Skip to content

Commit 4e9fce2

Browse files
authored
perf(build): enable unsafe fast drop in non-watch mode (#6404)
1 parent 792e4fa commit 4e9fce2

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

packages/core/src/cli/commands.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ export function setupCommands(): void {
123123
)
124124
.action(async (options: BuildOptions) => {
125125
try {
126+
if (!options.watch) {
127+
process.env.RSPACK_UNSAFE_FAST_DROP = 'true';
128+
}
129+
126130
const rsbuild = await init({
127131
cliOptions: options,
128132
isBuildWatch: options.watch,

packages/core/src/env.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,12 @@ declare global {
1111
const RSBUILD_WEB_SOCKET_TOKEN: string;
1212
const Deno: unknown;
1313
}
14+
15+
declare namespace NodeJS {
16+
interface ProcessEnv {
17+
/**
18+
* @experimental
19+
*/
20+
RSPACK_UNSAFE_FAST_DROP?: string;
21+
}
22+
}

packages/core/src/provider/createCompiler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ export async function createCompiler(options: InitConfigsOptions): Promise<{
105105
? rspack(rspackConfigs)
106106
: rspack(rspackConfigs[0]);
107107

108+
// Enable unsafe fast drop in non-watch mode to improve performance
109+
if (process.env.RSPACK_UNSAFE_FAST_DROP === 'true') {
110+
compiler.unsafeFastDrop = true;
111+
}
112+
108113
let isVersionLogged = false;
109114
let isCompiling = false;
110115

0 commit comments

Comments
 (0)