Unverified Commit 2b57edc6 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Add spans for hot-reloader start (#29251)

parent e90825ad
...@@ -263,53 +263,81 @@ export default class HotReloader { ...@@ -263,53 +263,81 @@ export default class HotReloader {
return { finished } return { finished }
} }
private async clean(): Promise<void> { private async clean(span: Span): Promise<void> {
return recursiveDelete(join(this.dir, this.config.distDir), /^cache/) return span
.traceChild('clean')
.traceAsyncFn(() =>
recursiveDelete(join(this.dir, this.config.distDir), /^cache/)
)
} }
private async getWebpackConfig() { private async getWebpackConfig(span: Span) {
const pagePaths = await Promise.all([ const webpackConfigSpan = span.traceChild('get-webpack-config')
findPageFile(this.pagesDir, '/_app', this.config.pageExtensions),
findPageFile(this.pagesDir, '/_document', this.config.pageExtensions), return webpackConfigSpan.traceAsyncFn(async () => {
]) const pagePaths = await webpackConfigSpan
.traceChild('get-page-paths')
const pages = createPagesMapping( .traceAsyncFn(() =>
pagePaths.filter((i) => i !== null) as string[], Promise.all([
this.config.pageExtensions, findPageFile(this.pagesDir, '/_app', this.config.pageExtensions),
this.isWebpack5, findPageFile(
true this.pagesDir,
) '/_document',
const entrypoints = createEntrypoints( this.config.pageExtensions
pages, ),
'server', ])
this.buildId, )
this.previewProps,
this.config,
[]
)
return Promise.all([ const pages = webpackConfigSpan
getBaseWebpackConfig(this.dir, { .traceChild('create-pages-mapping')
dev: true, .traceFn(() =>
isServer: false, createPagesMapping(
config: this.config, pagePaths.filter((i) => i !== null) as string[],
buildId: this.buildId, this.config.pageExtensions,
pagesDir: this.pagesDir, this.isWebpack5,
rewrites: this.rewrites, true
entrypoints: entrypoints.client, )
runWebpackSpan: this.hotReloaderSpan, )
}), const entrypoints = webpackConfigSpan
getBaseWebpackConfig(this.dir, { .traceChild('create-entrypoints')
dev: true, .traceFn(() =>
isServer: true, createEntrypoints(
config: this.config, pages,
buildId: this.buildId, 'server',
pagesDir: this.pagesDir, this.buildId,
rewrites: this.rewrites, this.previewProps,
entrypoints: entrypoints.server, this.config,
runWebpackSpan: this.hotReloaderSpan, []
}), )
]) )
return webpackConfigSpan
.traceChild('generate-webpack-config')
.traceAsyncFn(() =>
Promise.all([
getBaseWebpackConfig(this.dir, {
dev: true,
isServer: false,
config: this.config,
buildId: this.buildId,
pagesDir: this.pagesDir,
rewrites: this.rewrites,
entrypoints: entrypoints.client,
runWebpackSpan: this.hotReloaderSpan,
}),
getBaseWebpackConfig(this.dir, {
dev: true,
isServer: true,
config: this.config,
buildId: this.buildId,
pagesDir: this.pagesDir,
rewrites: this.rewrites,
entrypoints: entrypoints.server,
runWebpackSpan: this.hotReloaderSpan,
}),
])
)
})
} }
public async buildFallbackError(): Promise<void> { public async buildFallbackError(): Promise<void> {
...@@ -359,9 +387,12 @@ export default class HotReloader { ...@@ -359,9 +387,12 @@ export default class HotReloader {
} }
public async start(): Promise<void> { public async start(): Promise<void> {
await this.clean() const startSpan = this.hotReloaderSpan.traceChild('start')
startSpan.stop() // Stop immediately to create an artificial parent span
await this.clean(startSpan)
const configs = await this.getWebpackConfig() const configs = await this.getWebpackConfig(startSpan)
for (const config of configs) { for (const config of configs) {
const defaultEntry = config.entry const defaultEntry = config.entry
......
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