stealjs / steal-tools

Build easy. Load fast.
https://stealjs.com/docs/steal-tools.html
MIT License
67 stars 23 forks source link

named import fails with treeshaking #1077

Open pYr0x opened 5 years ago

pYr0x commented 5 years ago

see this test repo. https://github.com/pYr0x/import-bug

i have two files, both imported from "d3-axis". the first one imported {axisLeft, axisBottom} and the second one imported {axisLeft, axisTop}.

you see that axisBottom and axisTop is different. Using the build script

npm run build` with treeshaking throw an error `(node:3700) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: 'axisBottom' is not exported by d3-axis@1.0.12#src/index
(node:3700) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

but d3-axis really exports axisBottom

export {
  axisTop,
  axisRight,
  axisBottom,
  axisLeft
} from "./axis";

but without treeshaking, the build is successfully.

matthewp commented 5 years ago

Looked into this. Not totally sure what is going on. We use a slightly old version (maybe a few months) of rollup for tree-shaking, I wonder if there was a bug in that old version. I'd be interested to see what happens in their latest version. Could just be a matter of upgrading.

Longer term I'd like to get rid of the rollup dependency since it doesn't fit super well with what steal-tools does (it moves dependencies around, for example) and since steal does tree-shaking on its own I'd rather just improve that rather than maintain 2 separate tree-shaking sources of bugs.