# gulp-babel

> Use next generation JavaScript, today

Latest version **8.1.0** (published 2026-06-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-babel
pnpm add gulp-babel
yarn add gulp-babel
bun add gulp-babel
```

## Health

**Score 58/100 (C)** — status: active.

Positive: has types package; no vulnerabilities; recently updated; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 8.1.0 |
| Published | 2026-06-19 |
| First published | 2015-02-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/gulp-babel) |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 4 |
| Unpacked size | 7.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1307 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus, hzoo, sebmck, loganfsmyth, existentialism, nicolo-ribaudo |
| Keywords | gulpplugin, babel, transpiler, es2015, es2016, es2017, rewriting, transformation, syntax, codegen, desugaring, javascript, compiler |

## Links

- npm: https://www.npmjs.com/package/gulp-babel
- Repository: https://github.com/babel/gulp-babel
- Homepage: https://github.com/babel/gulp-babel#readme
- Issues: https://github.com/babel/gulp-babel/issues
- npm.io page: https://npm.io/package/gulp-babel

## Dependencies (4)

- [through2](https://npm.io/package/through2.md) ^3.0.0
- [replace-ext](https://npm.io/package/replace-ext.md) ^1.0.0
- [plugin-error](https://npm.io/package/plugin-error.md) ^1.0.1
- [vinyl-sourcemaps-apply](https://npm.io/package/vinyl-sourcemaps-apply.md) ^0.2.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 8.1.0 (latest) — 2026-06-19
- 8.0.0-beta.2 (next) — 2018-03-14
- 8.0.0 — 2018-08-28
- 8.0.0-beta.1 — 2018-01-26
- 7.0.1 — 2018-01-26
- 6.1.3 — 2018-01-26
- 8.0.0-beta.0 — 2017-10-30
- 7.0.0 — 2017-08-07
- 7.0.0-alpha.18 — 2017-08-04
- 6.1.2 — 2016-01-30
- 6.1.1 — 2015-11-27
- 6.1.0 — 2015-11-05
- 6.0.0 — 2015-10-30
- 5.3.0 — 2015-10-15
- 5.2.1 — 2015-08-20
- … 5 more at https://npm.io/package/gulp-babel/versions

## README

> This readme is for gulp-babel v8 + Babel v7/v8
> Check the [7.x branch](https://github.com/babel/gulp-babel/tree/v7-maintenance) for docs with Babel v6 usage

# gulp-babel [![npm](https://img.shields.io/npm/v/gulp-babel.svg?maxAge=2592000)](https://www.npmjs.com/package/gulp-babel) [![Build Status](https://travis-ci.org/babel/gulp-babel.svg?branch=master)](https://travis-ci.org/babel/gulp-babel)

> Use next generation JavaScript, today, with [Babel](https://babeljs.io)

*Issues with the output should be reported on the Babel [issue tracker](https://phabricator.babeljs.io/).*


## Install

Install `gulp-babel` if you want to get the pre-release of the next version of `gulp-babel`.

```
# Babel 7
$ npm install --save-dev gulp-babel @babel/core @babel/preset-env

# Babel 6
$ npm install --save-dev gulp-babel@7 babel-core babel-preset-env
```

## Usage

```js
const gulp = require('gulp');
const babel = require('gulp-babel');

gulp.task('default', () =>
	gulp.src('src/app.js')
		.pipe(babel({
			presets: ['@babel/preset-env']
		}))
		.pipe(gulp.dest('dist'))
);
```


## API

### babel([options])

#### options

See the Babel [options](http://babeljs.io/docs/en/options), except for `sourceMaps` and `filename` which is handled for you. Also, keep in mind that options will be loaded from [config files](http://babeljs.io/docs/en/config-files) that apply to each file.

## Source Maps

Use [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) like this:

```js
const gulp = require('gulp');
const sourcemaps = require('gulp-sourcemaps');
const babel = require('gulp-babel');
const concat = require('gulp-concat');

gulp.task('default', () =>
	gulp.src('src/**/*.js')
		.pipe(sourcemaps.init())
		.pipe(babel({
			presets: ['@babel/preset-env']
		}))
		.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()`](https://babeljs.io/docs/usage/api/).

#### Example

```js
const gulp = require('gulp');
const babel = require('gulp-babel');
const through = require('through2');

function logBabelMetadata() {
	return through.obj((file, enc, cb) => {
		console.log(file.babel.test); // 'metadata'
		cb(null, file);
	});
}

gulp.task('default', () =>
	gulp.src('src/**/*.js')
		.pipe(babel({
			// plugin that sets some metadata
			plugins: [{
				post(file) {
					file.metadata.test = 'metadata';
				}
			}]
		}))
		.pipe(logBabelMetadata())
)
```


## Runtime

If you're attempting to use features such as generators, you'll need to add `transform-runtime` as a plugin, to include the Babel runtime. Otherwise, you'll receive the error: `regeneratorRuntime is not defined`.

Install the runtime:

```
$ npm install --save-dev @babel/plugin-transform-runtime
$ npm install --save @babel/runtime
```

Use it as plugin:

```js
const gulp = require('gulp');
const babel = require('gulp-babel');

gulp.task('default', () =>
	gulp.src('src/app.js')
		.pipe(babel({
			plugins: ['@babel/transform-runtime']
		}))
		.pipe(gulp.dest('dist'))
);
```


## License

MIT © [Sindre Sorhus](http://sindresorhus.com)

---
_Source: https://npm.io/package/gulp-babel · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
