@@ -39,6 +39,12 @@ const cliCoreAliases = Object.entries(cliCorePkg.exports as Record<string, unkno
3939// The commonjs plugin bundles both. Alias to the node entry directly.
4040const debugNodeEntry = require . resolve ( 'debug/src/node.js' )
4141
42+ // rxjs ships ESM under dist/esm but its exports map gates that behind the
43+ // non-standard `es2015` condition — the `node` condition wins and resolves to
44+ // CJS (`dist/cjs/`). Alias rxjs to its ESM source so Rollup can tree-shake it.
45+ const rxjsDir = path . dirname ( require . resolve ( 'rxjs/package.json' ) )
46+ const rxjsEsmDir = path . join ( rxjsDir , 'dist' , 'esm' )
47+
4248export default defineConfig ( {
4349 // Catch both `node:fs` and bare `fs` (CJS deps may use unprefixed builtins)
4450 external : ( id ) => id . startsWith ( 'node:' ) || builtinModules . includes ( id ) ,
@@ -69,6 +75,11 @@ export default defineConfig({
6975 // debug's index.js bundles both browser and node via conditional require.
7076 // Alias to node entry directly since this is a Node CLI tool.
7177 { find : 'debug' , replacement : debugNodeEntry } ,
78+ // Alias rxjs to its ESM build so Rollup can tree-shake it properly.
79+ // Without this, the `node` export condition resolves to CJS.
80+ { find : / ^ r x j s $ / , replacement : path . join ( rxjsEsmDir , 'index.js' ) } ,
81+ { find : / ^ r x j s \/ o p e r a t o r s $ / , replacement : path . join ( rxjsEsmDir , 'operators' , 'index.js' ) } ,
82+ { find : / ^ r x j s \/ i n t e r n a l \/ ( .* ) / , replacement : path . join ( rxjsEsmDir , 'internal' , '$1' ) } ,
7283 ] ,
7384 } ) ,
7485 nodeResolve ( {
0 commit comments