Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sourceMappingURL in built JS is invalid #2343

Closed
5 tasks done
polarathene opened this issue Feb 25, 2021 · 3 comments · Fixed by aws/jsii#2693, hacf-fr/awesome-francophone-home-assistant#106 or JosephMontoya-TRI/BEEP#3
Closed
5 tasks done
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@polarathene
Copy link
Contributor

  • I've read the [contribution guidelines][1] and agree with them

I've found a bug and checked that ...

  • ... the problem doesn't occur with the default MkDocs template
  • ... the problem is not in any of my customizations (CSS, JS, template)
  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

I am fairly certain this isn't related to upstream MkDocs, AFAIK the asset bundling optimization is only offered by MkDocs Material here. The minified output files are incorrectly pointing to the Source Map files they generate, which the browser console will issue warnings about as unable to parse, thus they're not useful.

This appears to be the related code as your docs mention you use ESBuild:

const file = digest(options.to, js)
return concat(
mkdir(path.dirname(file)),
defer(() => merge(
fs.writeFile(`${file}.map`, map),
fs.writeFile(`${file}`, js.replace(
/(sourceMappingURL=)(.*)/,
`$1${path.basename(file)}\n`
)),
))
)

Slightly related, advice for adding JS via the docs here seems to mirror roughly what upstream MkDocs advise. I assume that these third-party assets are not included in the bundling during build? (seems to only process bundle and search TS files from this projects src/** dir)

Expected behavior

Processed JS file should be: //# sourceMappingURL=bundle.926459b3.min.js.map

Actual behavior

Processed JS files are actually: //# sourceMappingURL=bundle.926459b3.min.js

Probably just needs to be:

`$1${path.basename(file)}.map\n`

Steps to reproduce the bug

  1. Visit the MkDocs Material site.
  2. Open the console dev tools panel.
  3. Logged warning should be visible (at least on Firefox), or may require a refresh.
  4. Alternatively, inspecting the source via dev tools will show only minified JS that was loaded, source map would have failed to load.

Package versions

Current Docker container and current version of the website.

Project configuration

Standard instance should do the trick, this is an internal bug.

System information

Manjaro Linux with Firefox. Present with Docker container build, present with Github Action workflow (python pip install, not docker) build deployed to Github Pages.

@squidfunk squidfunk added the bug Issue reports a bug label Feb 25, 2021
@squidfunk
Copy link
Owner

Confirmed, indeed the .mapwas missing!

@squidfunk
Copy link
Owner

Fixed in 1aacca3.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Feb 25, 2021
@squidfunk
Copy link
Owner

Released as part of 7.0.2

This was referenced Mar 8, 2021
This was referenced Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment