Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
pvdlg opened this issue Aug 31, 2018 · 5 comments · May be fixed by jsGiven/jsGiven#521
Closed

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

pvdlg opened this issue Aug 31, 2018 · 5 comments · May be fixed by jsGiven/jsGiven#521

Comments

@pvdlg
Copy link

pvdlg commented Aug 31, 2018

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
Copy link
Owner

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

@pvdlg
Copy link
Author

pvdlg commented Aug 31, 2018

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
Copy link

xt0rted commented Sep 9, 2018

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
Copy link
Owner

TrySound commented Sep 9, 2018

Gonna fix after next rollup release with new lifecycle hooks

@TrySound
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants