Skip to content
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

Gulpfile in ES6 #62

Open
yoiang opened this issue Mar 24, 2016 · 7 comments
Open

Gulpfile in ES6 #62

yoiang opened this issue Mar 24, 2016 · 7 comments

Comments

@yoiang
Copy link

yoiang commented Mar 24, 2016

Hey @nicosantangelo !

My gulpfile is written in ES6 and I'm encountering this error:

(function (exports, require, module, __filename, __dirname) { import gulp from
                                                              ^^^^^^
SyntaxError: Unexpected reserved word
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at requireGulp (/Users/ian/Library/Application Support/Sublime Text 3/Packages/Gulp/write_tasks_to_cache.js:28:16)
    at Object.<anonymous> (/Users/ian/Library/Application Support/Sublime Text 3/Packages/Gulp/write_tasks_to_cache.js:83:12)
    at Module._compile (module.js:460:26)

It looks like sublime-gulp doesn't support ES6 at the moment. Are there plans in the future? Or is it another issue?

@nicosantangelo
Copy link
Owner

Actually it never came up as a desired feature but I like the idea. The problem is that the package has to run the gulpfile in order to get the tasks and be able to list them.

  • What do you use to run ES6 gulp from the command line?
  • Using the command Gulp: Run arbitrary task works?

@yoiang
Copy link
Author

yoiang commented Mar 25, 2016

By having the babel transpiler present using gulp directly (gulp run <blah>) works with our ES6 gulpfile.

This looks like an accurate tutorial to how we set ours up: http://macr.ae/article/gulp-and-babel.html

@nicosantangelo
Copy link
Owner

Hello again!

I created a test project with:

├── gulpfile.babel.js
├── .babelrc

Which has

$ cat .babelrc
{
  "presets": ["es2015"]
}
$ cat gulpfile.babel.js
import gulp from 'gulp';

gulp.task('default', () => console.log('Default task called'));

and I installed npm i --save babel-register babel-preset-es2015

After doing that, I can run gulp from both the command line and Sublime:

screen shot 2016-03-27 at 1 39 02 am

Am I missing something?

@yoiang
Copy link
Author

yoiang commented Mar 28, 2016

That worked a ok running through the plugin?

Huh, then something else is messing with this on our end...

@nicosantangelo
Copy link
Owner

In the spirit of troubleshooting this, your gulpfile is called gulpfile.bebel.js?

I run into the save problem as you using ES6 and a gulpfile called gulpfile.js

@yoiang
Copy link
Author

yoiang commented Mar 30, 2016

Arg, my mistake: so executing the default task or an arbitrary task works but getting a list of tasks does not, it seems to be creating a .sublime-gulp-tmp.js file, where this error is occuring.

@nicosantangelo
Copy link
Owner

Sublime Gulp works by creating a .sublime-gulp-tmp.js from which it extracts the gulp tasks.

The weird thing is that it looks like ES6 is being recognized in your project, but another issue makes it blow up, because the error says SyntaxError: Unexpected reserved word instead of SyntaxError: Unexpected token import.

If you don't mind, could you paste your gulpfile.babel.js here? (removing any sensible parts, if any) so I can give it a go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants