Skip to content
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

Treeshake dynamic import of modules #5410

Open
jakearchibald opened this issue Mar 1, 2024 · 0 comments
Open

Treeshake dynamic import of modules #5410

jakearchibald opened this issue Mar 1, 2024 · 0 comments
Assignees

Comments

@jakearchibald
Copy link
Contributor

Feature Use Case

Rollup now treeshakes dynamically imported modules in a lot of cases, which is brilliant, but there are a couple of important cases where it de-opts:

maths.js

export const square = x => x * x;
export const double = x => x * 2;

These cases will not treeshake:

const module = await import('./maths.js');
module.square(4);

Demo

const square = await import('./maths.js').then((m) => m.square);
square(4);

Demo

This is unexpected, because the static equivalent treeshakes.

Feature Proposal

Treeshake pls 😄

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

2 participants