我使用webpack2来构建我的网站,我希望能够从tree-shaking中受益,而这只对es2015模块有效。
因此,我想要像Rollup插件(https://github.com/rollup/rollup-plugin-commonjs)一样,寻求Babel插件中将CommonJS转换为ES2015的方法。
我使用webpack2来构建我的网站,我希望能够从tree-shaking中受益,而这只对es2015模块有效。
因此,我想要像Rollup插件(https://github.com/rollup/rollup-plugin-commonjs)一样,寻求Babel插件中将CommonJS转换为ES2015的方法。
其中一个插件是babel-plugin-transform-commonjs-es2015-modules。 可以通过运行以下命令进行安装:
npm install babel-plugin-transform-commonjs-es2015-modules
'plugins':['transform-commonjs-es2015-modules']
。