Skip to content

Commit

Permalink
Close #46 PR: chore: update babel-core to 6.0.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
marionebl authored and sindresorhus committed Oct 30, 2015
1 parent 8db5d87 commit 94addac
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -37,14 +37,17 @@
"6to5"
],
"dependencies": {
"babel-core": "^5.8.19",
"babel-core": "^6.0.2",
"gulp-util": "^3.0.0",
"object-assign": "^4.0.1",
"replace-ext": "0.0.1",
"through2": "^2.0.0",
"vinyl-sourcemaps-apply": "^0.2.0"
},
"devDependencies": {
"babel-plugin-transform-es2015-arrow-functions": "^6.0.2",
"babel-plugin-transform-es2015-block-scoping": "^6.0.9",
"babel-plugin-transform-es2015-classes": "^6.0.8",
"gulp-sourcemaps": "^1.1.1",
"mocha": "*",
"xo": "*"
Expand Down
22 changes: 16 additions & 6 deletions readme.md
Expand Up @@ -8,7 +8,7 @@
## Install

```
$ npm install --save-dev gulp-babel
$ npm install --save-dev gulp-babel babel-preset-es2015
```


Expand All @@ -20,7 +20,9 @@ var babel = require('gulp-babel');

gulp.task('default', function () {
return gulp.src('src/app.js')
.pipe(babel())
.pipe(babel({
presets: ['babel-preset-es2015']
}))
.pipe(gulp.dest('dist'));
});
```
Expand Down Expand Up @@ -59,7 +61,7 @@ gulp.task('default', function () {
## Babel Metadata

Files in the stream are annotated with a `babel` property, which
contains the [metadata](http://babeljs.io/docs/advanced/external-helpers/#selective-builds) from `babel.transform()`.
contains the metadata from `babel.transform()`.

#### Example

Expand All @@ -77,22 +79,30 @@ function logFileHelpers() {

gulp.task('default', function () {
return gulp.src('src/**/*.js')
.pipe(babel())
.pipe(babel({
presets: ['babel-preset-es2015']
}))
.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`.
If you are attempting to use features such as generators, you will need to add `transform-runtime` as plugin to include the babel runtime. Otherwise you will receive the error: `regeneratorRuntime is not defined`.

Install the runtime:
```
npm install --save-dev babel-plugin-transform-runtime
```

Use it as plugin:
```js
var gulp = require('gulp');
var babel = require('gulp-babel');

gulp.task('default', function () {
return gulp.src('src/app.js')
.pipe(babel({ optional: ['runtime'] }))
.pipe(babel({ plugins: ['transform-runtime'] }))
.pipe(gulp.dest('dist'));
});
```
Expand Down
14 changes: 10 additions & 4 deletions test.js
Expand Up @@ -6,7 +6,9 @@ var sourceMaps = require('gulp-sourcemaps');
var babel = require('./');

it('should transpile with Babel', function (cb) {
var stream = babel();
var stream = babel({
plugins: ['transform-es2015-block-scoping']
});

stream.on('data', function (file) {
assert(/var foo/.test(file.contents.toString()), file.contents.toString());
Expand All @@ -29,7 +31,9 @@ it('should generate source maps', function (cb) {
var init = sourceMaps.init();
var write = sourceMaps.write();
init
.pipe(babel())
.pipe(babel({
plugins: ['transform-es2015-arrow-functions']
}))
.pipe(write);

write.on('data', function (file) {
Expand All @@ -53,10 +57,12 @@ it('should generate source maps', function (cb) {
});

it('should list used helpers in file.babel', function (cb) {
var stream = babel();
var stream = babel({
plugins: ['transform-es2015-classes']
});

stream.on('data', function (file) {
assert.deepEqual(file.babel.usedHelpers, ['class-call-check']);
assert.deepEqual(file.babel.usedHelpers, ['classCallCheck']);
});

stream.on('end', cb);
Expand Down

0 comments on commit 94addac

Please sign in to comment.