plugins icon indicating copy to clipboard operation
plugins copied to clipboard

[plugin-terser] Minified UMD with default terser options cannot be consumed from ES6

Open springcomp opened this issue 2 years ago • 0 comments

  • Rollup Plugin Name: @rollup/plugin-terser
  • Rollup Plugin Version: ^0.4.4
  • Rollup Version: 2.79.1
  • Operating System (or Browser): Linux
  • Node Version: 18.18.0
  • Link to reproduction : StackBlitz repro.

Expected Behavior

Run the following command:

npm run build
npm run exec:dev

This generates a dist/sayHi.umd.min.js minified UMD module that is consumed as a CommonJS module from apps/dev/main.js using the require() instruction.

This produces the following output:

[Function (anonymous)]
Hello, John!
Good bye, John!

I would expect the same output when consuming the module as a ECMAScript module using the import instruction.

Actual Behavior

Run the following command:

npm run build
npm run exec:build

This generates a dist/sayHi.umd.min.js minified UMD module that is consumed as an ECMAScript module from apps/build/main.js using the import instruction.

This produces the following output:

file:///home/projects/rollup-repro-id5i6z/apps/build/main.js:5
import { sayGoodbye, sayHi } from '../../dist/sayHi.umd.min.js';
         ^^^^^^^^^^
SyntaxError: The requested module '../../dist/sayHi.umd.min.js' does not provide an export named 'sayGoodbye'
    at ModuleJob._instantiate (https://rollupreproid5i6z-kjjj-8fvnx673.w-corp.staticblitz.com/blitz.a9c8a5a3.js:181:1509)
    at async ModuleJob.run (https://rollupreproid5i6z-kjjj-8fvnx673.w-corp.staticblitz.com/blitz.a9c8a5a3.js:181:2327)

Additional Information

springcomp avatar Feb 08 '24 11:02 springcomp