Skip to content

Commit 40a0beb

Browse files
authored
Update .babelrc section
* Move explanations inline to the file * Switch to new es2015 syntax
1 parent bee36a8 commit 40a0beb

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

content/how-to/hot-module-reload.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,25 @@ Your `.babelrc` file should look like the following:
2626

2727
```js
2828
{
29-
"presets": ["es2015-webpack", "stage-2", "react"],
30-
"plugins": ["react-hot-loader/babel"]
29+
"presets": [
30+
["es2015", {"modules": false}],
31+
//Webpack understands the native import syntax, and uses it for tree shaking
32+
33+
"stage-2",
34+
//Specifies what level of language features to activate.
35+
//State 2 is "draft", 4 is finished, 0 is strawman.
36+
//See https://tc39.github.io/process-document/
37+
38+
"react"
39+
//Transpile React components to JS
40+
],
41+
"plugins": [
42+
"react-hot-loader/babel"
43+
//Enables React code to work with HMR.
44+
]
3145
}
3246
```
3347

34-
There's a few things to note here. First, in the presets, we're using es2015-webpack, which is a Babel preset that enables support for es2015 while DISABLING conversion to CommonJS module format. Since Webpack 2 understands import/export syntax, the es2015-webpack preset (unlike the general es2015 preset) allows Webpack to perform tree-shaking and dead code elimination.
35-
36-
The stage-2 preset is up to your comfort with adopting new technologies; stage-0 will keep you on the bleeding age.
37-
38-
Finally, the React preset will enable React specific transpilation, while the react-hot-loader/babel plugin will enable your React code to work with HMR.
39-
4048
###Webpack config
4149
While there's many ways of setting up your Webpack config - via API, via multiple or single config files, etc - here is the basic information you should have available:
4250

0 commit comments

Comments
 (0)