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

refactor: align configCases runner #5620

Merged
merged 1 commit into from
Feb 22, 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
1 change: 1 addition & 0 deletions packages/rspack/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const config = {
testMatch: [
"<rootDir>/tests/*.test.ts",
"<rootDir>/tests/*.basictest.ts",
"<rootDir>/tests/*.basictest.js",
"<rootDir>/tests/*.longtest.ts",
"<rootDir>/tests/*.unittest.ts",
"<rootDir>/tests/copyPlugin/*.test.js",
Expand Down
20 changes: 13 additions & 7 deletions packages/rspack/src/rspack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,17 @@ function rspack(
options: MultiRspackOptions | RspackOptions,
callback?: Callback<Error, MultiStats> | Callback<Error, Stats>
) {
asArray(options).every(opts => {
validate(opts, rspackOptions);
});
try {
for (let o of asArray(options)) {
validate(o, rspackOptions);
}
} catch (e) {
if (e instanceof Error) {
callback?.(e);
return;
}
throw e;
}
const create = () => {
if (isMultiRspackOptions(options)) {
const compiler = createMultiCompiler(options);
Expand Down Expand Up @@ -139,10 +147,8 @@ function rspack(
} else {
const { compiler, watch } = create();
if (watch) {
util.deprecate(
() => {},
"A 'callback' argument needs to be provided to the 'rspack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback."
)();
util.deprecate(() => {},
"A 'callback' argument needs to be provided to the 'rspack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.")();
}
return compiler;
}
Expand Down
Loading
Loading