Treeshake dynamic import of modules
jakearchibald opened this issue · 0 comments
jakearchibald commented
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);
const square = await import('./maths.js').then((m) => m.square);
square(4);
This is unexpected, because the static equivalent treeshakes.
Feature Proposal
Treeshake pls 😄