Skip to content

Commit 2596022

Browse files
committed
Update hmr-react.md
Add note about using es6 modules with webpack 2 tree-shaking
1 parent 45cfeef commit 2596022

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

content/guides/hmr-react.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ sort: 8
44
contributors:
55
- jmreidy
66
- jhnns
7+
- sararubin
78
---
89

910
As explained in detail on the [concept page](/concepts/hot-module-replacement), Hot Module Replacement (HMR) exchanges, adds, or removes modules while an application is running without a page reload.
@@ -234,6 +235,10 @@ The important thing to note in the code above is the `module` reference.
234235

235236
like what we did in [Babel Config](#babel-config). Note that disabling Babel's module plugin is not only necessary for HMR. If you don't disable it you'll run into many other issues (see [Migrating from v1 to v2](/guides/migrating/#mixing-es2015-with-amd-and-commonjs) and [webpack-tree-shaking](http://www.2ality.com/2015/12/webpack-tree-shaking.html)).
236237

238+
4. Note that if you're using ES6 modules in your Webpack 2 configuration file, and you change your `.babelrc` file in #3 above, you either need to use `require` or create two `.babelrc` files (issue [here](https://github.com/webpack/webpack.js.org/issues/154)):
239+
* One in the project root directory with `"presets": ["es2015"]
240+
* One in the home directory for webpack to build. For this example, in `src/`.
241+
237242
So in this case, `module.hot.accept` will fire the `render` method whenever `src/components/App.js` or its dependencies are changed - which means the `render` method will also fire when the `App.css` is changed, since `App.css` is included in `App.js`.
238243

239244
### index.html

0 commit comments

Comments
 (0)