JSPM

gulp-babel5

5.4.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q27483F
  • License MIT

Turn ES6 code into vanilla ES5 with no runtime required

Package Exports

  • gulp-babel5

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gulp-babel5) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

gulp-babel Build Status

Turn ES6 code into vanilla ES5 with no runtime required using babel

Issues with the output should be reported on the babel issue tracker.

Install

$ npm install --save-dev gulp-babel

Usage

var gulp = require('gulp');
var babel = require('gulp-babel');

gulp.task('default', function () {
    return gulp.src('src/app.js')
        .pipe(babel())
        .pipe(gulp.dest('dist'));
});

API

babel([options])

options

See the babel options, except for sourceMap and filename which is handled for you.

Source Maps

Use gulp-sourcemaps like this:

var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var babel = require('gulp-babel');
var concat = require('gulp-concat');

gulp.task('default', function () {
    return gulp.src('src/**/*.js')
        .pipe(sourcemaps.init())
        .pipe(babel())
        .pipe(concat('all.js'))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('dist'));
});

Babel Metadata

Files in the stream are annotated with a babel property, which contains the metadata from babel.transform().

Example

var gulp = require('gulp');
var babel = require('gulp-babel');
var through = require('through2');

function logFileHelpers() {
    return through.obj(function (file, enc, cb) {
        console.log(file.babel.usedHelpers);
        cb(null, file);
    });
}

gulp.task('default', function () {
    return gulp.src('src/**/*.js')
        .pipe(babel())
        .pipe(logFileHelpers);
})

Runtime

If you are attempting to use features such as generators, you will need to pass { optional: ['runtime'] } to include the babel runtime. Otherwise you will receive the error: regeneratorRuntime is not defined.

var gulp = require('gulp');
var babel = require('gulp-babel');

gulp.task('default', function () {
    return gulp.src('src/app.js')
        .pipe(babel({ optional: ['runtime'] }))
        .pipe(gulp.dest('dist'));
});

License

MIT © Sindre Sorhus