webpack: Webpack source maps are broken for debugging in Firefox
I’ve put together a quick repo to demonstrate the problem: https://github.com/Stuk/webpack-sourcemaps-firefox
And here’s a gif of the issue in action:
I’ve checked Uglify, and Firefox has no issues there. I’ve tried the different config options for devtool
:
eval
- workscheap-eval-source-map
- workscheap-source-map
- does not workcheap-module-eval-source-map
- workscheap-module-source-map
- does not workeval-source-map
- workssource-map
- does not work
So seems like eval is file, but an external sourcemap for multiple files does not.
Any thoughts about what’s going on?
I’ve also filed an issue on Bugzilla, in case this is a FF devtools issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1177329
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 42
- Comments: 80 (13 by maintainers)
👋🏻 Firefox DevTools PM here.
I am collecting any remaining source-map issues after we fixed a whole lot in the past releases (summarized in my hacks article). I was glad to see that this a few issues mentioned here seem to be addressed, but I want to make sure.
We need your help 🙏. Please post if any remaining source map issues with the webpack configurations, potentially STRs or even open source projects that are affected. To let us understand our impact so far, please also share if previously broken source maps are working now. Feel free to reach out directly.
@wis @viorelsfetea @jasonLaster the extension’s CSP is not related to those errors, the source maps are fetched from a worker running on the devtools client side and so the CSP of the extension doesn’t have any effect on them.
Currently, a (very annoying) workaround to make the extensions’ sourcemaps available to the source-map worker could be to point the
sourceMappingURL=...
explicitly to an HTTP url, e.g. by temporarily changing it in the bundled/transpiled file into something like//# sourceMappingURL=http://localhost:8080/bundle.js.map
and then make the source maps files available on that url by using something likepython -m SimpleHTTPServer
. The above workaround is also an additional proof that the extension CSP is not what is triggering this issue.The actual issue is that Addon Debugging window is currently running in its own separate process and a separate Firefox profile from the Firefox browser instance where the extension is installed, and so the developer tools are trying to fetch the source map from a moz-extension url that is not available locally (where “locally” I mean “in the Toolbox process where the debugger UI and the worker that is fetching and parsing the source maps data are running”).
This issue is tracked by Bug 1437937 (and in this comment there are some details about a possible approach to fix it). To be fair the sources of the source-map module are part of the debugger-html github repo, and so we should probably file an issue also in the github repo, because the fix is likely to require changes to both the mozilla-central (for the changes needed on the “remote debugging server” side) and in the debugger-html repo (for the changes needed to the souce-map module, and on the debugger ui if needed).
Can we please fix this? I don’t want to choose Chrome as the browser only coz of this issue.
Using FF 46.0 on Ubuntu. eval-source-map - sort of works source-map - sort of works Where sort of works means, I can find the original JSX source files (which have no syntax highlighting), set a breakpoint into them and they are triggered. But the console always shows the useless bundle lines.
@digitarald This example still produces a source map error: https://github.com/robertjk/webpack-firefox-source-map-error
Firefox 68.0b9 (64-Bit)
See also https://github.com/webpack-contrib/style-loader/issues/303 (already linked above).
Firefox 50+ has fixed this, but it is not yet enabled by default:
I can confirm that this is still an issue in Firefox Developer Edition 66.0b6 (64-bit) and works properly in Chrome.
@jasonLaster i’m developing a webExtension with Angular using the CLI (don’t have access to webpack config) and sourcemaps are not loading, is it CSP?
here’s the CSP I’ve tried in manifest.json:
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self' blob: filesystem:;"
everything’s fine in ChromeFor me sourcemaps work finally inside FF with this config:
output: { path: buildPath, //Path where the bundle should be exported filename: 'bundle.js', //Filename sourceMapFileName: 'bundle.js.map', //Filename publicPath: '/js/' //Where the js gets loaded from }, devtool: 'source-map',
Also please read this article: https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Use_a_source_map
I published an edit for the article which is not reviewed yet, but it is about setting devtools.sourcemap.locations.enabled to true at the about:config section.
Enjoy.
📯 The fix for missing
.vue
files landed in today’s Nightly and will ride the trains with Firefox 80.@theAdhocracy Errors like
TypeError: Invalid URL: .
should be fixed on Firefox Nightly right now, if you want to try that to verify.Developer version didn’t work for me. I’m still not seeing sass sources (works in Chrome).
The key point here is that ‘eval-source-map’ is partially broken for Firefox (you can set break points in the original sources, but stack traces from exceptions point uselessly to the compiled version, and typically to an eval at that). ‘source-map’ works fine, and ‘inline-source-map’ also works. I haven’t tried all the options.
With Chrome, both work.
Please can we re-open, even if it is just a documentation fix.
I’m having issues with locating source maps in firefox only. Here’s an example of the warning:
Propably a FF issue…
I had the issue until now. I removed the line
devtool: 'inline-source-map'
from webpack configuration file and it works (it uses eval by default, does’nt it?).@loganfsmyth Yep, just downloaded the latest version of Nightly and the errors are gone. That’s excellent news 👍
@digitarald Cheers, sent you some details
@darkship Whatever is causing
[name]
to still be in the URL is the problem. Something either in your config or in a plugin you’re using is creating an invalid URL.[name]
isn’t valid in a URL like that, and Chrome seems to not be validating that properly.AFAICS this got fixed in FF 67, can anybody confirm?
I’m having the exact same problem as @wis. the map file is there, I can access it by hand, but the extensions debugging window can’t see it. Does anybody have any ideas?
The only thing which works everywhere for me is:
cheap-module-inline-source-map
According to https://bugzilla.mozilla.org/show_bug.cgi?id=1177329 this should be fixed in FF nightly builds. Afraid I can’t check as I’m on vacation at the moment
Closing due to inactivity. Please test with latest
v5
and feel free to reopen if faced with the problem again (will be great if you provide reproducible test repo, this allow to fix a problem ASAP). Thanks!Works fine for me on the Developer Edition.
Is anyone still having problems? Firefox 71 fixed many issue with source maps, need feedback
@digitarald hi! is there any update on this? (was there a release of some kind where we could look at it?). Thanks
I have a vue app and source-map works perfectly with chrome but i still can’t make it work with FF v76.0.1, v77.0b9 developer ed. nor 78.0a1 nightly build. It works fine with js files but not with vue files. In my vue.config.js i have set configureWebpack: { devtool: “source-map”, … } What could be happening here? PLEASE HELP! THANKS
I had the same problem with
[name]
in the generated sourcemap, but in production build using devtool: ‘source-map’`.I was using
output.library
with[name]
as value.Specifying
output.devtoolNamespace
fixed the problem. I defined an arbitrary string, debugging with FF works. Not tested with Chrome / Safari.I had this issue with
devtool: "inline-source-map"
too .Using the plugin
new webpack.SourceMapDevToolPlugin({ filename: false})
anddevtool: false
option somehow fixed my sourcemap issue on FF.I also noticed that chrome had “[name]” as sourcemap root node and with the plugin it was named “webpack”
I hope this helps some of you.
CC @rpl
On Thu, Jun 28, 2018, 9:21 AM Viorel Sfetea notifications@github.com wrote:
@jasonLaster we need testing to ensure problem doesn’t exists anymore looks we have reproducible repos above
@evilebottnawi : https://github.com/webpack-contrib/style-loader/issues/303
@evilebottnawi Okay, I’ll try to.
Ran into this today. FWIW, I filed a bug in Firefox with a reproducible test case: https://bugzilla.mozilla.org/show_bug.cgi?id=1434081. This affects a bunch of Mozilla projects so I’m hoping to apply some leverage to get this fixed.
@adamziel Actually it works in the debugger, it’s just that error messages in the console point to the compiled code: https://youtu.be/pgS3x1hGPZ0 I’ve contacted the developer on Twitter: https://twitter.com/alex_marandon/status/686514228572864512
👍