Skip to content

Commit e231444

Browse files
committed
Remove backwards-incompatible babel-preset-env.
1 parent b358ca0 commit e231444

File tree

3 files changed

+45
-50
lines changed

3 files changed

+45
-50
lines changed

README.md

+42-47
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,74 @@
1-
babel-brunch
2-
===========
1+
## babel-brunch
2+
33
Brunch plugin using [babel](https://github.com/babel/babel) to turn latest
44
ECMAScript standard code into vanilla ES5 with no runtime required.
55

66
All the `.js` files in your project will be run through the babel compiler,
77
except those it is configured to ignore, unless you use the `pattern` option.
88

9-
Additionally, starting Brunch 2.7.3, babel-brunch will also compile NPM dependencies.
9+
Additionally, starting Brunch 2.7, babel-brunch will also compile NPM dependencies.
10+
11+
## Installation
1012

11-
Installation
12-
------------
1313
`npm install --save-dev babel-brunch`
1414

15-
Usage
16-
-----
15+
## Configuration
1716

18-
- **No configuration is required by default.** `es2015` and `es2016` presets are included.
19-
- To add **React** preset:
20-
- Execute `npm install --save-dev babel-preset-react`, then adjust the `presets` option in `brunch-config.js`:
21-
- `plugins: {babel: {presets: ['es2015', 'es2016', 'react']}}`
22-
- Default behavior is to handle `js` files which are not dependencies and `jsx` files if you enable React preset.
23-
- To specify preset options: `{presets: [['transform-es2015-template-literals', { spec: true }]]}`
17+
[babel-preset-latest](https://babeljs.io/docs/plugins/preset-latest/) (es2015, es2016, es2017) **is used by default**, you don't need to adjust config to have it.
2418

25-
Configuration
26-
-------------
19+
### Using React; or any other plugin
2720

28-
Set [babel options](https://babeljs.io/docs/usage/options) in your brunch
29-
config (such as `brunch-config.js`) except for `filename` and `sourceMap`
30-
which are handled internally.
21+
Install a plugin:
3122

32-
This plugin uses, by default,
33-
[babel-preset-env](https://github.com/babel/babel-preset-env/).
34-
To configure, use `env` option:
23+
```
24+
npm insall --save-dev babel-preset-react
25+
```
26+
27+
Then, make sure Brunch sees it:
3528

36-
```js
37-
plugins: {
29+
```javascript
30+
exports.plugins = {
3831
babel: {
39-
env: {
40-
targets: {
41-
safari: 7, // explicitly
42-
browsers: '>2%' // with browserslist query
43-
}
44-
}
32+
presets: ['latest', 'react']
4533
}
4634
}
4735
```
48-
Without providing any options, behavior will be like using [babel-preset-latest](https://babeljs.io/docs/plugins/preset-latest/) (es2015, es2016, es2017).
4936

50-
To use no preset, set the configuration option to an empty array.
37+
Optionally, you can configure the preset:
38+
39+
`presets: [ 'latest', ['transform-es2015-template-literals', {spec: true}] ]`
5140

52-
Additionally, you can set an `ignore` value to specify which `.js` files in
53-
your project should not be compiled by babel. By default, `ignore` is set to
54-
`/^(bower_components|vendor)/`.
5541

56-
You can also set `pattern` to a regular expression that will match the file
57-
paths you want compiled by babel, which will override the standard behavior of
58-
compiling every `.js` file.
42+
### Ignoring node modules
5943

60-
```js
61-
plugins: {
44+
```
45+
exports.plugins = {
6246
babel: {
63-
presets: ['es2015', 'es2016', 'react'], // es2015, es2016 are defaults
6447
ignore: [
65-
/^(bower_components|vendor)/,
48+
/^node_modules/,
6649
'app/legacyES5Code/**/*'
67-
],
68-
pattern: /\.(es6|jsx)$/ // js and jsx are defaults.
50+
]
51+
}
52+
}
53+
```
54+
55+
### Changing which files would be compiled by babel
56+
57+
```
58+
exports.plugins = {
59+
babel: {
60+
pattern: /\.es7$/ // By default, JS|JSX|ES6 are used.
6961
}
7062
}
7163
```
7264

73-
Change Log
74-
----------
65+
Set [babel options](https://babeljs.io/docs/usage/options) in your brunch
66+
config (such as `brunch-config.js`) except for `filename` and `sourceMap`
67+
which are handled internally.
68+
69+
## Change Log
7570
[See release notes page on GitHub](https://github.com/babel/babel-brunch/releases)
7671

77-
License
78-
-------
72+
## License
73+
7974
[ISC](https://raw.github.com/babel/babel-brunch/master/LICENSE)

index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ class BabelCompiler {
3939

4040
opts.sourceMap = !!config.sourceMaps;
4141
if (!opts.presets) {
42-
opts.presets = [['env', opts.env]];
42+
opts.presets = ['latest'];
43+
// ['env', opts.env]
4344
}
4445
if (!opts.plugins) opts.plugins = [];
4546

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@
3030
"dependencies": {
3131
"anymatch": "^1.0.0",
3232
"babel-core": "^6.0.0",
33-
"babel-preset-env": "^1.1.8",
33+
"babel-preset-latest": "^6.22.0",
3434
"loggy": "~1.0.1"
3535
},
3636
"devDependencies": {
3737
"babel-plugin-transform-es2015-template-literals": "^6.8.0",
3838
"babel-plugin-transform-node-env-inline": "^6.1.18",
39-
"babel-preset-es2015": "^6.22.0",
4039
"mocha": "^2.0.0",
4140
"eslint": "^2.0.0"
4241
}

0 commit comments

Comments
 (0)