minify-stream
minify-stream copied to clipboard
Terser version does not support optional chaining `?.`
The current version (2.1.0) calls for terser^4.7.0, which on my machine gets resolved to [email protected]. 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 [email protected], however the optional chaining is also broken in that version too. However, [email protected] (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)