TrySound / rollup-plugin-uglify

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

Fails with (uglify plugin) TypeError: regex.test is not a function #51

Closed pvdlg closed 6 years ago

pvdlg commented 6 years ago

When passing an Uglify option that is a regex, Uglify fails with error TypeError: regex.test is not a function as it seems rollup-plugin-uglify somehow transform regexps into strings. It might happen when passing the option object to the jest-worker.

Here is the config to reproduce:

import { rollup } from "rollup";
import { uglify } from "rollup-plugin-uglify";

rollup({
  input: "main.js",
  plugins: [uglify({mangle: {properties: {regex: /^_/}}})]
});
TrySound commented 6 years ago

I get it. Thanks for reporting. Could you use v4 for now?

pvdlg commented 6 years ago

Yes sure, I'll keep using v4 until this is fixed. Not sure what the solution is though. If it's indeed due to the way option are passed through jest-worker, that might create an issue for each property that is not a String (not only the mangle property regex).

xt0rted commented 6 years ago

I just ran into a similar issue. Passing a regex to options.comments causes all comments to be left in the file, and if I try a function it doesn't get called. Downgrading to v4 works as expected. The same issue exists in rollup-plugin-terser@2.

TrySound commented 6 years ago

Gonna fix after next rollup release with new lifecycle hooks

TrySound commented 6 years ago

Fixed in https://github.com/TrySound/rollup-plugin-uglify/releases/tag/v6.0.0