-
-
Notifications
You must be signed in to change notification settings - Fork 782
Description
System Info
System:
OS: macOS 14.6.1
CPU: (12) arm64 Apple M2 Max
Memory: 30.78 GB / 96.00 GB
Shell: 3.7.1 - /opt/homebrew/bin/fish
npmPackages:
@rspack/cli: ^1.0.5 => 1.0.5
@rspack/core: ^1.0.5 => 1.0.5
Details
I'm using custom configuration of SourceMapDevToolPlugin, both Webpack and Rspack documentation shows that I should set devtool: false.
https://webpack.js.org/plugins/source-map-dev-tool-plugin/#root
https://rspack.dev/plugins/webpack/source-map-dev-tool-plugin
But after I set devtool: false, I found the source-map is not correctly generated.
After dive into the compilation process, I found that is caused by the this.sourceMap changes to false in my custom loader.
// loader.js
export default function(content) {
const callback = this.async()
const result = transform(content, { sourceMap: this.sourceMap }) // this.sourceMap === false
callback(null, result.code, result.map) // result.map === false, result in no source-map generated
}The Rspack directly use devtool to setup loaderContext.sourceMap:
rspack/packages/rspack/src/loader-runner/index.ts
Lines 556 to 558 in 2ec06e4
| loaderContext.sourceMap = compiler.options.devtool | |
| ? isUseSourceMap(compiler.options.devtool) | |
| : false; |
But Webpack will update the value in the SourceMapDevToolModuleOptionsPlugin:
Reproduce link
https://github.com/colinaaa-reproductions/rspack-loader-context-sourcemap
Reproduce Steps
- Run
pnpm install - Run
pnpm build:webpack - Run
node webpack-dist/main.js// showtrue - Run
pnpm build:rspack - Run
node rspack-dist/main.js// showfalse