Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[@rollup/plugin-commonjs] treeshake disabling breaks asterisk imports #1849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
twawszczak opened this issue Feb 26, 2025 · 1 comment
Closed

Comments

@twawszczak
Copy link

twawszczak commented Feb 26, 2025

There's an extremely simple commonjs module:

module.exports.foo = 'bar'

and a simple main.js file (please not asterisk import)

import * as module from './module.cjs';

console.log('foo' in module)

Expected Behavior

For a typical node js execution it prints true:

❯ npm run exec:dev

> [email protected] exec:dev
> node src/main.js

true

Actual Behavior

For the build's execution it returns false

❯ npm run exec:build

> [email protected] exec:build
> node dist/main.js

false

Additional Information

If I change the rollup build treeshake option to true (default value), then it works as expected.

 treeshake: false

If I change the asterisk import to a default import, it works as expected.

import module from './module.cjs';
@twawszczak twawszczak changed the title [@rollup/plugin-commonjs] treeshake disablement breaks asterisk imports [@rollup/plugin-commonjs] treeshake elimination breaks asterisk imports Feb 26, 2025
@twawszczak twawszczak changed the title [@rollup/plugin-commonjs] treeshake elimination breaks asterisk imports [@rollup/plugin-commonjs] treeshake disabling breaks asterisk imports Feb 26, 2025
@stale stale bot added the x⁷ ⋅ stale label Apr 27, 2025
Copy link

stale bot commented May 1, 2025

Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it.

@stale stale bot closed this as completed May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant