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

fix!: align devtool default value #6904

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -236,34 +236,34 @@ chunk (runtime: e2) e2.js (e2) 51 bytes (javascript) 8.38 KiB (runtime) [entry]
`;

exports[`statsOutput statsOutput/optimization-runtime-chunk should print correct stats for 1`] = `
"Entrypoint e1 4.01 KiB = e1~runtime.js 3.68 KiB e1.js 338 bytes
Entrypoint e2 4.01 KiB = e2~runtime.js 3.68 KiB e2.js 338 bytes
"Entrypoint e1 4.07 KiB = e1~runtime.js 3.68 KiB e1.js 391 bytes
Entrypoint e2 4.07 KiB = e2~runtime.js 3.68 KiB e2.js 391 bytes
chunk (runtime: e1~runtime) e1.js (e1) 27 bytes [entry] [rendered]
chunk (runtime: e1~runtime) e1~runtime.js (e1~runtime) 2.58 KiB [initial] [rendered]
chunk (runtime: e2~runtime) e2.js (e2) 27 bytes [entry] [rendered]
chunk (runtime: e2~runtime) e2~runtime.js (e2~runtime) 2.58 KiB [initial] [rendered]"
`;

exports[`statsOutput statsOutput/optimization-runtime-chunk-multiple should print correct stats for 1`] = `
"Entrypoint e1 4.01 KiB = runtime~e1.js 3.68 KiB e1.js 338 bytes
Entrypoint e2 4.01 KiB = runtime~e2.js 3.68 KiB e2.js 338 bytes
"Entrypoint e1 4.07 KiB = runtime~e1.js 3.68 KiB e1.js 391 bytes
Entrypoint e2 4.07 KiB = runtime~e2.js 3.68 KiB e2.js 391 bytes
chunk (runtime: runtime~e1) e1.js (e1) 27 bytes [entry] [rendered]
chunk (runtime: runtime~e2) e2.js (e2) 27 bytes [entry] [rendered]
chunk (runtime: runtime~e1) runtime~e1.js (runtime~e1) 2.58 KiB [initial] [rendered]
chunk (runtime: runtime~e2) runtime~e2.js (runtime~e2) 2.58 KiB [initial] [rendered]"
`;

exports[`statsOutput statsOutput/optimization-runtime-chunk-single should print correct stats for 1`] = `
"Entrypoint e1 4.01 KiB = runtime.js 3.68 KiB e1.js 338 bytes
Entrypoint e2 4.01 KiB = runtime.js 3.68 KiB e2.js 338 bytes
"Entrypoint e1 4.06 KiB = runtime.js 3.68 KiB e1.js 391 bytes
Entrypoint e2 4.06 KiB = runtime.js 3.68 KiB e2.js 391 bytes
chunk (runtime: runtime) e1.js (e1) 27 bytes [entry] [rendered]
chunk (runtime: runtime) e2.js (e2) 27 bytes [entry] [rendered]
chunk (runtime: runtime) runtime.js (runtime) 2.58 KiB [initial] [rendered]"
`;

exports[`statsOutput statsOutput/optimization-runtime-chunk-true should print correct stats for 1`] = `
"Entrypoint e1 4.01 KiB = runtime~e1.js 3.68 KiB e1.js 338 bytes
Entrypoint e2 4.01 KiB = runtime~e2.js 3.68 KiB e2.js 338 bytes
"Entrypoint e1 4.07 KiB = runtime~e1.js 3.68 KiB e1.js 391 bytes
Entrypoint e2 4.07 KiB = runtime~e2.js 3.68 KiB e2.js 391 bytes
chunk (runtime: runtime~e1) e1.js (e1) 27 bytes [entry] [rendered]
chunk (runtime: runtime~e2) e2.js (e2) 27 bytes [entry] [rendered]
chunk (runtime: runtime~e1) runtime~e1.js (runtime~e1) 2.58 KiB [initial] [rendered]
Expand Down Expand Up @@ -387,8 +387,8 @@ Rspack x.x.x compiled with 1 error in X s"
`;

exports[`statsOutput statsOutput/resolve-unexpected-exports-in-pkg-error should print correct stats for 1`] = `
"asset bundle.js 945 bytes [emitted] (name: main)
Entrypoint main 945 bytes = bundle.js
"asset bundle.js 1.38 KiB [emitted] (name: main)
Entrypoint main 1.38 KiB = bundle.js
runtime modules 280 bytes 1 module
./index.js 39 bytes [built] [code generated] [1 error]

Expand Down Expand Up @@ -441,8 +441,8 @@ Rspack x.x.x compiled successfully in X s"
`;

exports[`statsOutput statsOutput/simple-export should print correct stats for 1`] = `
"asset bundle.js 1.25 KiB [emitted] (name: main)
Entrypoint main 1.25 KiB = bundle.js
"asset bundle.js 1.71 KiB [emitted] (name: main)
Entrypoint main 1.71 KiB = bundle.js
runtime modules 677 bytes 3 modules
./index.js 26 bytes [built] [code generated]
Rspack x.x.x compiled successfully in X s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ module.exports = {
+ "type": "filesystem",
+ },
@@ ... @@
- "devtool": false,
+ "devtool": "eval",
@@ ... @@
- "mode": "none",
+ "mode": "development",
@@ ... @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ module.exports = {
- "cache": false,
+ "cache": true,
@@ ... @@
- "devtool": false,
+ "devtool": "eval",
@@ ... @@
- "mode": "none",
+ "mode": "development",
@@ ... @@
Expand Down
3 changes: 1 addition & 2 deletions packages/rspack/src/config/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ export const applyRspackOptionsDefaults = (
}
}

// IGNORE(devtool): devtool is default to "eval" in webpack when mode is development
F(options, "devtool", () => false as const);
F(options, "devtool", () => (development ? "eval" : false));
D(options, "watch", false);
D(options, "profile", false);
// IGNORE(bail): bail is default to false in webpack, but it's set in `Compilation`
Expand Down
12 changes: 6 additions & 6 deletions webpack-test/__snapshots__/StatsTestCases.basictest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ Entrypoint main 294 KiB = no-warning.pro-node.js
./index.js 293 KiB [built] [code generated]
Rspack x.x.x compiled successfully in X s

asset no-warning.dev-web.js 294 KiB [emitted] (name: main)
Entrypoint main 294 KiB = no-warning.dev-web.js
asset no-warning.dev-web.js 1.72 MiB [emitted] (name: main)
Entrypoint main 1.72 MiB = no-warning.dev-web.js
./index.js 293 KiB [built] [code generated]
Rspack x.x.x compiled successfully in X s

asset no-warning.dev-node.js 294 KiB [emitted] (name: main)
Entrypoint main 294 KiB = no-warning.dev-node.js
asset no-warning.dev-node.js 1.72 MiB [emitted] (name: main)
Entrypoint main 1.72 MiB = no-warning.dev-node.js
./index.js 293 KiB [built] [code generated]
Rspack x.x.x compiled successfully in X s

asset no-warning.dev-web-with-limit-set.js 294 KiB [emitted] (name: main)
Entrypoint main 294 KiB = no-warning.dev-web-with-limit-set.js
asset no-warning.dev-web-with-limit-set.js 1.72 MiB [emitted] (name: main)
Entrypoint main 1.72 MiB = no-warning.dev-web-with-limit-set.js
./index.js 293 KiB [built] [code generated]
Rspack x.x.x compiled successfully in X s

Expand Down
2 changes: 1 addition & 1 deletion website/docs/en/config/devtool.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type Devtool =
| 'eval-nosources-source-map';
```

- **Default:** `false`
- **Default:** `eval`

The main types of Source Map generated behaviors are `source-map`, `eval`, `cheap`, `module`, `inline`, `nosources` and `hidden`, and can be combined.

Expand Down
2 changes: 1 addition & 1 deletion website/docs/zh/config/devtool.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type Devtool =
| 'eval-nosources-source-map';
```

- **默认值:** `false`
- **默认值:** `eval`

主要分为 `source-map`、`eval`、`cheap`、`module`、`inline`、`nosources` 和 `hidden` 这几种 Source Map 生成的行为,并可以进行组合。

Expand Down
Loading