Unverified Commit 3dc24bbd authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Update waitUntilValid parameters (#13612)

Since the reload function was removed this parameter is no longer needed 💯
parent 7a1724f3
...@@ -168,7 +168,11 @@ export default class HotReloader { ...@@ -168,7 +168,11 @@ export default class HotReloader {
this.previewProps = previewProps this.previewProps = previewProps
} }
async run(req: IncomingMessage, res: ServerResponse, parsedUrl: UrlObject) { public async run(
req: IncomingMessage,
res: ServerResponse,
parsedUrl: UrlObject
) {
// Usually CORS support is not needed for the hot-reloader (this is dev only feature) // Usually CORS support is not needed for the hot-reloader (this is dev only feature)
// With when the app runs for multi-zones support behind a proxy, // With when the app runs for multi-zones support behind a proxy,
// the current page is trying to access this URL via assetPrefix. // the current page is trying to access this URL via assetPrefix.
...@@ -246,11 +250,11 @@ export default class HotReloader { ...@@ -246,11 +250,11 @@ export default class HotReloader {
return { finished } return { finished }
} }
async clean(): Promise<void> { private async clean(): Promise<void> {
return recursiveDelete(join(this.dir, this.config.distDir), /^cache/) return recursiveDelete(join(this.dir, this.config.distDir), /^cache/)
} }
async getWebpackConfig() { private async getWebpackConfig() {
const pagePaths = await Promise.all([ const pagePaths = await Promise.all([
findPageFile(this.pagesDir, '/_app', this.config.pageExtensions), findPageFile(this.pagesDir, '/_app', this.config.pageExtensions),
findPageFile(this.pagesDir, '/_document', this.config.pageExtensions), findPageFile(this.pagesDir, '/_document', this.config.pageExtensions),
...@@ -302,7 +306,7 @@ export default class HotReloader { ...@@ -302,7 +306,7 @@ export default class HotReloader {
]) ])
} }
async start(): Promise<void> { public async start(): Promise<void> {
await this.clean() await this.clean()
const configs = await this.getWebpackConfig() const configs = await this.getWebpackConfig()
...@@ -319,7 +323,7 @@ export default class HotReloader { ...@@ -319,7 +323,7 @@ export default class HotReloader {
] = ((await this.waitUntilValid()) as any).stats ] = ((await this.waitUntilValid()) as any).stats
} }
async stop( public async stop(
webpackDevMiddleware?: WebpackDevMiddleware.WebpackDevMiddleware webpackDevMiddleware?: WebpackDevMiddleware.WebpackDevMiddleware
): Promise<void> { ): Promise<void> {
const middleware = webpackDevMiddleware || this.webpackDevMiddleware const middleware = webpackDevMiddleware || this.webpackDevMiddleware
...@@ -333,7 +337,7 @@ export default class HotReloader { ...@@ -333,7 +337,7 @@ export default class HotReloader {
} }
} }
assignBuildTools({ private assignBuildTools({
webpackDevMiddleware, webpackDevMiddleware,
webpackHotMiddleware, webpackHotMiddleware,
onDemandEntries, onDemandEntries,
...@@ -359,7 +363,7 @@ export default class HotReloader { ...@@ -359,7 +363,7 @@ export default class HotReloader {
] ]
} }
async prepareBuildTools(multiCompiler: webpack.MultiCompiler) { private async prepareBuildTools(multiCompiler: webpack.MultiCompiler) {
watchCompilers(multiCompiler.compilers[0], multiCompiler.compilers[1]) watchCompilers(multiCompiler.compilers[0], multiCompiler.compilers[1])
// This plugin watches for changes to _document.js and notifies the client side that it should reload the page // This plugin watches for changes to _document.js and notifies the client side that it should reload the page
...@@ -502,16 +506,13 @@ export default class HotReloader { ...@@ -502,16 +506,13 @@ export default class HotReloader {
} }
} }
waitUntilValid( private waitUntilValid(): Promise<webpack.Stats> {
webpackDevMiddleware?: WebpackDevMiddleware.WebpackDevMiddleware
): Promise<webpack.Stats> {
const middleware = webpackDevMiddleware || this.webpackDevMiddleware
return new Promise((resolve) => { return new Promise((resolve) => {
middleware!.waitUntilValid(resolve) this.webpackDevMiddleware!.waitUntilValid(resolve)
}) })
} }
async getCompilationErrors(page: string) { public async getCompilationErrors(page: string) {
const normalizedPage = normalizePage(page) const normalizedPage = normalizePage(page)
if (this.stats.hasErrors()) { if (this.stats.hasErrors()) {
...@@ -537,11 +538,11 @@ export default class HotReloader { ...@@ -537,11 +538,11 @@ export default class HotReloader {
return [] return []
} }
send = (action: string, ...args: any[]): void => { private send(action: string, ...args: any[]): void {
this.webpackHotMiddleware!.publish({ action, data: args }) this.webpackHotMiddleware!.publish({ action, data: args })
} }
async ensurePage(page: string) { public async ensurePage(page: string) {
// Make sure we don't re-build or dispose prebuilt pages // Make sure we don't re-build or dispose prebuilt pages
if (page !== '/_error' && BLOCKED_PAGES.indexOf(page) !== -1) { if (page !== '/_error' && BLOCKED_PAGES.indexOf(page) !== -1) {
return return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment