From 013e0530c5ecf79c7f33f09749c39eb0091ac9ff Mon Sep 17 00:00:00 2001 From: Boshen <1430279+Boshen@users.noreply.github.com> Date: Tue, 30 Sep 2025 15:58:31 +0000 Subject: [PATCH] fix(napi/transform): fix define plugin not applying DCE correctly (#14264) DCE options was using "smallest", hence `debugger` was removed. fixes 14260 --- crates/oxc/src/compiler.rs | 2 +- napi/transform/test/transform.test.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/oxc/src/compiler.rs b/crates/oxc/src/compiler.rs index 2d45c68666c23..72b0dce487c5a 100644 --- a/crates/oxc/src/compiler.rs +++ b/crates/oxc/src/compiler.rs @@ -198,7 +198,7 @@ pub trait CompilerInterface { Compressor::new(&allocator).dead_code_elimination_with_scoping( &mut program, scoping, - CompressOptions::smallest(), + CompressOptions::dce(), ); } } diff --git a/napi/transform/test/transform.test.ts b/napi/transform/test/transform.test.ts index 8dfd636800b4c..00b07aee9a226 100644 --- a/napi/transform/test/transform.test.ts +++ b/napi/transform/test/transform.test.ts @@ -290,6 +290,16 @@ describe('define plugin', () => { // Replaced `undefined` with `void 0` by DCE. expect(ret.code).toEqual('new (void 0)();\n'); }); + + it('keeps debugger', () => { + const code = 'Foo; debugger;'; + const ret = transform('test.js', code, { + define: { + Foo: 'Bar', + }, + }); + expect(ret.code).toEqual('Bar;\ndebugger;\n'); + }); }); describe('inject plugin', () => {