webpack-plugin-hash-output icon indicating copy to clipboard operation
webpack-plugin-hash-output copied to clipboard

Usage with devtool: "hidden-source-map"

Open rtsao opened this issue 6 years ago • 5 comments

Thanks for making this plugin!

It's co common to use devtool: "hidden-source-map" in production. However, the problem with this use case is this plugin doesn't rename the final source map filename to match the final chunk asset filename. Usually when mapping stack traces server-side, the assumption is the source map filename is always x.js.map where the associated js file is x.js.

For "hidden-source-map" usage, it would be nice if this plugin renamed the source map filename to match the final chunk asset name.

Perhaps this could be an option/config. Happy to work on a PR and tests for this if that makes sense to you.

rtsao avatar Oct 04 '18 19:10 rtsao

The reason we don't rename sourcemaps is because they create a circular dependency: the .js file contains a reference to the sourcemap, and the sourcemap contains a reference to the .js file.

Maybe there is a solution I don't see, feel free to try fixing it :)

scinos avatar Nov 02 '18 07:11 scinos

With sourcemap: “hidden”, the .js doesn’t reference the map; the comment is omitted.

rtsao avatar Nov 02 '18 15:11 rtsao

Sorry, I read your message to quickly :( You are right. With hidden-source-map this should work.

We probably don't need a config option: we can scan the .js source looking for the name of the sourcemap. If not found, then we can assume there is not a circular dependency and we can rename both. That way this will work for hidden-source-map or any other future devtool option that generates sourcemaps without circular dependencies.

What do you think?

scinos avatar Nov 02 '18 22:11 scinos

Wouldn't this be solved by #28?

wmertens avatar Jul 29 '19 21:07 wmertens

Is there a workaround for this?

gajus avatar Jul 15 '20 01:07 gajus