Add module support for tree shaking
See original GitHub issueAdd support for the "module"
field in package.json so that webpack/rollup can do proper tree shaking. If you use @vx currently with Rollup, you will get an error by default due to the only availability being commonjs that it cannot understand, so you have to add all the exports of each sub-library of @vx explicitly in rollup.config.js:
https://github.com/rollup/rollup-plugin-commonjs#custom-named-exports
The result is that if you import one part of a @vx/shape
, for example, you have to import its entirety.
I believe this can be as simple as building each library twice: Once as it currently is (default es5 transpiling by babel), and a second build into another folder, such as module
, where the modules
flag is turned off for babel in the babelrc:
"presets": [["es2015", { "modules": false }], "react", "stage-0"],
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (4 by maintainers)
Top GitHub Comments
That’s my fault. Will get that fixed. Thanks @knoopx
@techniq i believe it’s now
sideEffects: false
.