sublime-gulp icon indicating copy to clipboard operation
sublime-gulp copied to clipboard

Gulpfile in ES6

Open yoiang opened this issue 9 years ago • 7 comments
trafficstars

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?

yoiang avatar Mar 24 '16 15:03 yoiang

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?

nicosantangelo avatar Mar 25 '16 12:03 nicosantangelo

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

yoiang avatar Mar 25 '16 14:03 yoiang

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?

nicosantangelo avatar Mar 27 '16 04:03 nicosantangelo

That worked a ok running through the plugin?

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

yoiang avatar Mar 28 '16 12:03 yoiang

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

nicosantangelo avatar Mar 28 '16 14:03 nicosantangelo

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.

yoiang avatar Mar 30 '16 14:03 yoiang

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

nicosantangelo avatar Apr 01 '16 11:04 nicosantangelo