-
-
Notifications
You must be signed in to change notification settings - Fork 764
Open
Description
System Info
System:
OS: macOS 15.5
CPU: (10) arm64 Apple M1 Max
Memory: 2.34 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.4.1 - ~/.volta/tools/image/node/24.4.1/bin/node
pnpm: 10.13.1 - ~/.volta/tools/image/pnpm/10.13.1/bin/pnpm
Watchman: 2025.07.28.00 - /opt/homebrew/bin/watchman
npmPackages:
@rspack/core: ^1.4.10 => 1.4.10
Details
If you have a file foo.ts
that contains 2 exports:
// foo.ts
exports.bar = 'bar';
exports.paz = 'paz';
Tree shaking will work (aka the unused variable will be stripped out during compilation) when writing:
// stripped.ts
import { bar } from './foo';
const bar = require('./foo').bar;
But in some other instances, paz
is kept in the bundle:
// kept.ts
const { bar } = require('./foo');
const module = require('./foo'); // And then only `module.foo` is used
Reproduce link
https://github.com/Ayc0/code-splitting-issue
Reproduce Steps
You can clone https://github.com/Ayc0/code-splitting-issue and run node --test tests/rspack.test.mjs
(requires node 24.4.0+)