Skip to content

Commit 4811d57

Browse files
committed
fix: use simpler conditions for index.js, implements #1244
1 parent 608805a commit 4811d57

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

examples/parcel/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"version": "1.0.0",
44
"license": "MIT",
55
"scripts": {
6-
"start": "parcel index.html"
6+
"start": "parcel index.html",
7+
"start:prod": "parcel build index.html",
8+
"start:link": "cp -R ../../dist ./node_modules/react-hot-loader && cp -R ../../*.js ./node_modules/react-hot-loader"
79
},
810
"devDependencies": {
911
"babel-core": "^6.26.3",

index.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
'use strict';
22

3-
var hasWindow = typeof window !== 'undefined';
4-
5-
if (!module.hot || process.env.NODE_ENV === 'production' || !hasWindow) {
3+
if (process.env.NODE_ENV === 'production') {
4+
module.exports = require('./dist/react-hot-loader.production.min.js');
5+
} else if (!module.hot) {
6+
console.error('React-Hot-Loader: Hot Module Replacement is not enabled');
7+
module.exports = require('./dist/react-hot-loader.production.min.js');
8+
} else if (typeof window === 'undefined') {
9+
// this is just server environment
610
module.exports = require('./dist/react-hot-loader.production.min.js');
711
} else {
812
var evalAllowed = false;

0 commit comments

Comments
 (0)