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
sourcemap collision when building as a library #5767
Comments
Are you thinking about adding the |
@sokra yes, will try to do that. I do have some questions though:
|
|
@sokra thanks for the reply! Having |
@MagicDuck Feel free to open an Issue /PR at |
I can do that. Just wanted to get to get @sokra 's opinion since he has the context to give a wholistic approach to the solution rather than piecemeal everywhere. |
In my opinion a prefix for the CSS Source Maps does make sense. Maybe we shouldn't merge it into |
When loading multiple libraries built with webpack, you can run into collisions of the sourcemap file paths. For examle, both have "webpack:///src/index.js". This change addresses the problem by introducing a new output option `output.devtoolNamespace` which defaults to `output.library` when not specified. The defaults moduleFilenameTemplates in all the sourcemap plugins have been modified to start with: "webpack://[namespace]/...", where [namespace] will be replaced by the `output.devtoolNamespace`. Notice that there are only two slashes following "webpack:" now. This is to make it behave just as before when not building with a namespace. When building with a namespace you only get the two slashes, but from what I've seen the chrome dev tools only care about the first 2 slashes anyways. webpack#5767
When loading multiple libraries built with webpack, you can run into collisions of the sourcemap file paths. For examle, both have "webpack:///src/index.js". This change addresses the problem by introducing a new output option `output.devtoolNamespace` which defaults to `output.library` when not specified. The defaults moduleFilenameTemplates in all the sourcemap plugins have been modified to start with: "webpack://[namespace]/...", where [namespace] will be replaced by the `output.devtoolNamespace`. Notice that there are only two slashes following "webpack:" now. This is to make it behave just as before when not building with a namespace. When building with a namespace you only get the two slashes, but from what I've seen the chrome dev tools only care about the first 2 slashes anyways. Discussed with sokra here: webpack#5767
PR here: #5844 :) |
When loading multiple libraries built with webpack, you can run into collisions of the sourcemap file paths. For examle, both have "webpack:///src/index.js". This change addresses the problem by introducing a new output option `output.devtoolNamespace` which defaults to `output.library` when not specified. The defaults moduleFilenameTemplates in all the sourcemap plugins have been modified to start with: "webpack://[namespace]/...", where [namespace] will be replaced by the `output.devtoolNamespace`. Notice that there are only two slashes following "webpack:" now. This is to make it behave just as before when not building with a namespace. When building with a namespace you only get the two slashes, but from what I've seen the chrome dev tools only care about the first 2 slashes anyways. Discussed with sokra here: webpack#5767
When loading multiple libraries built with webpack, you can run into collisions of the sourcemap file paths. For examle, both have "webpack:///src/index.js". This change addresses the problem by introducing a new output option `output.devtoolNamespace` which defaults to `output.library` when not specified. The defaults moduleFilenameTemplates in all the sourcemap plugins have been modified to start with: "webpack://[namespace]/...", where [namespace] will be replaced by the `output.devtoolNamespace`. Notice that there are only two slashes following "webpack:" now. This is to make it behave just as before when not building with a namespace. When building with a namespace you only get the two slashes, but from what I've seen the chrome dev tools only care about the first 2 slashes anyways. Discussed with sokra here: webpack#5767
also filed issue on the |
@MagicDuck Thanks for adding this options. I'm waiting for your namespace PR request to go through. |
@adrianromanko my pleasure 😀. I looks it was merged a while ago. Its probably available in webpack 4. |
Thanks for this, its useful when you build a library with multiple entry points. I use a library option like this |
@jazdw that sounds like a bug to me. You should file an issue I think. Closing this one. |
@jazdw Did you end up creating that ticket, also experiencing the same problem: many entrypoints, many output bundles, each being a umd library with sourcemaps that all get called |
@airtonix no I didn't sorry |
Do you want to request a feature or report a bug?
What is the current behavior?
This happens when you have multiple webpack builds that integrate at runtime. For instance, I have a couple of projects that are built as webpack libraries (libraryTarget: "jsonp"). I use those libraries in a 3rd project. When I try to debug, I can see the sourcemaps for the libraries code in the devtool, but if you happen to have a file with the the same path in both libraries, for example:
"webpack:///src/index.js"
Then you basically just see the one for last loaded library...
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
We should have a way namespace those paths. Would be nice if you could change only the webpack:/// prefix independent on the devtool being used. Then we could switch it to something like:
webpack (<library name>):///
I am guessing there should be some config option, a function, which is applied on the template as a last thing before usage. The reason for not using
output.devtoolModuleFilenameTemplate
is that there seem to be different defaults for different devtool settings...If this is a feature request, what is motivation or use case for changing the behavior?
debugging webpack built lilbraries
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
The text was updated successfully, but these errors were encountered: