Skip to content

[Feature][Treeshaking]: re-assignment breaks treeshaking #9727

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

Open
SoonIter opened this issue Mar 18, 2025 · 2 comments
Open

[Feature][Treeshaking]: re-assignment breaks treeshaking #9727

SoonIter opened this issue Mar 18, 2025 · 2 comments
Assignees
Labels
team The issue/pr is created by the member of Rspack.

Comments

@SoonIter
Copy link
Member

SoonIter commented Mar 18, 2025

Details

{
  "sideEffects": ["a.mjs"]
}

1. without re-assignment

// ./src/barrel.mjs
import { a } from './a.mjs';
import { b } from './b.mjs';

// a is unused
export { a, b };

output:

;// CONCATENATED MODULE: ./src/b.mjs
const b = 2;

console.log(b)

2. with re-assignment

// ./src/barrel.mjs
import { a } from './a.mjs';
import { b } from './b.mjs';
// a is unused
const __webpack_exports__a__ = a;
const __webpack_exports__b__ = b;

export { __webpack_exports__a__ as a , __webpack_exports__b__ as b };

output:

;// CONCATENATED MODULE: ./src/a.mjs
const a_a = 2;
window.a = a_a;

;// CONCATENATED MODULE: ./src/b.mjs
const b = 2;

console.log(b)

Reproduction

see https://github.com/SoonIter/rspack-reassign-treeshaking-issue

which is a minimal production of https://github.com/SoonIter/rslib-css-modules-treeshaking

@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Mar 18, 2025
@JSerFeng JSerFeng self-assigned this Apr 7, 2025
@zachgrayio
Copy link

I see this is assigned, is there an ETA on when this will land?

@JSerFeng
Copy link
Contributor

The const inline feature is on the way #10451

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

No branches or pull requests

3 participants