workbox icon indicating copy to clipboard operation
workbox copied to clipboard

Webpack devtool-option not considered for sourcemap generation

Open jens-duttke opened this issue 5 years ago • 4 comments

Library Affected: workbox-webpack-plugin

Browser & Platform: "all browsers" (not the browser is the issue, it's the auto-generated code)

Issue or Feature Request Description: The plugin does not consider the Webpack devtool configuration for the sourcemap generation. I'm using the value 'hidden-source-map', but the plugin append //# sourceMappingURL=service-worker.js.map to the JavaScript file.

I need the source maps to upload them to my error tracker (so disabling them is not an option), but I don't upload them to the webserver. The result is that browsers like Chrome and Edge (correctly) complain about the missing sourcemap:

DevTools failed to load SourceMap: Could not load content for https://[...]/service-worker.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE

The WorkboxPlugin.GenerateSW option sourcemap is only a boolean, so it doesn't allow a setup with hidden sourcemap. Furthermore, it would be better if the plugin adhered to the webpack standards.

jens-duttke avatar Jun 30 '20 17:06 jens-duttke

In Workbox v5, workbox-webpack-plugin's GenerateSW mode uses Rollup under the hood to create its bundled output—it's basically a wrapper on top of workbox-build's generateSW mode, with the webpack asset pipeline used to determine the precache manifest instead of glob patterns.

(I understand that this might be surprising, but sharing code in that manner should hopefully lead to less divergence between the webpack plugin's GenerateSW behavior and the workbox-build/workbox-cli's behavior, which has historically been an issue.)

I do see that Rollup now supports boolean | 'inline' | 'hidden' as its input for configuring sourcemaps, so expanding the options available in the GenerateSW plugin to match that sounds reasonable for Workbox v6.

If you use the InjectManifest plugin, an actual webpack child compilation is kicked off that uses the parent compilation's configuration, and I think that should include the sourcemap options. So switching to InjectManifest might be a viable short-term solution if you need one right away.

jeffposnick avatar Jun 30 '20 17:06 jeffposnick

v6 has been released now. Are there any news to this issue?

jens-duttke avatar Dec 01 '20 18:12 jens-duttke

Sorry, this unfortunately did not make it into v6.

jeffposnick avatar Dec 02 '20 18:12 jeffposnick

@tropicadri Seems like this repo may be dying, but if google decides to focus on it again, this issue could really use some attention, it's very low hanging fruit!

719media avatar Sep 19 '23 14:09 719media