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(cli): display the error which is thrown by the plugin during the starting of rspack serve #8244

Merged
merged 2 commits into from
Oct 28, 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
6 changes: 5 additions & 1 deletion packages/rspack-cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ export class RspackCLI {
this.getLogger().error(e.message);
process.exit(2);
} else if (e instanceof Error) {
callback?.(e);
if (typeof callback === "function") {
callback(e);
} else {
this.getLogger().error(e);
}
return null;
}
throw e;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
mode: "development",
devtool: false,
plugins: [
{
name: "test-plugin",
apply(compiler) {
throw new Error("error in plugin");
}
}
],
devServer: {}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { normalizeStderr, runWatch } from "../../utils/test-utils";

describe("should display plugin error", () => {
it("display error", async () => {
const { stderr } = await runWatch(__dirname, ["serve"], {
killString: /Error: /
});

expect(normalizeStderr(stderr)).toContain("error in plugin");
});
});
Loading