TrySound / rollup-plugin-uglify

Rollup plugin to minify generated bundle
MIT License
260 stars 42 forks source link

Using the plugin for third party libraries #44

Closed endymion00 closed 6 years ago

endymion00 commented 6 years ago

Hi, I'm using the plugin in combination with rollup-plugin-typescript2. In my code I'm referencing lodash.clonedeep as external dependency (so it is not included in the bundle). I get the following error: (uglify plugin) Error: Error transforming bundle with 'uglify' plugin: Unexpected token: name (cloneDeep) Error: Error transforming bundle with 'uglify' plugin: Unexpected token: name (cloneDeep)"

My plugins section in rollup.config.js is:


   plugins: [
      // rollup-plugin-typescript2 config.
        typescript({
            tsconfig: "tsconfig.json",
            verbosity: 3,  // 0 -- Error, 1 -- Warning, 2 -- Info, 3 -- Debug
            cacheRoot: "./.rollup-plugin-typescript2_cache",
            clean: true // Set to true for clean build (wipes out cache on every build).
        }),
        uglify()
    ]

By the way I tried 'rollup-plugin-uglify-es' and does not throw this error.

my tsconfig.json:


{
  "compileOnSave": true,
  "compilerOptions": {
    "outDir": "./build/compiled",
    "module": "ES2015",
    "target": "es5",
    "moduleResolution": "node",
    "lib": ["ES2016", "ES2017"],
    "sourceMap": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "downlevelIteration": true,
    "declaration": true,
    "alwaysStrict": true,
    "strict": true,
    "allowJs": false
  },
  "include": [
    "./src/**/*",
    "./spec/**/*",
    "./test/**/*"
  ],
  "exclude": [
    "node_modules"
  ]
}
TrySound commented 6 years ago

The latest version of this plugin uses uglify-js package which is able to handle only es5. uglify-es is unsupported these days and if you need to minify es6 syntax use rollup-plugin-terser instead.

endymion00 commented 6 years ago

@TrySound ok, thank you very much :)

TrySound commented 6 years ago

I would accept pr with this info in docs.