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

Using [name] within output.library, the correct value isn't utilized in the source map namespace #18243

Open
bwhite94 opened this issue Mar 25, 2024 · 3 comments

Comments

@bwhite94
Copy link

bwhite94 commented Mar 25, 2024

Bug report

What is the current behavior?
When utilizing multiple entry points, and specifying a custom library name which includes the [name] placeholder, the source-map resource path is excluding the replaced [name] value with an empty string.

This is causing issues where sources will not be presented properly or may conflict if generated with the same output.library pattern.

If the current behavior is a bug, please provide the steps to reproduce.
Minimal reproduction repository: https://github.com/bwhite94/webpack-source-map-issue

  1. Configure your webpack config to have multiple named entry-points.
  2. Specify output.library to include the [name] placeholder. E.g: library-[name]
  3. Ensure devtool: 'source-map' exists in your webpack config object. (This may also exist with other devtools but haven't been tested)
  4. Run webpack build and inspect source map files. You will notice the sources will include values like: webpack://library-/...

What is the expected behavior?
The source map sources should include the correct namespace with the [name] value present. E.g: webpack://library-entry-a/... and webpack://library-entry-b/...

Other relevant information:
webpack version: 5.91.0
Node.js version: 20.11.1
Operating System: Windows 11
Additional tools:

@bwhite94 bwhite94 changed the title Using [name] within output.library, the correct value isn't utilized in the source map namespace Using [name] within output.library, the correct value isn't utilized in the source map namespace Mar 25, 2024
@alexander-akait
Copy link
Member

Feel free to send a PR

@keshav861
Copy link

@bwhite94 where is the webpack.config.js file i have got the issue and i think that i have a solution for it but i was not able to find the file in the repo can you help me out.

@bwhite94
Copy link
Author

@bwhite94 where is the webpack.config.js file i have got the issue and i think that i have a solution for it but i was not able to find the file in the repo can you help me out.

It's in the minimal reproduction repo, but more specifically here.

I know of workarounds like generating separate webpack config objects for each entry-point that needs a different library name, but that defeats the purpose of using things like the [name] placeholder and adds extra overhead that could potentially break your webpack configuration if you're not careful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Priority - Medium
Development

No branches or pull requests

4 participants