-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Support ES6 #830
Comments
👍 Would be awesome to have this work transparently. |
@domenic a registration module needs to be provided for interpret. That's why I was looking at 6to5. I'd like to use Traceur but there isn't a module and we can't use makeDefault |
👍 looking forward for it. |
ES6 should be usable against master now. Try it out and let me know how it works. |
@phated I'm already using the gulp4.0 branch. Is it possible to get this there too? |
@phated Doesn't work. I get |
apparently merging the gulp-cli master into 4.0 solves the problem. The second problem is the gulp-cli check complains about the local gulp version (4.0.0-alpha), probably because he doesn't understand the alpha thing :-) |
Should be working now. Thanks for catching those. |
I can confirm it works now (gulpfile has to end with .es6 or .es instead of .js). |
@geekflyer @phated is the .es6 extension a real thing, or just for transpilers? Is .js not going to be used anymore? Is there no way to detect ES6 in a JS file? |
@ilanbiala I don't think .es6 is a real / offical extension, it's just a simple way to tell your CLI or transpiler, "hey this file probably has some ES6 code in there". The other alternative would be to simply transpile all .js files or scan all .js files for ES6 syntax - both would cause not negligible overhead as oppose to just looking for the file extension .es6. In my own project (which has a central gulpfile + ~10 subfiles) I could see the startup of gulp to slow down about ~1 second when using .es6, because the 6to5 transpiler has to be initialized etc.. It would not make sense to slow down everybody's gulp startup through code scanning etc. when they don't use ES6. |
Note that also other transpilers (coffee, JSX, TypeScript) are supported for gulpfiles - the extension always indicates which transpiler to use. Basically everything which is listed here is supported: |
SystemJS relies on format detection based on hints present in the files (e.g. |
I've been thinking about this for a while, and I stumbled upon what IMO is the right answer: the extension should be
|
👍 |
👍 for Also has the advantage that I don't have to tell my IDE / Editor explicitly that .es6 is actually just JavaScript. |
I'm +1 for |
I have no opinions on this and am open to changing it to .6to5.js (breaking change in interpret) but should we still register on My proposal is to register on the extensions: I also need to check liftoff and see if it supports double extensions, as I know it needed to be fixed in node-rechoir. |
I don't entirely understand what "register on .js when it is loaded" means (especially the "loaded" part). But I think it seems bad since then in e.g. an io.js environment how could you use the native ES6 features? |
@domenic He means, that when the gulpfile.6to5.js is loaded all subsequently required .js files (like subtasks1.js, subtasks2.js etc.) should also be transpiled using 6to5, even though they don't have the special 6to5 extension (except node_modules folder). This is also the default behaviour of 6to5's require hook which is being used in gulp: https://6to5.org/docs/usage/require/ |
@domenic exactly as @geekflyer said (quicker than me at typing 😛). I don't think you should have to name all your files |
Oh, ick, that seems pretty bad. The same concerns about those required subtasks apply as they do to the gulpfile. E.g., you are not writing JS (in the sense of what is interpreted by JS by the node/io.js environment). You are writing the 6to5 dialect, with all its foibles. |
@adam-beck That shouldn't be the case. Can you please elaborate on why you say that? @shadowmint It currently works for me with either This warning when
EDIT: however, in babel v6 the functionality this relies on probably isn't going to be in the |
Here's my import gulp from 'gulp';
gulp.task('default', () => console.log('default')); With
With
|
@moretti What's your |
@jmm I'm using
|
@moretti Try |
@jmm Yeah, that's correct, thank you. Removing and reinstalling my global version of |
@moretti Great! You're welcome. |
I'm getting an issue related to this, as I'm trying to require the babel/register module from within a gulp task to pass it into the gulp mocha task as a compiler
yet I get this error: |
If Babel is already being used for the gulpfile, all you need is this: gulp.src('test/spec/**/*.js')
.pipe(mocha()) If not, you only need this: require('babel/register')
gulp.src('test/spec/**/*.js')
.pipe(mocha()) |
is it possible to pass in options when using require('babel/register')({ ignore: false }) |
@webdesserts Have you tried using the .babelrc? |
@IMPinball I did and it would have worked, unfortunately I later found that I also needed to use |
@webdesserts that's my understanding. The idea has crossed my mind of making |
You could also try this as the gulpfile.js: require('babel/register')({
/* your extra options */
})
require('./gulpfile.babel.js') To be honest, this pattern works with any compiler with a require hook. On Sun, Sep 6, 2015, 11:50 Jesse McCarthy notifications@github.com wrote:
|
@IMPinball Yeah, I ended up just doing what I was doing before for now. @jmm It would be nice if babel supported a |
@webdesserts that might be how plugins work in v6, so it might be possible to shift most of the config (or just |
@jimm well if you do end up removing |
Those looking for a way to use |
Thanks @isiahmeadows. I've updated the repo accordingly. |
Hy, Unfortunately, I still have this issue on Windows 10 (Windows_NT 6.3.9600) I use NVM and run Node version 5.10.1 and NPM version 3.9.5 I have installed gulp and gulp-cli globally and locally as 3.9.0 I have installed though I get following errors if I run any gulp command:
Hope anyone can help |
@AndyOGo I just created a minimal gulpfile repo with 2 branches: Does the babel branch work for you? |
This work has been discussed and issue opened over at gulpjs/interpret#8
The text was updated successfully, but these errors were encountered: