vite-plugin / vite-plugin-commonjs

A pure JavaScript implementation for CommonJs
MIT License
96 stars 14 forks source link

[vite] RollupError: Duplicate export 'default' #46

Open tangerball opened 5 months ago

tangerball commented 5 months ago
const test = [
    { test: 123, add: 123 },
    { test: 123, add: 123 },
    { test: 123, add: 123 },
    { test: 123, add: 123 },
  ]

  test.forEach((module, index) => {
    console.log('🚀 ~ test.forEach ~ module:', module)
    if (index == 1) {
      module.test = 123
    }
  })

The above code example will have a packaging exception

Abnormal information: ERROR Duplicate export 'default' (Note that you need plugins to import files that are not JavaScript) 11:31:29
204: const CJSexport_default = (module.exports == null ? {} : module.exports).default || module.exports; 205: export { 206: CJS__export_default__ as default, ^ 207: } 208: / [vite-plugin-commonjs] export-statement-E /

alphashr commented 4 months ago

Were you able to find a workaround for this issue?

yejimeiming commented 3 months ago

Can you provide a minimal reproduction repo?