From b746a4967b66156f4a18bf782a5ce824c157ed34 Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Sat, 10 Sep 2016 13:58:57 +0300 Subject: [PATCH] Fix hmr --- src/index.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/index.js b/src/index.js index 5630bb0..27872e4 100644 --- a/src/index.js +++ b/src/index.js @@ -1,20 +1,26 @@ import 'babel-polyfill'; -import ReactDOM from 'react-dom'; -import ReactDOMServer from 'react-dom/server'; - -import App from 'App'; +// NOTE: we are requiring with require(), to enable dynamic dependencies +// depending on ENV, where App is running in. +// This allows us better support of hmr and reduces bundle size /* global process: false */ +// eslint-disable-next-line no-negated-condition if (process.env.NODE_ENV !== 'production') { + const ReactDOM = require('react-dom'); const DevApp = require('devTools').default; ReactDOM.render( , document.getElementById('app') ); -} +} else { + const ReactDOMServer = require('react-dom/server'); + const App = require('App').default; -export default function(props) { - return ReactDOMServer.renderToStaticMarkup(); + module.exports = { + default(props) { + return ReactDOMServer.renderToStaticMarkup(); + } + }; }