rollup/rollup

Assistance with Rollup export functions & default.

andresclua opened this issue · 0 comments

hey!
I'm working on an NPM package that uses this setup in rollup.config.js

export default {
  input: 'src/js/libraryName.js', 
  output: [
    {
        file: packageJson.main, 
        format: 'cjs',
        sourcemap: true
    },
    {
        file: packageJson.module, 
        format: 'es',
        sourcemap: true
    },
    {
        name: 'libraryName',
        file: 'dist/libraryName-it.umd.js', 
        format: 'umd',
        globals: {
        },
        sourcemap: true
    }
  ],
  plugins: [
    resolve(),
    commonjs(),
    uglify(),
    babel({
      exclude: 'node_modules/**',
      babelHelpers: 'bundled'
    }),
    terser() 
  ]
};

If I only export export default libraryName; the UMD works ok.
export default libraryName // -> works fine

However If I do this. it does not, any thing that I'm missing inside something?

export default libraryName;
export {somefunction} ;

this message from rollup.

The entry module "src/js/libraryName.js" is by default utilizing the "default" export mode. In the context of CommonJS output, this configuration results in the module's default export being allocated to "module.exports". This approach to CommonJS output may not be fully compatible with the ES module format as originally designed. To address this, if the current behavior aligns with your intentions, it is recommended to explicitly configure "output.exports" in your setup to either "auto" or "default". Alternatively, if ensuring compatibility or following best practices is a priority, you might want to modify the export structure of "src/js/libraryName.js" to exclusively utilize named exports.