Skip to content

Commit

Permalink
fix: dont resolve require() for react-loadable.json. fixes #48
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinl committed Feb 23, 2018
1 parent 1c8d327 commit 6db764f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"node": true
},
"globals": {
"expect": true
"expect": true,
"__non_webpack_require__": true
},
"extends": [
"eslint:recommended",
Expand Down
8 changes: 7 additions & 1 deletion server/renderer/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ import config from '../../config';

let stats = null;

// This is a small 'hack' to tell webpack to avoid resolving the below file
// during compilation, since react-loadable.json may or may not exist.
const requireFunc = typeof __webpack_require__ === 'function'
? __non_webpack_require__
: require;

if (config.enableDynamicImports) {
stats = require('../../react-loadable.json');
stats = requireFunc('../../react-loadable.json');
}

export default function handleRender(req, res) {
Expand Down

0 comments on commit 6db764f

Please sign in to comment.