-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add Babel #15
Add Babel #15
Conversation
bin/gyp
Outdated
@@ -1,7 +1,7 @@ | |||
#!/usr/bin/env node | |||
const gyp = require('../'); | |||
var gyp = require('../'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not compiling bin/
and since its just a few lines I just changed to var
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Thank you! Tests require |
Cool just did function Ninja() {}
Ninja.prototype.copies = function copies() { // SyntaxError: "copies" is read-only
const copies = 1; //
};
Need to add transform-runtime for |
a8152c7
to
236db66
Compare
Thank you so much for this! I'm a complete noob with regards to Babel. As far as I got it, it looks like Unfortunately there are no benchmarks for the input at the moment, so I guess it could be benchmarked only on |
Idiomatic ES6 is typically slower than hand-written ES5 on v8 as it is not as well tuned. https://kpdecker.github.io/six-speed/
|
@kzc so basically, the things that I have used here are: |
@hzoo I have simplified lots of code in recent commits. I think we now use only |
Adding more or less ES6 is fine for Babel 😄 (given i'm running the es2015 preset which transpiles es6 syntax, otherwise could choose a smaller/specific set of transforms). Still have to transpile the use of stuff like Map/Set though (either a specific module like es6-map or use the babel one (core-js)) |
@hzoo yeah, I just hope to gain as much control as possible over the resulting code. Optimally, it should be almost the same, but with |
You can use "loose" mode for most things but ok, what do you want to do for |
@hzoo I think |
Sorry didn't get to update this. When I rebased, I realize that Also do we want a polyfill that changes globals (Map, Set) or just use the ponyfill's modules? edit: Not sure why the commits aren't updating. branch is here: https://github.com/hzoo/gyp.js/tree/add-babel (can do another pr) |
Also regarding your earlier comment, babel is pretty good on the output of most things (especially with loose mode). Like classes is no big deal (you can try it in the repl here). In that case, the only thing it adds that you wouldn't do handwritten is the classCallCheck to make sure you call with so let/const, template strings, destructuring, classes, arrow functions, shorthand methods/properties, computed properties, literals are simple. |
@indutny should I still update this? Not sure why the commits are off now (maybe force pushed incorrectly) |
@hzoo TBH, I'm not yet sure. I think that I have reduced ES6 usage to get this thing working on node.js v4-master. At the moment, @pmed is pushing gyp.js as a backend for node-gyp, and I would like to keep this a priority for this project. I'm really glad to see lots of things that you did here. Let's return to this a bit later, when we will reach the node-gyp goal. Thanks! |
Ok rebased again so it only has my changes. it fails on node 0.10 because some of the dependencies are on node 4 |
@indutny should I close this PR? It's been a long time but it's a lot easier to do this now with babel-preset-env, by targeting node 0.10/0.12/4/etc (it only compiles what's not supported) {
"presets": [
["env", {
"targets": {
"node": 4
}
}]
]
} |
Actually, I have been playing with Would you care to rebase this PR, please? |
Ok I rebased and am targeting node 4 (since now 0.10/0.12 are deprecated) if that is what we wanted now |
Landed in 1ad257b, thank you so much! This should give me some starting base to porting this to duktape. |
Do we close #9 now? |
Ref #9
Just add's Babel, but with preset-env
Old description
Just did the basic thing, probably needs changes, might need to look again monday/tues though since I'm busy for most of tomorrow.
These tests were failing for me locally for some reason (node 6) on master as well