This repository has been archived by the owner on Sep 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [xde] Build XDE with Webpack Build XDE with Webpack. Benefits: - Adds HMR capabilities - Tree shaking with web pack 2 - Potential other optimizations in the future that I haven't thought of yet. Key points: - Keeps node_modules in `app` unbundled -- at the moment, there's no benefit in bundling them. - Uses source maps to keep debug-ability (for some reason source-map support was turned off in Chrome Developer Tools in Electron for me...make sure to turn it on) - You can run with hot module reloading turned off or on -- run `npm run start[-local | -staging]-hot` to use it, omit the `-hot` to not. - Modified npm scripts so that you don't have to run any watcher script separately. Just run the correct `npm run start-blahblahblha` command and go. - No need to `yarn` in both directories -- `yarn` in `dev/xde` will use a postinstall script to `yarn` in the `dev/xde/app` directory and also rebuild any node_modules using electron rebuild. - When bundling with Webpack, don't transpile commonJS modules -- Webpack understands these and uses them to do tree shaking. - Temporarily, we need to use the `es2015` preset with babel when using HMR -- there is a bug: gaearon/react-hot-loader#391 cc @jesseruder @ide * [xde] Install React Developer Tools * [xde] Update yarn.lock. * [XDE] Fix native dependency installation, update Electron * [xde] Rebuild when app starts, not on install * [xde] Fix dirname issue in renderer * [xde] Clean up gulp + webpack config * Fix yarn * [xde] Fixup babel/HMR config * re yarn * s/index/renderer * separate entry point for HMR fbshipit-source-id: f4e811b
- Loading branch information
Showing
12 changed files
with
362 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* @flow | ||
*/ | ||
|
||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import Redbox from 'redbox-react'; | ||
|
||
import { AppContainer } from 'react-hot-loader'; | ||
|
||
import App from './ui/App'; | ||
|
||
const rootNode = document.getElementById('app'); | ||
|
||
const render = () => { | ||
if (window.HMR) { | ||
ReactDOM.render( | ||
<AppContainer errorReporter={Redbox}> | ||
<App segment={window.analytics} /> | ||
</AppContainer>, | ||
rootNode | ||
); | ||
} else { | ||
ReactDOM.render( | ||
<App segment={window.analytics} />, | ||
rootNode | ||
); | ||
} | ||
}; | ||
|
||
window.addEventListener('beforeunload', () => { | ||
ReactDOM.unmountComponentAtNode(rootNode); | ||
}); | ||
|
||
if (window.HMR) { | ||
// Hot Module Replacement API | ||
if (module.hot) { | ||
try { | ||
// host re-render | ||
// $FlowFixMe | ||
module.hot.accept('./ui/App', render); | ||
} | ||
catch (error) { | ||
// hot re-render failed. display a nice error page like inwebpack-hot-middleware | ||
const RedBox = require('redbox-react'); | ||
ReactDOM.render(<RedBox error={error} className="redbox" />, rootNode); | ||
} | ||
} | ||
} | ||
|
||
render(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* @flow | ||
*/ | ||
|
||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
import App from './ui/App'; | ||
|
||
const rootNode = document.getElementById('app'); | ||
|
||
ReactDOM.render( | ||
<App segment={window.analytics} />, | ||
rootNode | ||
); | ||
|
||
window.addEventListener('beforeunload', () => { | ||
ReactDOM.unmountComponentAtNode(rootNode); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
export { default as App } from './App'; |
Oops, something went wrong.