Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[Babel](https://github.com/babel/babel) [browserify](https://github.com/substack/node-browserify) transform.

As of [Babel 6.0.0](http://babeljs.io/blog/2015/10/29/6.0.0/) there are **no plugins included by default**. For babelify to be useful, you must also include some [presets](http://babeljs.io/docs/plugins/#presets) and/or [plugins](http://babeljs.io/docs/plugins/#transform).
As of [Babel 6.0.0](https://babeljs.io/blog/2015/10/29/6.0.0/) there are **no plugins included by default**. For babelify to be useful, you must also include some [presets](https://babeljs.io/docs/plugins/#presets) and/or [plugins](https://babeljs.io/docs/plugins/#transform).

## Installation

Expand Down Expand Up @@ -33,15 +33,15 @@ browserify("./script.js")
.pipe(fs.createWriteStream("bundle.js"));
```

**NOTE:** [Presets and plugins](http://babeljs.io/docs/plugins/) need to be installed as separate modules. For the above examples to work, you'd need to also install [`@babel/preset-env`](https://www.npmjs.com/package/@babel/preset-env) and [`@babel/preset-react`](https://www.npmjs.com/package/@babel/preset-react):
**NOTE:** [Presets and plugins](https://babeljs.io/docs/plugins/) need to be installed as separate modules. For the above examples to work, you'd need to also install [`@babel/preset-env`](https://www.npmjs.com/package/@babel/preset-env) and [`@babel/preset-react`](https://www.npmjs.com/package/@babel/preset-react):

```sh
$ npm install --save-dev @babel/preset-env @babel/preset-react
```

### Options

Selected options are discussed below. See the [babel](http://babeljs.io/) docs for the complete list of [options](http://babeljs.io/docs/usage/options/).
Selected options are discussed below. See the [babel](https://babeljs.io/) docs for the complete list of [options](https://babeljs.io/docs/usage/options/).

Options may be passed in via standard [browserify](https://github.com/substack/node-browserify#btransformtr-opts) ways:

Expand Down Expand Up @@ -127,18 +127,18 @@ $ browserify -t [ babelify --sourceMapsAbsolute ]

```javascript
browserify().transform(babelify.configure({
// Optional ignore regex - if any filenames **do** match this regex then
// they aren't compiled
ignore: /regex/,
// Optional 'ignore' regex array - if any filenames **do** match a regex in
// this array, then they aren't compiled.
ignore: [/regex/],

// Optional only regex - if any filenames **don't** match this regex
// then they aren't compiled
only: /my_es6_folder/
// Optional 'only' regex array - if any filenames **don't** match a regex in
// this array, then they aren't compiled.
only: [/my_es6_folder/]
}))
```

```sh
$ browserify -t [ babelify --ignore regex --only my_es6_folder ]
$ browserify -t [ babelify --ignore [ regex ] --only [ my_es6_folder ] ]
```

#### Babel result (metadata and others)
Expand Down Expand Up @@ -187,12 +187,12 @@ specify options then you can use:
}
```

Another solution (proceed with caution!) is to run babelify as a [global](https://github.com/substack/node-browserify#btransformtr-opts) transform. Use the babel [`ignore` option](http://babeljs.io/docs/usage/options/) to narrow the number of files transformed:
Another solution (proceed with caution!) is to run babelify as a [global](https://github.com/substack/node-browserify#btransformtr-opts) transform. Use the babel [`ignore` option](https://babeljs.io/docs/usage/options/) to narrow the number of files transformed:

```js
browserify().transform("babelify", {
global: true,
ignore: /\/node_modules\/(?!app\/)/
ignore: [/\/node_modules\/(?!app\/)/]
});
```

Expand Down