Skip to content

Commit 92961be

Browse files
authored
Discourage using webpack loader for all the files (#1452)
* Replaces the phrase "It is safe to enable this loader for all the files" with "It is _possible_ to enable...", because it's neither safe (as proven in #1449) nor usually necessary. * Switches first example of Webpack config (suboptimal, applying loader to all the files) with the second one (optimal, applying loader to react-dom only, if you're using babel plugin)
1 parent ec3447f commit 92961be

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -382,16 +382,17 @@ class MyComponent extends React.Component {
382382

383383
But `webpack-loader` could help with TypeScript or _spreading_ "cold API" [to all node_modules](https://github.com/gaearon/react-hot-loader#disabling-a-type-change-for-all-node_modules).
384384

385-
> It is safe to enable this loader for all the files. But place it after babel-loader, if babel-loader is present.
385+
> It is possible to enable this loader for all the files, but if you use `babel` plugin, you need to enable this loader for `react-dom` only. Place it after babel-loader, if babel-loader is present.
386386
387387
```js
388388
// webpack.config.js
389389
module.exports = {
390390
module: {
391391
rules: [
392+
// would only land a "hot-patch" to react-dom
392393
{
393-
test: /\.jsx?$/,
394-
include: /node_modules/,
394+
test: /\.js$/,
395+
include: /node_modules\/react-dom/,
395396
use: ['react-hot-loader/webpack'],
396397
},
397398
],
@@ -401,14 +402,13 @@ module.exports = {
401402

402403
Webpack plugin will also land a "hot" patch to react-dom, making React-Hot-Loader more compliant to [the principles](https://github.com/gaearon/react-hot-loader/issues/1118).
403404

404-
If you are using `babel-plugin` you might not need to apply `webpack-loader` to all the files, scoping it to `react-dom`
405+
If you are not using `babel` plugin you might need to apply `webpack-loader` to all the files.
405406

406407
```js
407-
// would only land a "hot-patch" to react-dom
408408
{
409-
test: /\.js$/,
410-
include: /node_modules\/react-dom/,
411-
use: ['react-hot-loader/webpack']
409+
test: /\.jsx?$/,
410+
include: /node_modules/,
411+
use: ['react-hot-loader/webpack']
412412
},
413413
```
414414

0 commit comments

Comments
 (0)