Building a tree shaking package using rollup
1 分钟阅读#9
rollup-esm-template
Building a tree shaking package using rollup.
Requirements
- Set a
slideEffect: falseflag inpackage.json
"sideEffects": false,- Make all export to input
- Setting output to
esm
export default {
input: ["src/*.ts"],
output: {
dir: pkg.module,
format: "esm",
},
plugins: [commonjs(), typescript(), resolve(), multiInput()],
};- Build it!
Usage
import { foo } from "@chen86860/rollup-esm-template";
foo();For that, the bar function in @chen86860/rollup-esm-template will not build into bundle by tree shaking.
Related repository: rollup-esm-template
这篇文章写在 GitHub Issue 里。
在 GitHub 上参与讨论 ↗