Skip to content

Commit d25c23e

Browse files
committed
switch from babel-preset-es2015 to babel-preset-env addresses reactjs#112 and reactjs#113
1 parent b0a6aa2 commit d25c23e

File tree

6 files changed

+26
-7
lines changed

6 files changed

+26
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Next
2+
* switch from babel-preset-es2015 to babel-preset-env
3+
14
# v0.10.4 (2017-10-13)
25

36
* Fixed bug preventing the use of arrays for the Express views setting

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ option | values | default
3434
`doctype` | any string that can be used as [a doctype](http://en.wikipedia.org/wiki/Document_type_declaration), this will be prepended to your document | `"<!DOCTYPE html>"`
3535
`beautify` | `true`: beautify markup before outputting (note, this can affect rendering due to additional whitespace) | `false`
3636
`transformViews` | `true`: use `babel` to apply JSX, ESNext transforms to views.<br>**Note:** if already using `babel-register` in your project, you should set this to `false` | `true`
37-
`babel` | any object containing valid Babel options<br>**Note:** does not merge with defaults | `{presets: ['react', 'es2015']}`
37+
`babel` | any object containing valid Babel options<br>**Note:** does not merge with defaults | `{presets: ['react', [ "env", {"targets": {"node": "current"}}]]}`
3838

3939
The defaults are sane, but just in case you want to change something, here's how it would look:
4040

@@ -46,7 +46,7 @@ app.engine('jsx', require('express-react-views').createEngine(options));
4646

4747
### Views
4848

49-
Under the hood, [Babel][babel] is used to compile your views into ES5 friendly code, using the [react][babel-preset-react] and [es2015][babel-preset-es2015] presets by default. Only the files in your `views` directory (i.e. `app.set('views', __dirname + '/views')`) will be compiled.
49+
Under the hood, [Babel][babel] is used to compile your views to code compatible with your current node version, using the [react][babel-preset-react] and [env][babel-preset-env] presets by default. Only the files in your `views` directory (i.e. `app.set('views', __dirname + '/views')`) will be compiled.
5050

5151
Your views should be node modules that export a React component. Let's assume you have this file in `views/index.jsx`:
5252

@@ -156,11 +156,17 @@ All "locals" are exposed to your view in `this.props`. These should work identic
156156

157157
* It's not possible to specify a doctype in JSX. You can override the default HTML5 doctype in the options.
158158

159+
## Contributors
160+
* [Zpao][zpao] (Author)
161+
* [Venkat Reddy][svenkatreddy]
162+
159163
[express]: http://expressjs.com/
160164
[react]: http://facebook.github.io/react/
161165
[jade]: http://jade-lang.com/
162166
[ejs]: http://embeddedjs.com/
163167
[hbs]: https://github.com/barc/express-hbs
164168
[babel]: https://babeljs.io/
165169
[babel-preset-react]: https://babeljs.io/docs/plugins/preset-react/
166-
[babel-preset-es2015]: https://babeljs.io/docs/plugins/preset-es2015/
170+
[babel-preset-env]: https://babeljs.io/docs/plugins/preset-env/
171+
[zpao]: https://github.com/zpao
172+
[svenkatreddy]: https://github.com/svenkatreddy

examples/dynamic/.babelrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"presets": [
3+
"react",
4+
"env"
5+
]
6+
}

examples/dynamic/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"author": "Chris Johnson <[email protected]>",
66
"private": true,
77
"scripts": {
8-
"start": "browserify -t [ babelify --presets [ es2015 react ] --standalone main views/main.js -o public/main.js ] && node app.js"
8+
"start": "browserify -t babelify views/main.js --standalone main -o public/main.js && node app.js"
99
},
1010
"dependencies": {
11-
"babel-preset-es2015": "^6.24.1",
11+
"babel-preset-env": "^1.6.0",
1212
"babel-preset-react": "^6.24.1",
1313
"babelify": "^7.3.0",
1414
"browserify": "^14.3.0",

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ var DEFAULT_OPTIONS = {
2020
babel: {
2121
presets: [
2222
'react',
23-
'es2015',
23+
[ "env", {
24+
"targets": {
25+
"node": "current",
26+
},
27+
}],
2428
],
2529
},
2630
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"react-dom": "^0.14.0 || ^15.0.0 || ^16.0.0"
2323
},
2424
"dependencies": {
25-
"babel-preset-es2015": "^6.24.1",
25+
"babel-preset-env": "^1.6.0",
2626
"babel-preset-react": "^6.24.1",
2727
"babel-register": "^6.26.0",
2828
"js-beautify": "^1.7.3",

0 commit comments

Comments
 (0)