News for hackers. Stuff that matters.
Re:Babili: An ES6+ aware minifier based on Babel by yladiz on Tuesday August 30, 2016 @04:50PM (#12393785)
It may just be a paranoid delusion, but I'm worried that Babel is trying to become a more encompassing build tool ala Grunt/Gulp instead of just transpiling. I love Babel and plan to continue to use it in the future for my front-end development, but the "doing it all ourselves" is a little bit much.

I would much rather see a recommendation and efforts around Uglify than a brand new minimization tool, and I would rather see work on acorn[1] rather than around a new parser[2], because these things fragment the community rather than bring them together.

Edit: Yes, Uglify has taken a long time to get work done on ES2015, but note that the spec has changed a lot over that time. It does feel like they are dragging their feet or not getting much done in that front, but all the more reason to put one of the Babel devs who may have more free time on the project to get more things going.

1: https://github.com/marijnh/acorn

2: https://github.com/babel/babylon

Re:Babili: An ES6+ aware minifier based on Babel by amasad on Tuesday August 30, 2016 @10:33PM (#12395576)
We're not losing focus. Babel is as focused as ever on being a general purpose parser, transformer, and code generator. Babili is a set of Babel transforms.

Uglify has its own parser and transformer and generator, so arguably any work that goes into that is duplicate work because Babel already covers most of what it does.

Re parsers: we had to fork acorn because they were understandably skeptical of adding all the experimental and non-standard features (JSX and flow types) that Babel supports.

I started this project at Facebook and one of our aims (which is mentioned in the post) was to have access to the original source AST which may include Flow type annotations, JSX and early ES proposal features. Have I spent the time trying to get those into uglify, the majority of the work would've went into parsing and code generation. And I would imagine an uphill battle with the maintainers convincing them of adding non-standard features.

Re:Babili: An ES6+ aware minifier based on Babel by yladiz on Tuesday August 30, 2016 @10:58PM (#12395691)
> Uglify has its own parser and transformer and generator, so arguably any work that goes into that is duplicate work because Babel already covers most of what it does.

That seems a little hubristic... Not everyone uses Babel, and working with the Uglify devs to get it ES2015+ compliant (through whatever means, including adding a different AST parser) would make the entire community better, not just Babel. Since not all browsers support ES2015, I have to use babel, but if I didn't need to use Babel, I wouldn't. But now I'm kind of forced to for uglification now until ES2015 support comes to Uglify.

> Re parsers: we had to fork acorn because they were understandably skeptical of adding all the experimental and non-standard features (JSX and flow types) that Babel supports.

JSX and Flow are not part of ES spec. I can understand those being in a different parser, but that's a flimsy argument for creating a whole new parser. If you had to create a brand new parser to handle this, it seems like a Babel issue, not a parser issue.

Re:Babili: An ES6+ aware minifier based on Babel by amasad on Tuesday August 30, 2016 @11:15PM (#12395759)
>That seems a little hubristic... Not everyone uses Babel, and working with the Uglify devs to get it ES2015+ compliant (through whatever means, including adding a different AST parser) would make the entire community better, not just Babel. Since not all browsers support ES2015, I have to use babel, but if I didn't need to use Babel, I wouldn't. But now I'm kind of forced to for uglification now until ES2015 support comes to Uglify.

Again, this project started at Facebook and we were scratching our own itch (and the React/Babel community's itch). So our target audience is already people using Babel.

You're committing the fallacy of thinking about this as an opportunity cost. But the upside for us in modernizing uglify while Babel exists is so little to make it worth it.

>but that's a flimsy argument for creating a whole new parser. If you had to create a brand new parser to handle this, it seems like a Babel issue, not a parser issue.

I'm going to go ahead and assume that you never worked on a parser before. Pluggable parsers is a really hard problem. And none of the existing parsers have support for it. At facebook we supported an esprima fork for years because they wouldn't accept our JSX/Flow patches. If I'm wrong then put your code where your mouth is and benefit the community by creating the first ever generalized pluggable parser.

Re:Babili: An ES6+ aware minifier based on Babel by mstade on Wednesday August 31, 2016 @09:37AM (#12398167)
Not sure why you're being down voted, your comment is fine I think.

What's worse than having specific parsers, transformers, and generators – I think – is not having an AST standard. If there was a common standard for ES ASTs, including extension points, then it becomes a lot easier to write tools that aren't specific to a tool chain but specific to a data structure. I could use the Babylon parser, but do transforms with Rollup and optimizations with Uglify (obviously provided those tools had APIs that take/return ASTs.)

As it stands, there's a varying degree of lock-in when using these tools, making them more difficult to compose. That's a shame I think.

Re:Babili: An ES6+ aware minifier based on Babel by yladiz on Wednesday August 31, 2016 @04:41PM (#12401308)
You're right -- it would be nice to have a standard AST for ES, which is what you have in languages like Python, so that tools can be built around it more easily and without lock-in. This would also help accomplish my idea of helping the community rather than one tech specifically. I saw some other comment that mentioned ESTree but I guess that didn't go anywhere... sucks.
Re:Babili: An ES6+ aware minifier based on Babel by hzoo on Wednesday August 31, 2016 @12:02AM (#12395939)
It's not a whole/brand new parser though. It's mostly acorn + JSX/Flow/everything experimental that wouldn't be in acorn anyway (until stage 4) for Babel.
Re:Babili: An ES6+ aware minifier based on Babel by sotojuan on Tuesday August 30, 2016 @05:22PM (#12394027)
Uglify has had many years to at least attempt to minify ES2015+. They just haven't—it's still an "experimental" branch in their repo: https://github.com/mishoo/UglifyJS2/issues/448

I agree with your comment, but at some point, devs will get impatient.

Re:Babili: An ES6+ aware minifier based on Babel by beefsack on Tuesday August 30, 2016 @09:38PM (#12395328)
All the effort put into Babili could have gone into that branch though, either through feature implementation or polishing so it's production ready.

It's a wrong assumption to make that free software can only be developed centrally by a project owner.

Re:Babili: An ES6+ aware minifier based on Babel by mlsarecmg on Wednesday August 31, 2016 @08:40AM (#12397827)
This is one of the cases where starting from scratch is probably the better choice. Uglify probably hasn't come near a stable because of the codebase in the first place.
Re:Babili: An ES6+ aware minifier based on Babel by tolmasky on Tuesday August 30, 2016 @05:06PM (#12393899)
At least when it comes to parsers, it makes sense for Babel to want to be "in control" of their destiny here. Its really hard to draw a line between transpiling and parsing, especially when many of the features you are implementing require new syntax. Not having your own parser can make this more difficult (especially considering how unfortunately most "production ready" parsers end up being hand rolled so don't really easily allow "plugins" or "composition" to easily add new syntax). As babel may aim to implement experimental features that may never actually be added to JavaScript, it would be understandable that that may be considered a low priority for a standalone JavaScript parser project while high priority for a transpiling project.
Re:Babili: An ES6+ aware minifier based on Babel by yladiz on Tuesday August 30, 2016 @05:10PM (#12393933)
But my point still stands -- why don't they just work with the acorn developers to get specific features rather than build their own?
Re:Babili: An ES6+ aware minifier based on Babel by hzoo on Tuesday August 30, 2016 @05:51PM (#12394232)
I would like that too! I don't think there have been any features added since the last one with Babel 6 release.

Yeah there's multiple JavaScript parsers: esprima, acorn, shift, babylon (uglify has their own parser I think).

There was an effort to standardize as well in https://github.com/estree/estree.

EDIT:

However, in Babel 6 there were a few (nice) incompatible changes to the AST which was unfortunate for interop and other tools (https://github.com/babel/babel-eslint had to make a lot of changes).

I don't want to speak for him, but I think a lot of the decisions to fork (parser, etc) at the time were most likely made like mentioned above to move faster. And at the time, Sebastian was basically the only one working on it. Maybe more context from his post: https://medium.com/@sebmck/2015-in-review-51ac7035e272#.qcyz...

Re:Babili: An ES6+ aware minifier based on Babel by anotherthing on Tuesday August 30, 2016 @06:02PM (#12394312)
acorn is an ECMAScript parse library that emits a JSON parse tree. It does its job very well, but doesn't do anything else.
Re:Babili: An ES6+ aware minifier based on Babel by ravenstine on Tuesday August 30, 2016 @05:08PM (#12393909)
Yes, I hate it when projects do this. Along with senseless forking, trying to solve too many problems(especially ones that are already solved) is one of the worst things that can happen to a piece of software.