Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Remove hot module replacement #291

Merged
merged 2 commits into from
Aug 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"@types/react": "16.8.22",
"@types/react-color": "^3.0.1",
"@types/react-dom": "^16.8.4",
"@types/react-hot-loader": "^4.1.0",
"@types/react-measure": "^2.0.5",
"@types/react-outside-click-handler": "^1.2.0",
"@types/react-router": "^5.0.2",
Expand All @@ -76,7 +75,6 @@
"@types/throttle-debounce": "^1.1.1",
"@types/webpack": "^4.4.33",
"@types/webpack-dev-middleware": "^2.0.2",
"@types/webpack-hot-middleware": "^2.16.5",
"@types/xxhashjs": "^0.2.1",
"babel-loader": "^8.0.6",
"caniuse-lite": "^1.0.30000983",
Expand All @@ -99,7 +97,6 @@
"postcss-reporter": "6.0.1",
"postcss-url": "^8.0.0",
"raw-loader": "^3.0.0",
"react-hot-loader": "4.11.1",
"react-svg-loader": "2.1.0",
"rimraf": "^2.6.3",
"seedrandom": "^3.0.1",
Expand All @@ -115,8 +112,7 @@
"webpack": "^4.35.0",
"webpack-cli": "^3.3.5",
"webpack-dev-middleware": "^3.7.0",
"webpack-dev-server": "^3.7.2",
"webpack-hot-middleware": "^2.25.0"
"webpack-dev-server": "^3.7.2"
},
"dependencies": {
"binary": "^0.3.0",
Expand Down
31 changes: 0 additions & 31 deletions src/client/components/app/install.tsx

This file was deleted.

12 changes: 3 additions & 9 deletions src/client/components/app/view.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
import { Component } from 'react'
import React from 'react'
import { hot } from 'react-hot-loader'
import { Switch } from 'react-router'
import { Route } from 'react-router'
import { BrowserRouter } from 'react-router-dom'

import { NavigationConfiguration } from '../../navigation'
import { NavigationView } from '../navigation/view'

import { installNav } from './install'
import style from './style.css'

class AppView extends Component {
private readonly nav: NavigationConfiguration = installNav()

export class AppView extends Component<{ nav: NavigationConfiguration }> {
render() {
return (
<BrowserRouter>
<div className={style.app}>
<NavigationView nav={this.nav}/>
<NavigationView nav={this.props.nav}/>
<div className={style.app__container}>
<div className={style.app__content}>
<Switch>
{...this.nav.getRoutes().map(config => <Route
{...this.props.nav.getRoutes().map(config => <Route
key={config.path}
exact={config.exact}
path={config.path}
Expand All @@ -36,5 +32,3 @@ class AppView extends Component {
)
}
}

export default hot(module)(AppView)
30 changes: 28 additions & 2 deletions src/client/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,33 @@ import { configure } from 'mobx'
import React from 'react'
import ReactDOM from 'react-dom'

import AppView from './components/app/view'
import { AppController } from './components/app/controller'
import { AppModel } from './components/app/model'
import { AppNetwork } from './components/app/network'
import { AppView } from './components/app/view'
import { installChart } from './components/chart/install'
import { installDashboard } from './components/dashboard/install'
import { installLocalisation } from './components/localisation/install'
import { withRobotSelectorMenuBar } from './components/menu_bar/view'
import { installVision } from './components/vision/install'
import { installVisualMesh } from './components/visual_mesh/install'
import { NavigationConfiguration } from './navigation'
import { NUsightNetwork } from './network/nusight_network'

const nav = NavigationConfiguration.of()
const appModel = AppModel.of()
const nusightNetwork = NUsightNetwork.of(appModel)
nusightNetwork.connect({ name: 'nusight' })

const appController = AppController.of()
AppNetwork.of(nusightNetwork, appModel)
const menu = withRobotSelectorMenuBar(appModel.robots, appController.toggleRobotEnabled)

installDashboard({ nav, appModel, nusightNetwork, menu })
installLocalisation({ nav, appModel, nusightNetwork, menu })
installChart({ nav, appModel, nusightNetwork, menu })
installVision({ nav, appModel, nusightNetwork, Menu: menu })
installVisualMesh({ nav, appModel, nusightNetwork, Menu: menu })

configure({ enforceActions: 'observed' })
ReactDOM.render(<AppView/>, document.getElementById('root'))
ReactDOM.render(<AppView nav={nav}/>, document.getElementById('root'))
2 changes: 0 additions & 2 deletions src/server/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import favicon from 'serve-favicon'
import sio from 'socket.io'
import webpack from 'webpack'
import webpackDevMiddleware from 'webpack-dev-middleware'
import webpackHotMiddleware from 'webpack-hot-middleware'

import webpackConfig from '../../webpack.config'
import * as NUClearNetProxyParser from '../shared/nuclearnet/nuclearnet_proxy_parser'
Expand Down Expand Up @@ -52,7 +51,6 @@ app.use(compression())
app.use(devMiddleware)
app.use(history())
app.use(devMiddleware)
app.use(webpackHotMiddleware(compiler))
app.use(favicon(`${__dirname}/../assets/favicon.ico`))

const port = process.env.PORT || 3000
Expand Down
6 changes: 1 addition & 5 deletions webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ const config: webpack.Configuration = {
context: sourcePath,
devtool: isContinuousIntegration ? false : isProduction ? 'source-map' : 'eval-source-map',
entry: {
main: [
'./client/main.tsx',
...(isProduction ? [] : ['webpack-hot-middleware/client?reload=true']),
],
main: './client/main.tsx',
},
output: {
path: outPath,
Expand Down Expand Up @@ -146,7 +143,6 @@ const config: webpack.Configuration = {
filename: 'index.html',
chunks: ['main'],
}),
...(isProduction ? [] : [new webpack.HotModuleReplacementPlugin()]),
] as any as webpack.Plugin[],
node: {
// workaround for webpack-dev-server issue
Expand Down