Skip to content

Commit

Permalink
feat: deprecate Compilation API
Browse files Browse the repository at this point in the history
  • Loading branch information
h-a-n-a committed May 10, 2024
1 parent 449fcf1 commit 3fdc64b
Show file tree
Hide file tree
Showing 18 changed files with 116 additions and 182 deletions.
2 changes: 0 additions & 2 deletions crates/node_binding/binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ export interface JsStatsChunkGroupAsset {

export interface JsStatsError {
message: string
formatted: string
moduleIdentifier?: string
moduleName?: string
moduleId?: string
Expand Down Expand Up @@ -560,7 +559,6 @@ export interface JsStatsOptimizationBailout {

export interface JsStatsWarning {
message: string
formatted: string
moduleIdentifier?: string
moduleName?: string
moduleId?: string
Expand Down
4 changes: 0 additions & 4 deletions crates/rspack_binding_values/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use super::{JsCompilation, ToJsCompatSource};
#[derive(Debug)]
pub struct JsStatsError {
pub message: String,
pub formatted: String,
pub module_identifier: Option<String>,
pub module_name: Option<String>,
pub module_id: Option<String>,
Expand All @@ -24,7 +23,6 @@ impl From<rspack_core::StatsError> for JsStatsError {
fn from(stats: rspack_core::StatsError) -> Self {
Self {
message: stats.message,
formatted: stats.formatted,
module_identifier: stats.module_identifier,
module_name: stats.module_name,
module_id: stats.module_id,
Expand All @@ -35,7 +33,6 @@ impl From<rspack_core::StatsError> for JsStatsError {
#[napi(object)]
pub struct JsStatsWarning {
pub message: String,
pub formatted: String,
pub module_identifier: Option<String>,
pub module_name: Option<String>,
pub module_id: Option<String>,
Expand All @@ -45,7 +42,6 @@ impl From<rspack_core::StatsWarning> for JsStatsWarning {
fn from(stats: rspack_core::StatsWarning) -> Self {
Self {
message: stats.message,
formatted: stats.formatted,
module_identifier: stats.module_identifier,
module_name: stats.module_name,
module_id: stats.module_id,
Expand Down
8 changes: 0 additions & 8 deletions crates/rspack_core/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,6 @@ impl Stats<'_> {
message: diagnostic_displayer
.emit_diagnostic(d)
.expect("should print diagnostics"),
formatted: diagnostic_displayer
.emit_diagnostic(d)
.expect("should print diagnostics"),
module_identifier: module_identifier.map(|i| i.to_string()),
module_name,
module_id: module_id.flatten(),
Expand Down Expand Up @@ -369,9 +366,6 @@ impl Stats<'_> {
message: diagnostic_displayer
.emit_diagnostic(d)
.expect("should print diagnostics"),
formatted: diagnostic_displayer
.emit_diagnostic(d)
.expect("should print diagnostics"),
module_identifier: module_identifier.map(|i| i.to_string()),
module_name,
module_id: module_id.flatten(),
Expand Down Expand Up @@ -703,7 +697,6 @@ fn get_stats_module_name_and_id(
#[derive(Debug)]
pub struct StatsError {
pub message: String,
pub formatted: String,
pub module_identifier: Option<String>,
pub module_name: Option<String>,
pub module_id: Option<String>,
Expand All @@ -712,7 +705,6 @@ pub struct StatsError {
#[derive(Debug)]
pub struct StatsWarning {
pub message: String,
pub formatted: String,
pub module_identifier: Option<String>,
pub module_name: Option<String>,
pub module_id: Option<String>,
Expand Down
1 change: 0 additions & 1 deletion packages/rspack-test-tools/tests/errorCases/error-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ module.exports = {
expect(errors).toMatchInlineSnapshot(`
Array [
Object {
"formatted": " Γ— Resolve error: Can't resolve './answer' in '<cwd>packages/rspack-test-tools/tests/fixtures/errors/resolve-fail-esm'\\n ╭────\\n 1 β”‚ import { answer } from './answer';\\n Β· ──────────\\n ╰────\\n help: Did you mean './answer.js'?\\n \\n The request './answer' failed to resolve only because it was resolved as fully specified,\\n probably because the origin is strict EcmaScript Module,\\n e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '\\"type\\": \\"module\\"'.\\n \\n The extension in the request is mandatory for it to be fully specified.\\n Add the extension to the request.\\n",
"index": 0,
"message": " Γ— Resolve error: Can't resolve './answer' in '<cwd>packages/rspack-test-tools/tests/fixtures/errors/resolve-fail-esm'\\n ╭────\\n 1 β”‚ import { answer } from './answer';\\n Β· ──────────\\n ╰────\\n help: Did you mean './answer.js'?\\n \\n The request './answer' failed to resolve only because it was resolved as fully specified,\\n probably because the origin is strict EcmaScript Module,\\n e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '\\"type\\": \\"module\\"'.\\n \\n The extension in the request is mandatory for it to be fully specified.\\n Add the extension to the request.\\n",
"moduleId": "./resolve-fail-esm/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ module.exports = {
Object {
"errors": Array [
Object {
"formatted": " Γ— test push\\n",
"message": " Γ— test push\\n",
},
Object {
"formatted": " Γ— Resolve error: Can't resolve './answer' in '<cwd>packages/rspack-test-tools/tests/fixtures/errors/resolve-fail-esm'\\n ╭────\\n 1 β”‚ import { answer } from './answer';\\n Β· ──────────\\n ╰────\\n help: Did you mean './answer.js'?\\n \\n The request './answer' failed to resolve only because it was resolved as fully specified,\\n probably because the origin is strict EcmaScript Module,\\n e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '\\"type\\": \\"module\\"'.\\n \\n The extension in the request is mandatory for it to be fully specified.\\n Add the extension to the request.\\n",
"message": " Γ— Resolve error: Can't resolve './answer' in '<cwd>packages/rspack-test-tools/tests/fixtures/errors/resolve-fail-esm'\\n ╭────\\n 1 β”‚ import { answer } from './answer';\\n Β· ──────────\\n ╰────\\n help: Did you mean './answer.js'?\\n \\n The request './answer' failed to resolve only because it was resolved as fully specified,\\n probably because the origin is strict EcmaScript Module,\\n e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '\\"type\\": \\"module\\"'.\\n \\n The extension in the request is mandatory for it to be fully specified.\\n Add the extension to the request.\\n",
"moduleId": "./resolve-fail-esm/index.js",
"moduleIdentifier": "javascript/esm|<cwd>packages/rspack-test-tools/tests/fixtures/errors/resolve-fail-esm/index.js",
Expand Down
59 changes: 29 additions & 30 deletions packages/rspack-test-tools/tests/errorCases/error-test-shift.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
/** @type {import('../..').TErrorCaseConfig} */
module.exports = {
description: "Testing proxy methods on errors: test shift&unshift",
options() {
return {
entry: "./resolve-fail-esm",
plugins: [
compiler => {
compiler.hooks.afterCompile.tap(
"test shift and unshift",
compilation => {
compilation.errors.shift();
compilation.errors.unshift("test unshift");
}
);
}
]
};
},
async check(diagnostics) {
expect(diagnostics).toMatchInlineSnapshot(`
Object {
"errors": Array [
Object {
"formatted": " Γ— test unshift\\n",
"message": " Γ— test unshift\\n",
},
],
"warnings": Array [],
}
`);
}
description: "Testing proxy methods on errors: test shift&unshift",
options() {
return {
entry: "./resolve-fail-esm",
plugins: [
compiler => {
compiler.hooks.afterCompile.tap(
"test shift and unshift",
compilation => {
compilation.errors.shift();
compilation.errors.unshift("test unshift");
}
);
}
]
};
},
async check(diagnostics) {
expect(diagnostics).toMatchInlineSnapshot(`
Object {
"errors": Array [
Object {
"message": " Γ— test unshift\\n",
},
],
"warnings": Array [],
}
`);
}
};
51 changes: 25 additions & 26 deletions packages/rspack-test-tools/tests/errorCases/error-test-splice-1.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
/** @type {import('../..').TErrorCaseConfig} */
module.exports = {
description: "Testing proxy methods on errors: test splice 1",
options() {
return {
entry: "./resolve-fail-esm",
plugins: [
compiler => {
compiler.hooks.afterCompile.tap("test splice", compilation => {
compilation.errors.splice(0, 1, "test splice");
});
}
]
};
},
async check(diagnostics) {
expect(diagnostics).toMatchInlineSnapshot(`
Object {
"errors": Array [
Object {
"formatted": " Γ— test splice\\n",
"message": " Γ— test splice\\n",
},
],
"warnings": Array [],
}
`);
}
description: "Testing proxy methods on errors: test splice 1",
options() {
return {
entry: "./resolve-fail-esm",
plugins: [
compiler => {
compiler.hooks.afterCompile.tap("test splice", compilation => {
compilation.errors.splice(0, 1, "test splice");
});
}
]
};
},
async check(diagnostics) {
expect(diagnostics).toMatchInlineSnapshot(`
Object {
"errors": Array [
Object {
"message": " Γ— test splice\\n",
},
],
"warnings": Array [],
}
`);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ module.exports = {
Object {
"errors": Array [
Object {
"formatted": " Γ— test splice\\n",
"message": " Γ— test splice\\n",
},
Object {
"formatted": " Γ— Resolve error: Can't resolve './answer' in '<cwd>packages/rspack-test-tools/tests/fixtures/errors/resolve-fail-esm'\\n ╭────\\n 1 β”‚ import { answer } from './answer';\\n Β· ──────────\\n ╰────\\n help: Did you mean './answer.js'?\\n \\n The request './answer' failed to resolve only because it was resolved as fully specified,\\n probably because the origin is strict EcmaScript Module,\\n e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '\\"type\\": \\"module\\"'.\\n \\n The extension in the request is mandatory for it to be fully specified.\\n Add the extension to the request.\\n",
"message": " Γ— Resolve error: Can't resolve './answer' in '<cwd>packages/rspack-test-tools/tests/fixtures/errors/resolve-fail-esm'\\n ╭────\\n 1 β”‚ import { answer } from './answer';\\n Β· ──────────\\n ╰────\\n help: Did you mean './answer.js'?\\n \\n The request './answer' failed to resolve only because it was resolved as fully specified,\\n probably because the origin is strict EcmaScript Module,\\n e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '\\"type\\": \\"module\\"'.\\n \\n The extension in the request is mandatory for it to be fully specified.\\n Add the extension to the request.\\n",
"moduleId": "./resolve-fail-esm/index.js",
"moduleIdentifier": "javascript/esm|<cwd>packages/rspack-test-tools/tests/fixtures/errors/resolve-fail-esm/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module.exports = {
Object {
"errors": Array [
Object {
"formatted": " Γ— Resolve error: Can't resolve './answer' in '<cwd>packages/rspack-test-tools/tests/fixtures/errors/resolve-fail-esm'\\n ╭────\\n 1 β”‚ import { answer } from './answer';\\n Β· ──────────\\n ╰────\\n help: Did you mean './answer.js'?\\n \\n The request './answer' failed to resolve only because it was resolved as fully specified,\\n probably because the origin is strict EcmaScript Module,\\n e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '\\"type\\": \\"module\\"'.\\n \\n The extension in the request is mandatory for it to be fully specified.\\n Add the extension to the request.\\n",
"message": " Γ— Resolve error: Can't resolve './answer' in '<cwd>packages/rspack-test-tools/tests/fixtures/errors/resolve-fail-esm'\\n ╭────\\n 1 β”‚ import { answer } from './answer';\\n Β· ──────────\\n ╰────\\n help: Did you mean './answer.js'?\\n \\n The request './answer' failed to resolve only because it was resolved as fully specified,\\n probably because the origin is strict EcmaScript Module,\\n e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '\\"type\\": \\"module\\"'.\\n \\n The extension in the request is mandatory for it to be fully specified.\\n Add the extension to the request.\\n",
"moduleId": "./resolve-fail-esm/index.js",
"moduleIdentifier": "javascript/esm|<cwd>packages/rspack-test-tools/tests/fixtures/errors/resolve-fail-esm/index.js",
Expand Down
1 change: 0 additions & 1 deletion packages/rspack-test-tools/tests/errorCases/warning-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ module.exports = {
expect(warnings).toMatchInlineSnapshot(`
Array [
Object {
"formatted": " ⚠ Module parse warning:\\n ╰─▢ ⚠ Module parse failed: require.main.require() is not supported by Rspack.\\n ╭────\\n 1 β”‚ require.main.require('./file');\\n Β· ──────────────────────────────\\n ╰────\\n \\n",
"index": 0,
"message": " ⚠ Module parse warning:\\n ╰─▢ ⚠ Module parse failed: require.main.require() is not supported by Rspack.\\n ╭────\\n 1 β”‚ require.main.require('./file');\\n Β· ──────────────────────────────\\n ╰────\\n \\n",
"moduleId": "./require.main.require.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ module.exports = {
"errors": Array [],
"warnings": Array [
Object {
"formatted": " ⚠ Error: test push\\n β”‚ at <cwd>packages/rspack-test-tools/tests/errorCases/warning-test-push.js:10:33\\n β”‚ at Hook.eval [as callAsync] (eval at create (<cwd>node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)\\n β”‚ at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (<cwd>node_modules/tapable/lib/Hook.js:18:14)\\n β”‚ at <cwd>packages/rspack/dist/Compiler.js:466:41\\n β”‚ at <cwd>packages/rspack/dist/Compiler.js:533:65\\n",
"message": " ⚠ Error: test push\\n β”‚ at <cwd>packages/rspack-test-tools/tests/errorCases/warning-test-push.js:10:33\\n β”‚ at Hook.eval [as callAsync] (eval at create (<cwd>node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)\\n β”‚ at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (<cwd>node_modules/tapable/lib/Hook.js:18:14)\\n β”‚ at <cwd>packages/rspack/dist/Compiler.js:466:41\\n β”‚ at <cwd>packages/rspack/dist/Compiler.js:533:65\\n",
},
Object {
"formatted": " ⚠ Module parse warning:\\n ╰─▢ ⚠ Module parse failed: require.main.require() is not supported by Rspack.\\n ╭────\\n 1 β”‚ require.main.require('./file');\\n Β· ──────────────────────────────\\n ╰────\\n \\n",
"message": " ⚠ Module parse warning:\\n ╰─▢ ⚠ Module parse failed: require.main.require() is not supported by Rspack.\\n ╭────\\n 1 β”‚ require.main.require('./file');\\n Β· ──────────────────────────────\\n ╰────\\n \\n",
"moduleId": "./require.main.require.js",
"moduleIdentifier": "<cwd>packages/rspack-test-tools/tests/fixtures/errors/require.main.require.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ module.exports = {
"errors": Array [],
"warnings": Array [
Object {
"formatted": " ⚠ Error: test unshift\\n β”‚ at <cwd>packages/rspack-test-tools/tests/errorCases/warning-test-shift.js:13:37\\n β”‚ at Hook.eval [as callAsync] (eval at create (<cwd>node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)\\n β”‚ at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (<cwd>node_modules/tapable/lib/Hook.js:18:14)\\n β”‚ at <cwd>packages/rspack/dist/Compiler.js:466:41\\n β”‚ at <cwd>packages/rspack/dist/Compiler.js:533:65\\n",
"message": " ⚠ Error: test unshift\\n β”‚ at <cwd>packages/rspack-test-tools/tests/errorCases/warning-test-shift.js:13:37\\n β”‚ at Hook.eval [as callAsync] (eval at create (<cwd>node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)\\n β”‚ at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (<cwd>node_modules/tapable/lib/Hook.js:18:14)\\n β”‚ at <cwd>packages/rspack/dist/Compiler.js:466:41\\n β”‚ at <cwd>packages/rspack/dist/Compiler.js:533:65\\n",
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ module.exports = {
"errors": Array [],
"warnings": Array [
Object {
"formatted": " ⚠ Error: test splice\\n β”‚ at <cwd>packages/rspack-test-tools/tests/errorCases/warning-test-splice-1.js:10:41\\n β”‚ at Hook.eval [as callAsync] (eval at create (<cwd>node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)\\n β”‚ at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (<cwd>node_modules/tapable/lib/Hook.js:18:14)\\n β”‚ at <cwd>packages/rspack/dist/Compiler.js:466:41\\n β”‚ at <cwd>packages/rspack/dist/Compiler.js:533:65\\n",
"message": " ⚠ Error: test splice\\n β”‚ at <cwd>packages/rspack-test-tools/tests/errorCases/warning-test-splice-1.js:10:41\\n β”‚ at Hook.eval [as callAsync] (eval at create (<cwd>node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)\\n β”‚ at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (<cwd>node_modules/tapable/lib/Hook.js:18:14)\\n β”‚ at <cwd>packages/rspack/dist/Compiler.js:466:41\\n β”‚ at <cwd>packages/rspack/dist/Compiler.js:533:65\\n",
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ module.exports = {
"errors": Array [],
"warnings": Array [
Object {
"formatted": " ⚠ Error: test splice\\n β”‚ at <cwd>packages/rspack-test-tools/tests/errorCases/warning-test-splice-2.js:10:41\\n β”‚ at Hook.eval [as callAsync] (eval at create (<cwd>node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)\\n β”‚ at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (<cwd>node_modules/tapable/lib/Hook.js:18:14)\\n β”‚ at <cwd>packages/rspack/dist/Compiler.js:466:41\\n β”‚ at <cwd>packages/rspack/dist/Compiler.js:533:65\\n",
"message": " ⚠ Error: test splice\\n β”‚ at <cwd>packages/rspack-test-tools/tests/errorCases/warning-test-splice-2.js:10:41\\n β”‚ at Hook.eval [as callAsync] (eval at create (<cwd>node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)\\n β”‚ at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (<cwd>node_modules/tapable/lib/Hook.js:18:14)\\n β”‚ at <cwd>packages/rspack/dist/Compiler.js:466:41\\n β”‚ at <cwd>packages/rspack/dist/Compiler.js:533:65\\n",
},
Object {
"formatted": " ⚠ Module parse warning:\\n ╰─▢ ⚠ Module parse failed: require.main.require() is not supported by Rspack.\\n ╭────\\n 1 β”‚ require.main.require('./file');\\n Β· ──────────────────────────────\\n ╰────\\n \\n",
"message": " ⚠ Module parse warning:\\n ╰─▢ ⚠ Module parse failed: require.main.require() is not supported by Rspack.\\n ╭────\\n 1 β”‚ require.main.require('./file');\\n Β· ──────────────────────────────\\n ╰────\\n \\n",
"moduleId": "./require.main.require.js",
"moduleIdentifier": "<cwd>packages/rspack-test-tools/tests/fixtures/errors/require.main.require.js",
Expand Down
Loading

0 comments on commit 3fdc64b

Please sign in to comment.