Skip to content

Commit

Permalink
fix: sourceMapFilename default value (#6845)
Browse files Browse the repository at this point in the history
  • Loading branch information
SyMind authored Jun 18, 2024
1 parent ebeac79 commit ede24bb
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ Object {
"pathinfo": false,
"publicPath": "auto",
"scriptType": false,
"sourceMapFilename": "[file].map",
"sourceMapFilename": "[file].map[query]",
"strictModuleErrorHandling": false,
"trustedTypes": undefined,
"uniqueName": "@rspack/test-tools",
Expand Down
1 change: 0 additions & 1 deletion packages/rspack/scripts/check-documentation-coverage.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ function checkConfigsDocumentationCoverage() {
"output.workerWasmLoading",
"output.workerPublicPath",
"output.strictModuleExceptionHandling",
"output.sourceMapFilename",

"stats",

Expand Down
5 changes: 1 addition & 4 deletions packages/rspack/src/config/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,10 +720,7 @@ const applyOutputDefaults = (
F(output, "clean", () => !!output.clean);
D(output, "crossOriginLoading", false);
D(output, "workerPublicPath", "");
// IGNORE(output.sourceMapFilename): In webpack, sourceMapFilename is [file].map[query] by default
F(output, "sourceMapFilename", () => {
return "[file].map";
});
D(output, "sourceMapFilename", "[file].map[query]");
F(output, "scriptType", () => (output.module ? "module" : false));

const { trustedTypes } = output;
Expand Down
9 changes: 9 additions & 0 deletions website/docs/en/config/output.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,15 @@ module.exports = {
};
```

## output.sourceMapFilename

- **Type:** `string`
- **Default:** `'[file].map[query]'`

Configure how source maps are named. Only takes effect when [`devtool`](/config/devtool) is set to `'source-map'`, which writes an output file.

The `[name]`, `[id]`, `[fullhash]` and `[chunkhash]` substitutions from [`output.filename`](#outputfilename) can be used. In addition to those, you can use substitutions listed under Filename-level in [Template strings](#template-string).

## output.strictModuleErrorHandling

- **Type:** `boolean`
Expand Down
17 changes: 13 additions & 4 deletions website/docs/zh/config/output.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,15 @@ module.exports = {

## output.devtoolFallbackModuleFilenameTemplate

- **Type:** `string` | `function (info)`
- **类型:** `string` | `function (info)`

当模板字符串或函数产生重复时使用的备用内容。

详见 [`output.devtoolModuleFilenameTemplate`](/config/output#outputdevtoolmodulefilenametemplate).

## output.devtoolModuleFilenameTemplate

- **Type:** `string = 'webpack://[namespace]/[resource-path]?[loaders]'` | `function (info) => string`
- **类型:** `string = 'webpack://[namespace]/[resource-path]?[loaders]'` | `function (info) => string`

此选项仅在 [`devtool`](/config/devtool.html) 使用了需要模块名称的选项时使用。

Expand Down Expand Up @@ -428,8 +428,8 @@ import './others.js';

## output.scriptType

- **Type:** `'module' | 'text/javascript' | boolean`
- **Default:** `false`
- **类型:** `'module' | 'text/javascript' | boolean`
- **默认值:** `false`

该选项允许使用自定义脚本类型(例如 `<script type="module" ...>`)来加载异步块。

Expand All @@ -446,6 +446,15 @@ module.exports = {
};
```

## output.sourceMapFilename

- **类型:** `string`
- **默认值:** `'[file].map[query]'`

配置 source map 文件的命名方式。仅当 [`devtool`](/config/devtool) 设置为 `'source-map'` 时生效,此时会输出文件。

可以使用 [`output.filename`](#outputfilename) 中的 `[name]``[id]``[fullhash]``[chunkhash]` 替换符。此外,还可以使用 [Template strings](#template-string) 中在文件级别列出的替换符。

## output.strictModuleErrorHandling

- **类型:** `boolean`
Expand Down

2 comments on commit ede24bb

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs ❌ failure
_selftest ✅ success
nx ✅ success
rspress ✅ success
rsbuild ✅ success
compat ✅ success
examples ✅ success

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-06-18 553f785) Current Change
10000_development-mode + exec 2.21 s ± 22 ms 2.22 s ± 26 ms +0.23 %
10000_development-mode_hmr + exec 737 ms ± 12 ms 737 ms ± 7.1 ms +0.06 %
10000_production-mode + exec 2.57 s ± 22 ms 2.6 s ± 41 ms +1.12 %
arco-pro_development-mode + exec 1.94 s ± 68 ms 1.96 s ± 74 ms +0.95 %
arco-pro_development-mode_hmr + exec 441 ms ± 2.1 ms 442 ms ± 0.95 ms +0.18 %
arco-pro_production-mode + exec 3.53 s ± 85 ms 3.54 s ± 95 ms +0.41 %
threejs_development-mode_10x + exec 1.46 s ± 11 ms 1.47 s ± 17 ms +0.71 %
threejs_development-mode_10x_hmr + exec 799 ms ± 3.3 ms 788 ms ± 15 ms -1.32 %
threejs_production-mode_10x + exec 4.76 s ± 33 ms 4.78 s ± 31 ms +0.32 %

Please sign in to comment.