Skip to content

Commit

Permalink
Load the hot-reloader when only needed. (vercel#2566)
Browse files Browse the repository at this point in the history
This reduce the server boot-up time a lot.
With a 2015 MacBook Pro, it went down from 1000ms to 200ms
  • Loading branch information
arunoda authored and rauchg committed Jul 15, 2017
1 parent 20db38e commit f25055c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 12,6 @@ import {
renderScriptError
} from './render'
import Router from './router'
import HotReloader from './hot-reloader'
import { resolveFromList } from './resolve'
import { getAvailableChunks } from './utils'
import getConfig from './config'
Expand All @@ -35,7 34,7 @@ export default class Server {
this.dev = dev
this.quiet = quiet
this.router = new Router()
this.hotReloader = dev ? new HotReloader(this.dir, { quiet, conf }) : null
this.hotReloader = dev ? this.getHotReloader(this.dir, { quiet, conf }) : null
this.http = null
this.config = getConfig(this.dir, conf)
this.dist = this.config.distDir
Expand All @@ -59,6 58,11 @@ export default class Server {
this.defineRoutes()
}

getHotReloader (dir, options) {
const HotReloader = require('./hot-reloader').default
return new HotReloader(dir, options)
}

handleRequest (req, res, parsedUrl) {
// Parse url if parsedUrl not provided
if (!parsedUrl || typeof parsedUrl !== 'object') {
Expand Down

0 comments on commit f25055c

Please sign in to comment.