Skip to content

Commit

Permalink
feat: add compiler.rspack (#7434)
Browse files Browse the repository at this point in the history
  • Loading branch information
LingyuCoder authored Aug 5, 2024
1 parent b616f98 commit 4471e41
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
Object {
"message": " × Error: test push\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n",
"moduleTrace": Array [],
"stack": "Error: test push\\n at Object.fn (<cwd>packages/rspack-test-tools/tests/errorCases/error-test-push.js:10:31)\\n at next (<cwd>packages/rspack-lite-tapable/dist/index.js:529:25)\\n at AsyncSeriesHook.callAsyncStageRange (<cwd>packages/rspack-lite-tapable/dist/index.js:549:9)\\n at AsyncSeriesHook.callAsync (<cwd>packages/rspack-lite-tapable/dist/index.js:88:21)\\n at <cwd>packages/rspack/dist/Compiler.js:458:41\\n at <cwd>packages/rspack/dist/Compiler.js:525:23",
"stack": "Error: test push\\n at Object.fn (<cwd>packages/rspack-test-tools/tests/errorCases/error-test-push.js:10:31)\\n at next (<cwd>packages/rspack-lite-tapable/dist/index.js:529:25)\\n at AsyncSeriesHook.callAsyncStageRange (<cwd>packages/rspack-lite-tapable/dist/index.js:549:9)\\n at AsyncSeriesHook.callAsync (<cwd>packages/rspack-lite-tapable/dist/index.js:88:21)\\n at <cwd>packages/rspack/dist/Compiler.js:459:41\\n at <cwd>packages/rspack/dist/Compiler.js:526:23",
},
Object {
"loc": "1:0-33",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = {
Object {
"message": " × Error: test unshift\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n",
"moduleTrace": Array [],
"stack": "Error: test unshift\\n at Object.fn (<cwd>packages/rspack-test-tools/tests/errorCases/error-test-shift.js:13:35)\\n at next (<cwd>packages/rspack-lite-tapable/dist/index.js:529:25)\\n at AsyncSeriesHook.callAsyncStageRange (<cwd>packages/rspack-lite-tapable/dist/index.js:549:9)\\n at AsyncSeriesHook.callAsync (<cwd>packages/rspack-lite-tapable/dist/index.js:88:21)\\n at <cwd>packages/rspack/dist/Compiler.js:458:41\\n at <cwd>packages/rspack/dist/Compiler.js:525:23",
"stack": "Error: test unshift\\n at Object.fn (<cwd>packages/rspack-test-tools/tests/errorCases/error-test-shift.js:13:35)\\n at next (<cwd>packages/rspack-lite-tapable/dist/index.js:529:25)\\n at AsyncSeriesHook.callAsyncStageRange (<cwd>packages/rspack-lite-tapable/dist/index.js:549:9)\\n at AsyncSeriesHook.callAsync (<cwd>packages/rspack-lite-tapable/dist/index.js:88:21)\\n at <cwd>packages/rspack/dist/Compiler.js:459:41\\n at <cwd>packages/rspack/dist/Compiler.js:526:23",
},
],
"warnings": Array [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
Object {
"message": " × Error: test splice\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n",
"moduleTrace": Array [],
"stack": "Error: test splice\\n at Object.fn (<cwd>packages/rspack-test-tools/tests/errorCases/error-test-splice-1.js:10:39)\\n at next (<cwd>packages/rspack-lite-tapable/dist/index.js:529:25)\\n at AsyncSeriesHook.callAsyncStageRange (<cwd>packages/rspack-lite-tapable/dist/index.js:549:9)\\n at AsyncSeriesHook.callAsync (<cwd>packages/rspack-lite-tapable/dist/index.js:88:21)\\n at <cwd>packages/rspack/dist/Compiler.js:458:41\\n at <cwd>packages/rspack/dist/Compiler.js:525:23",
"stack": "Error: test splice\\n at Object.fn (<cwd>packages/rspack-test-tools/tests/errorCases/error-test-splice-1.js:10:39)\\n at next (<cwd>packages/rspack-lite-tapable/dist/index.js:529:25)\\n at AsyncSeriesHook.callAsyncStageRange (<cwd>packages/rspack-lite-tapable/dist/index.js:549:9)\\n at AsyncSeriesHook.callAsync (<cwd>packages/rspack-lite-tapable/dist/index.js:88:21)\\n at <cwd>packages/rspack/dist/Compiler.js:459:41\\n at <cwd>packages/rspack/dist/Compiler.js:526:23",
},
],
"warnings": Array [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
Object {
"message": " × Error: test splice\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n",
"moduleTrace": Array [],
"stack": "Error: test splice\\n at Object.fn (<cwd>packages/rspack-test-tools/tests/errorCases/error-test-splice-2.js:10:39)\\n at next (<cwd>packages/rspack-lite-tapable/dist/index.js:529:25)\\n at AsyncSeriesHook.callAsyncStageRange (<cwd>packages/rspack-lite-tapable/dist/index.js:549:9)\\n at AsyncSeriesHook.callAsync (<cwd>packages/rspack-lite-tapable/dist/index.js:88:21)\\n at <cwd>packages/rspack/dist/Compiler.js:458:41\\n at <cwd>packages/rspack/dist/Compiler.js:525:23",
"stack": "Error: test splice\\n at Object.fn (<cwd>packages/rspack-test-tools/tests/errorCases/error-test-splice-2.js:10:39)\\n at next (<cwd>packages/rspack-lite-tapable/dist/index.js:529:25)\\n at AsyncSeriesHook.callAsyncStageRange (<cwd>packages/rspack-lite-tapable/dist/index.js:549:9)\\n at AsyncSeriesHook.callAsync (<cwd>packages/rspack-lite-tapable/dist/index.js:88:21)\\n at <cwd>packages/rspack/dist/Compiler.js:459:41\\n at <cwd>packages/rspack/dist/Compiler.js:526:23",
},
Object {
"loc": "1:0-33",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
Object {
"message": " ⚠ Error: test push\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n",
"moduleTrace": Array [],
"stack": "Error: test push\\n at Object.fn (<cwd>packages/rspack-test-tools/tests/errorCases/warning-test-push.js:10:33)\\n at next (<cwd>packages/rspack-lite-tapable/dist/index.js:529:25)\\n at AsyncSeriesHook.callAsyncStageRange (<cwd>packages/rspack-lite-tapable/dist/index.js:549:9)\\n at AsyncSeriesHook.callAsync (<cwd>packages/rspack-lite-tapable/dist/index.js:88:21)\\n at <cwd>packages/rspack/dist/Compiler.js:458:41\\n at <cwd>packages/rspack/dist/Compiler.js:525:23",
"stack": "Error: test push\\n at Object.fn (<cwd>packages/rspack-test-tools/tests/errorCases/warning-test-push.js:10:33)\\n at next (<cwd>packages/rspack-lite-tapable/dist/index.js:529:25)\\n at AsyncSeriesHook.callAsyncStageRange (<cwd>packages/rspack-lite-tapable/dist/index.js:549:9)\\n at AsyncSeriesHook.callAsync (<cwd>packages/rspack-lite-tapable/dist/index.js:88:21)\\n at <cwd>packages/rspack/dist/Compiler.js:459:41\\n at <cwd>packages/rspack/dist/Compiler.js:526:23",
},
Object {
"message": " ⚠ Module parse warning:\\n ╰─▶ ⚠ Unsupported feature: require.main.require() is not supported by Rspack.\\n ╭────\\n 1 │ require.main.require('./file');\\n · ──────────────────────────────\\n ╰────\\n \\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {
Object {
"message": " ⚠ Error: test unshift\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n",
"moduleTrace": Array [],
"stack": "Error: test unshift\\n at Object.fn (<cwd>packages/rspack-test-tools/tests/errorCases/warning-test-shift.js:13:37)\\n at next (<cwd>packages/rspack-lite-tapable/dist/index.js:529:25)\\n at AsyncSeriesHook.callAsyncStageRange (<cwd>packages/rspack-lite-tapable/dist/index.js:549:9)\\n at AsyncSeriesHook.callAsync (<cwd>packages/rspack-lite-tapable/dist/index.js:88:21)\\n at <cwd>packages/rspack/dist/Compiler.js:458:41\\n at <cwd>packages/rspack/dist/Compiler.js:525:23",
"stack": "Error: test unshift\\n at Object.fn (<cwd>packages/rspack-test-tools/tests/errorCases/warning-test-shift.js:13:37)\\n at next (<cwd>packages/rspack-lite-tapable/dist/index.js:529:25)\\n at AsyncSeriesHook.callAsyncStageRange (<cwd>packages/rspack-lite-tapable/dist/index.js:549:9)\\n at AsyncSeriesHook.callAsync (<cwd>packages/rspack-lite-tapable/dist/index.js:88:21)\\n at <cwd>packages/rspack/dist/Compiler.js:459:41\\n at <cwd>packages/rspack/dist/Compiler.js:526:23",
},
],
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
Object {
"message": " ⚠ Error: test splice\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n",
"moduleTrace": Array [],
"stack": "Error: test splice\\n at Object.fn (<cwd>packages/rspack-test-tools/tests/errorCases/warning-test-splice-1.js:10:41)\\n at next (<cwd>packages/rspack-lite-tapable/dist/index.js:529:25)\\n at AsyncSeriesHook.callAsyncStageRange (<cwd>packages/rspack-lite-tapable/dist/index.js:549:9)\\n at AsyncSeriesHook.callAsync (<cwd>packages/rspack-lite-tapable/dist/index.js:88:21)\\n at <cwd>packages/rspack/dist/Compiler.js:458:41\\n at <cwd>packages/rspack/dist/Compiler.js:525:23",
"stack": "Error: test splice\\n at Object.fn (<cwd>packages/rspack-test-tools/tests/errorCases/warning-test-splice-1.js:10:41)\\n at next (<cwd>packages/rspack-lite-tapable/dist/index.js:529:25)\\n at AsyncSeriesHook.callAsyncStageRange (<cwd>packages/rspack-lite-tapable/dist/index.js:549:9)\\n at AsyncSeriesHook.callAsync (<cwd>packages/rspack-lite-tapable/dist/index.js:88:21)\\n at <cwd>packages/rspack/dist/Compiler.js:459:41\\n at <cwd>packages/rspack/dist/Compiler.js:526:23",
},
],
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
Object {
"message": " ⚠ Error: test splice\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n",
"moduleTrace": Array [],
"stack": "Error: test splice\\n at Object.fn (<cwd>packages/rspack-test-tools/tests/errorCases/warning-test-splice-2.js:10:41)\\n at next (<cwd>packages/rspack-lite-tapable/dist/index.js:529:25)\\n at AsyncSeriesHook.callAsyncStageRange (<cwd>packages/rspack-lite-tapable/dist/index.js:549:9)\\n at AsyncSeriesHook.callAsync (<cwd>packages/rspack-lite-tapable/dist/index.js:88:21)\\n at <cwd>packages/rspack/dist/Compiler.js:458:41\\n at <cwd>packages/rspack/dist/Compiler.js:525:23",
"stack": "Error: test splice\\n at Object.fn (<cwd>packages/rspack-test-tools/tests/errorCases/warning-test-splice-2.js:10:41)\\n at next (<cwd>packages/rspack-lite-tapable/dist/index.js:529:25)\\n at AsyncSeriesHook.callAsyncStageRange (<cwd>packages/rspack-lite-tapable/dist/index.js:549:9)\\n at AsyncSeriesHook.callAsync (<cwd>packages/rspack-lite-tapable/dist/index.js:88:21)\\n at <cwd>packages/rspack/dist/Compiler.js:459:41\\n at <cwd>packages/rspack/dist/Compiler.js:526:23",
},
Object {
"message": " ⚠ Module parse warning:\\n ╰─▶ ⚠ Unsupported feature: require.main.require() is not supported by Rspack.\\n ╭────\\n 1 │ require.main.require('./file');\\n · ──────────────────────────────\\n ╰────\\n \\n",
Expand Down
2 changes: 2 additions & 0 deletions packages/rspack/etc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,8 @@ export class Compiler {
// (undocumented)
root: Compiler;
// (undocumented)
rspack: typeof rspack;
// (undocumented)
run(callback: liteTapable.Callback<Error, Stats>): void;
// (undocumented)
runAsChild(callback: (err?: null | Error, entries?: Chunk[], compilation?: Compilation) => any): void;
Expand Down
2 changes: 2 additions & 0 deletions packages/rspack/src/Compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class Compiler {
};

webpack: typeof rspack;
rspack: typeof rspack;
name?: string;
parentCompilation?: Compilation;
root: Compiler;
Expand Down Expand Up @@ -210,6 +211,7 @@ class Compiler {
};

this.webpack = rspack;
this.rspack = rspack;
this.root = this;
this.outputPath = "";

Expand Down

2 comments on commit 4471e41

@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-08-05 b616f98) Current Change
10000_development-mode + exec 2.32 s ± 33 ms 2.32 s ± 26 ms +0.06 %
10000_development-mode_hmr + exec 703 ms ± 9.4 ms 706 ms ± 5 ms +0.39 %
10000_production-mode + exec 2.86 s ± 27 ms 2.85 s ± 20 ms -0.16 %
arco-pro_development-mode + exec 1.91 s ± 71 ms 1.88 s ± 78 ms -1.72 %
arco-pro_development-mode_hmr + exec 433 ms ± 3.7 ms 433 ms ± 3.9 ms -0.00 %
arco-pro_production-mode + exec 3.46 s ± 69 ms 3.43 s ± 95 ms -0.91 %
threejs_development-mode_10x + exec 1.7 s ± 20 ms 1.7 s ± 14 ms -0.12 %
threejs_development-mode_10x_hmr + exec 811 ms ± 8.4 ms 811 ms ± 9.4 ms +0.01 %
threejs_production-mode_10x + exec 5.52 s ± 28 ms 5.52 s ± 33 ms +0.07 %

@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 ✅ success
_selftest ✅ success
nx ❌ failure
rspress ✅ success
rsbuild ✅ success
examples ✅ success

Please sign in to comment.