gaearon / gaearon/react-hot-loader

react-hot-loader breaks the page without react

Open
#1,159 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
12.2k
Forks
775
PR merge metrics
No merged PRs in 30d

Description

### Description

My project has a lot of pages, some of which don't use react, react-hot-loader breaks these pages.

### Expected behavior

no react-hot-loader code in the js of the page.

### Actual behavior

![image](https://user-images.githubusercontent.com/13401668/51511644-fe9bb880-1e3c-11e9-8a6a-9de9cd776605.png)
![image](https://user-images.githubusercontent.com/13401668/51511738-64884000-1e3d-11e9-8a0b-16cb5b0d66dd.png)

i add react in webpack externals, but do not add cdn link in this page. and react-hot-loader requires it, so "React is not defined", but i really don't need react. If i remove react-hot-loader/babel in .babelrc or remove react in externals or add cdn link in this page, everything will be ok.

### Environment

React Hot Loader version: 4.2.0

Run these commands in the project folder and fill in their results:

1. `node -v`: 8.11.3
2. `npm -v`: 6.4.0

### Reproducible Demo

.babelrc
``` json
{
"presets": [
[
"env",
{
"targets": {
"node": "current",
"browsers": ["Android >= 4", "iOS >= 8", "last 3 versions"]
}
}
],
"react"
],
"plugins": [
"transform-object-assign",
"react-hot-loader/babel",
"transform-class-properties",
[
"transform-runtime",
{
"polyfill": false,
"regenerator": true
}
]
]
}
```

webpack externals
``` javascripts
externals: {
vue: 'Vue',
react: 'React',
'react-dom': 'ReactDOM',
'prop-types': 'PropTypes',
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.