Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.0k views
in Technique[技术] by (71.8m points)

rollup设置output.exports为none报错

由于是cli工具所以不需要导出,在output.exports设置none时,打包却报错:

[!] Error: "none" was specified for "output.exports", but entry module "packages/cli/lib/index.js" has the following exports: default

意思应该是代码里有导出不能设置为none,后来发现是使用'@rollup/plugin-commonjs'插件导致自动插入一个默认导出在代码结尾出

module.exports={};

但是commonjs插件官网也没有看到怎么关闭这个功能。
请问有什么解决办法?暂时设置exports为default了。

这是配置文件:

export default async () => ({
  input: 'packages/cli/lib/index.js',
  output: {
    file: 'packages/cli/bin/yy.js',
    format: 'cjs',
    banner: '#!/usr/bin/env node',
    exports: 'default'
  },
  plugins: [
    json(),
    commonjs(),
    isProduction && (await import('rollup-plugin-terser')).terser()
  ]
})

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...