goto-bus-stop / minify-stream Goto Github PK
View Code? Open in Web Editor NEWminify javascript in a stream using uglify-js (ES5) or terser (ES6+)
License: MIT License
minify javascript in a stream using uglify-js (ES5) or terser (ES6+)
License: MIT License
xtend can easily be replaced with Object.assign
This reduce the dependencies and possible also avoid duplicated versions where some package don't use the same version range for the xtend package
// immutable
Object.assign({}, a, b)
// mutable
Object.assign(a, b)
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)
There has been development on a new fork of uglify-es, which is now called terser and has its own package!
"terser": "^3.7.3"
Please upgrade to our new version.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.