TS 中如何 有效的使用 webpack 的tree-shaking

TS 中 使用 import {A} from 'component';
webpack4 在 mode = production 情况下 也不会 使用 tree-shaking,会导致 打包整个 component 的代码,

只能写成 import A from 'component/A' 的方式;

tsconfig.json 中已经写成 了


{
    "compilerOptions": {
        "target": "es6",
        "module": "esnext",
        "moduleResolution": "node",
        "allowSyntheticDefaultImports": true,
        "sourceMap": true,
        "removeComments": false,
        ...
        }
}
阅读 1.7k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题