GithubHelp home page GithubHelp logo

goto-bus-stop / minify-stream Goto Github PK

View Code? Open in Web Editor NEW
26.0 2.0 13.0 32 KB

minify javascript in a stream using uglify-js (ES5) or terser (ES6+)

License: MIT License

JavaScript 100.00%
minify stream javascript uglify terser

minify-stream's People

Contributors

dependabot-preview[bot] avatar goto-bus-stop avatar toddself avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

minify-stream's Issues

Use native Object.assign instead of xtend

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)

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.