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

[Bug]: SourcemapDevToolPlugin uses the incorrect contenthash - outputs assets contenthash rather than sourcemaps contenthash #8597

Closed
cblagg opened this issue Dec 2, 2024 · 0 comments · Fixed by #8623
Assignees
Labels
bug Something isn't working

Comments

@cblagg
Copy link

cblagg commented Dec 2, 2024

System Info

OS: macOS 13.6.3
CPU: (10) arm64 Apple M1 Pro
Memory: 7.02 GB / 32.00 GB
Shell: 5.9 - /bin/zsh

Binaries:
Node: 22.11.0 - ~/.nvm/versions/node/v22.11.0/bin/node
npm: 10.9.0 - ~/.nvm/versions/node/v22.11.0/bin/npm

Browsers:
Chrome: 130.0.6723.117

npmPackages:
@rspack/cli: 1.1.4 => 1.1.4
@rspack/core: 1.1.4 => 1.1.4

Details

When using SourceMapDevToolPlugin, the produced sourcemaps filename outputs the incorrect hash in the filename template for [contenthash]. It outputs the assets contenthash in this token rather than the sourcemaps contenthash.

This behavior is unexpected and different to behavior within Webpack.

The current RSPack behavior can result in sourcemap files overwriting each other with the same name despite different content - when a underlying source change is only types.

When using the SourceMapDevToolPlugin, it is expected that the [contenthash] in it's configuration of the filename refers to the content hash of the sourcemap.

Webpack explicitly creates the [contenthash] for naming the sourcemap here.

Reproduce link

https://github.com/cblagg/rspack-sourcemap-name-repro

Reproduce Steps

Steps to reproduce:

  1. npm i
  2. Run: ENTRY=untyped npm run build:webpack
  3. Run: ENTRY=typed npm run build:webpack
  4. Run: ENTRY=untyped npm run build
  5. Run: ENTRY=typed npm run build
  6. Observe dist/webpack contains 3 files. Where the sourcemap files are named with the pattern of:
  • {sourcemaps_content_hash}-{entry_name}-{entry_content_hash}-min.js.map
  1. Observe dist/rspack contains only 2 files. Because one is overwritten, due to the entries contenthash being used rather than the sourcemaps content hash, resulting in the pattern:
  • {entry_content_hash}-{entry_name}-{entry_content_hash}-min.js.map

When using the SourceMapDevToolPlugin, it is expected that the [contenthash] in it's configuration of the filename refers to the content hash of the sourcemap, not the content hash of the entry asset.

@cblagg cblagg added bug Something isn't working pending triage The issue/PR is currently untouched. labels Dec 2, 2024
@LingyuCoder LingyuCoder self-assigned this Dec 4, 2024
@LingyuCoder LingyuCoder removed the pending triage The issue/PR is currently untouched. label Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants