Skip to content
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
2 changes: 1 addition & 1 deletion packages/compat/webpack/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const build = async (
if (err) {
reject(err);
} else if (stats?.hasErrors()) {
reject(new Error('Webpack build failed!'));
reject(new Error('webpack build failed.'));
}
// If there is a compilation error, the close method should not be called.
// Otherwise bundler may generate an invalid cache.
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/cli/commands.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import cac, { type CAC, type Command } from 'cac';
import type { ConfigLoader } from '../config';
import { logger } from '../logger';
import { RSPACK_BUILD_ERROR } from '../provider/build';
import { onBeforeRestartServer } from '../server/restart';
import type { RsbuildMode } from '../types';
import { init } from './init';
Expand Down Expand Up @@ -131,7 +132,12 @@ export function setupCommands(): void {
}
}
} catch (err) {
logger.error('Failed to build.');
const isRspackError =
err instanceof Error && err.message === RSPACK_BUILD_ERROR;
if (!isRspackError) {
logger.error('Failed to build.');
}

logger.error(err);
process.exit(1);
}
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/provider/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import type { Build, BuildOptions, Rspack } from '../types';
import { createCompiler } from './createCompiler';
import type { InitConfigsOptions } from './initConfigs';

export const RSPACK_BUILD_ERROR = 'Rspack build failed.';

export const build = async (
initOptions: InitConfigsOptions,
{ watch, compiler: customCompiler }: BuildOptions = {},
Expand Down Expand Up @@ -54,7 +56,7 @@ export const build = async (
if (err) {
reject(err);
} else if (stats?.hasErrors()) {
reject(new Error('Rspack build failed!'));
reject(new Error(RSPACK_BUILD_ERROR));
}
// If there is a compilation error, the close method should not be called.
// Otherwise the bundler may generate an invalid cache.
Expand Down
Loading