Skip to content

Commit 0f5a0bd

Browse files
authored
feat!: change default value for devtool (#12934)
1 parent d1b61e7 commit 0f5a0bd

File tree

13 files changed

+29
-21
lines changed

13 files changed

+29
-21
lines changed

packages/rspack-cli/src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export class RspackCLI {
162162

163163
// false is also a valid value for sourcemap, so don't override it
164164
if (typeof item.devtool === 'undefined') {
165-
item.devtool = isBuild ? 'source-map' : 'cheap-module-source-map';
165+
item.devtool = isBuild ? false : 'cheap-module-source-map';
166166
}
167167
// The CLI flag has a higher priority than the default devtool and devtool from the config.
168168
if (typeof options.devtool !== 'undefined') {

packages/rspack/src/config/defaults.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ export const applyRspackOptionsDefaults = (
8181
}
8282
}
8383

84-
F(options, 'devtool', () => (development ? 'eval' : false));
84+
// IGNORE(devtool): Rspack use cheap-module-source-map by default
85+
F(options, 'devtool', () =>
86+
development ? 'cheap-module-source-map' : false,
87+
);
8588
D(options, 'watch', false);
8689
// IGNORE(lazyCompilation): Unlike webpack where lazyCompilation is configured under experiments, Rspack exposes this option at the configuration root level.
8790
D(options, 'lazyCompilation', false);

tests/e2e/cases/hooks/asset-emitted/index.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test('asset emitted hook should only emit modified assets', async ({
1515
return content.replace('__ROOT_TEXT__', '__OTHER_TEXT__');
1616
});
1717
await expect(page.locator('#root')).toHaveText('__OTHER_TEXT____FOO_VALUE__');
18-
expect(assets).toEqual(['main.js']);
18+
expect(assets.sort()).toEqual(['main.js', 'main.js.map']);
1919

2020
// reset assets
2121
assets.length = 0;
@@ -26,7 +26,12 @@ test('asset emitted hook should only emit modified assets', async ({
2626
});
2727
await expect(page.locator('#root')).toHaveText('__OTHER_TEXT____VALUE__');
2828
// main.js contains runtime module, so it should also emit
29-
expect(assets.sort()).toEqual(['main.js', 'src_foo_js.js']);
29+
expect(assets.sort()).toEqual([
30+
'main.js',
31+
'main.js.map',
32+
'src_foo_js.js',
33+
'src_foo_js.js.map',
34+
]);
3035

3136
// check dist dir
3237
// the outputFileSystem can contain only one main hot-update.js
@@ -53,7 +58,7 @@ test('asset emitted should not emit removed assets', async ({
5358
return 'document.getElementById("root").innerText = "__ROOT_TEXT__"';
5459
});
5560
await expect(page.locator('#root')).toHaveText('__ROOT_TEXT__');
56-
expect(assets).toEqual(['main.js']);
61+
expect(assets.sort()).toEqual(['main.js', 'main.js.map']);
5762

5863
// check dist dir
5964
const files = rspack.compiler.outputFileSystem.readdirSync(

tests/rspack-test/compilerCases/banner-plugin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ module.exports = [{
5555
options(context) {
5656
return {
5757
mode: "development",
58+
devtool: 'eval',
5859
entry: {
5960
footerFile: context.getDist("footerFile.js")
6061
},

tests/rspack-test/defaultsCases/cache/cache-filesystem-dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = {
2828
+ },
2929
@@ ... @@
3030
- "devtool": false,
31-
+ "devtool": "eval",
31+
+ "devtool": "cheap-module-source-map",
3232
@@ ... @@
3333
- "mode": "none",
3434
+ "mode": "development",

tests/rspack-test/defaultsCases/mode/development.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212
+ "cache": true,
1313
@@ ... @@
1414
- "devtool": false,
15-
+ "devtool": "eval",
15+
+ "devtool": "cheap-module-source-map",
1616
@@ ... @@
1717
- "mode": "none",
1818
+ "mode": "development",

tests/rspack-test/statsOutputCases/all-stats/rspack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/** @type {import("@rspack/core").Configuration} */
22
module.exports = {
33
mode: "development",
4+
devtool: 'eval',
45
entry: "./index.js",
56
output: {
67
filename: "bundle.js"

tests/rspack-test/statsOutputCases/immutable/rspack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/** @type {import("@rspack/core").Configuration} */
22
module.exports = {
33
mode: "development",
4+
devtool: 'eval',
45
entry: "./index.js",
56
output: {
67
filename: "[contenthash].js"

tests/rspack-test/statsOutputCases/performance-different-mode-and-target/rspack.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module.exports = [
3939
{
4040
entry: "./index",
4141
mode: "development",
42+
devtool: 'eval',
4243
target: "web",
4344
output: {
4445
filename: "no-warning.dev-web.js"
@@ -51,6 +52,7 @@ module.exports = [
5152
{
5253
entry: "./index",
5354
mode: "development",
55+
devtool: 'eval',
5456
target: "node",
5557
output: {
5658
filename: "no-warning.dev-node.js"
@@ -63,6 +65,7 @@ module.exports = [
6365
{
6466
entry: "./index",
6567
mode: "development",
68+
devtool: 'eval',
6669
target: "web",
6770
performance: {
6871
maxAssetSize: 100

tests/rspack-test/statsOutputCases/resolve-unexpected-exports-in-pkg-error/rspack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
entry: './index.js',
33
mode: 'development',
4+
devtool: 'eval',
45
stats: {
56
assets: true,
67
modules: true,

0 commit comments

Comments
 (0)