father icon indicating copy to clipboard operation
father copied to clipboard

add @rollup/plugin-commonjs to esm & cjs

Open helloyou2012 opened this issue 4 years ago • 3 comments

当导出为 esm 或 cjs 时,如果依赖的库里有 commonjs 模块会报错,如很多库都依赖 @babel/runtime 而里面很多都是 commonjs 的,报错如下:

Error: 'default' is not exported by node_modules/@babel/runtime/helpers/defineProperty.js, imported by ...

helloyou2012 avatar Aug 25 '21 05:08 helloyou2012

esm 和 cjs 有依赖安装时机,应该优先对依赖做 external 处理?refer: https://github.com/umijs/father#%E5%85%B3%E4%BA%8E-dependenciespeerdependencies-%E5%92%8C-external

PeachScript avatar Aug 25 '21 07:08 PeachScript

esm 和 cjs 有依赖安装时机,应该优先对依赖做 external 处理?refer: https://github.com/umijs/father#%E5%85%B3%E4%BA%8E-dependenciespeerdependencies-%E5%92%8C-external

但如果想把依赖一同打包进来就不行了。

helloyou2012 avatar Aug 25 '21 12:08 helloyou2012

error Error: 'default' is not exported by ../../node_modules/@babel/runtime/helpers/typeof.js, imported by ../../node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js 我也出现了这个问题,想问一下.fatherrc里如何配置@rollup/plugin-commonjs 插件

sds1037681793 avatar Sep 01 '21 07:09 sds1037681793

感谢贡献,father 4 已发布,旧版本不再迭代,PR closed

PeachScript avatar Aug 31 '22 11:08 PeachScript