Rollup 错误解决

2,614 阅读1分钟

1 问题 (!) Entry module "src/main.js" is implicitly using "default" export mode, which means for CommonJS output that its default export is assigned to "module.exports". For many tools, such CommonJS output will not be interchangeable with the original ES module. If this is intended, explicitly set "output.exports" to either "auto" or "default", otherwise you might want to consider changing the signature of "src/main.js" to use named exports only.

2 解决

import babel from "@rollup/plugin-babel";
export default {
  input: "src/main.js",
  output: [
    {
      file: "lib/index.cjs.js",
      format: "cjs",
      exports: "auto",
    },
    {
      file: "lib/index.ems.js",
      format: "esm",
      exports: "auto",
    },
  ],
  plugins: [babel({ babelHelpers: "bundled" })],
};