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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree-shaking dynamic imports #4318

surma opened this issue Mar 12, 2020 · 2 comments 路 Fixed by #5367

Tree-shaking dynamic imports #4318

surma opened this issue Mar 12, 2020 · 2 comments 路 Fixed by #5367


Copy link

surma commented Mar 12, 2020

馃檵 feature request

I am wondering if it has ever been considered to enable tree-shaking on dynamic imports. As a starter: If (and only if) every import of a module is easily statically analyzable, the same dead code elimination routines as they are used for static imports could be run.

If it is not easily analyzable, Parcel could always fall back to the current behavior. The resulting bundle sizes should remain same size or get smaller!.


const { logCaps } = await import('./utils.js');
export function logCaps(msg) {

export function thisIsNeverCalled(msg) {
  return msg + '!';

Example repo

Copy link

kzc commented Mar 21, 2020

Related discussion: rollup/rollup#3417 (comment)

Copy link

devongovett commented Mar 24, 2020

With pure ESM this should be possible. We'd need to move the analysis of used imports to the bundling phase instead of the packaging phase though. It currently happens here. cc @mischnic I think you were running into something related today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
4 participants