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

Terser version does not support optional chaining ?. #21

Open
jonathanvanschenck opened this issue Oct 26, 2023 · 0 comments
Open

Terser version does not support optional chaining ?. #21

jonathanvanschenck opened this issue Oct 26, 2023 · 0 comments

Comments

@jonathanvanschenck
Copy link

The current version (2.1.0) calls for terser^4.7.0, which on my machine gets resolved to terser@4.8.1. This version of terser does not support the modern js optional chaining ?., thinking it is a syntax error. Here's a minimal example:

const minifyStream = require("minify-stream")();
minifyStream.on("data",console.log);
minifyStream.write(`console.log({a:1}?.b);`);
minifyStream.end();
/**
      throw er; // Unhandled 'error' event
      ^

te [SyntaxError]: Unexpected token: punc (.)
 */

I see that the news commit calls out terser@5.4.1, however the optional chaining is also broken in that version too. However, terser@5.22.0 (newest as of post), does support. So providing the newest version of terser:

const minifyStream = require("minify-stream")({ uglify:require("terser") });
minifyStream.on("data",(d) => console.log(d.toString()));
minifyStream.write(`console.log({a:1}?.b);`);
minifyStream.end();
/**
inline source map not found
console.log({a:1}?.b);
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJjb25zb2xlIiwibG9nIiwiYSIsImIiXSwic291cmNlcyI6WyIwIl0sIm1hcHBpbmdzIjoiQUFBQUEsUUFBUUMsSUFBSSxDQUFDQyxFQUFFLElBQUlDIn0=
 */

Doesn't throw the error, but does seem to have an issue with the source maps.

Can we bump the version of terser?

(See this issue for background)

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

No branches or pull requests

1 participant