Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor code #43291

Merged
merged 1 commit into from Nov 23, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 0 additions & 16 deletions packages/next/build/output/index.ts
Expand Up @@ -11,10 +11,6 @@ export function startedDevelopmentServer(appUrl: string, bindAddr: string) {
consoleStore.setState({ appUrl, bindAddr })
}

let previousClient: webpack.Compiler | null = null
let previousServer: webpack.Compiler | null = null
let previousEdgeServer: webpack.Compiler | null = null

type CompilerDiagnostics = {
modules: number
errors: string[] | null
Expand Down Expand Up @@ -223,14 +219,6 @@ export function watchCompilers(
server: webpack.Compiler,
edgeServer: webpack.Compiler
) {
if (
previousClient === client &&
previousServer === server &&
previousEdgeServer === edgeServer
) {
return
}

buildStore.setState({
client: { loading: true },
server: { loading: true },
Expand Down Expand Up @@ -317,10 +305,6 @@ export function watchCompilers(
})
}
})

previousClient = client
previousServer = server
previousEdgeServer = edgeServer
}

export function reportTrigger(trigger: string) {
Expand Down
25 changes: 9 additions & 16 deletions packages/next/server/dev/hot-reloader.ts
Expand Up @@ -537,20 +537,19 @@ export default class HotReloader {
})
}

public async start(initial?: boolean): Promise<void> {
public async start(): Promise<void> {
const startSpan = this.hotReloaderSpan.traceChild('start')
startSpan.stop() // Stop immediately to create an artificial parent span

if (initial) {
await this.clean(startSpan)
// Ensure distDir exists before writing package.json
await fs.mkdir(this.distDir, { recursive: true })
await this.clean(startSpan)
// Ensure distDir exists before writing package.json
await fs.mkdir(this.distDir, { recursive: true })

const distPackageJsonPath = join(this.distDir, 'package.json')
// Ensure commonjs handling is used for files in the distDir (generally .next)
// Files outside of the distDir can be "type": "module"
await fs.writeFile(distPackageJsonPath, '{"type": "commonjs"}')

const distPackageJsonPath = join(this.distDir, 'package.json')
// Ensure commonjs handling is used for files in the distDir (generally .next)
// Files outside of the distDir can be "type": "module"
await fs.writeFile(distPackageJsonPath, '{"type": "commonjs"}')
}
this.activeConfigs = await this.getWebpackConfig(startSpan)

for (const config of this.activeConfigs) {
Expand Down Expand Up @@ -1024,12 +1023,6 @@ export default class HotReloader {
edgeServerStats: () => this.edgeServerStats,
}),
]

// trigger invalidation to ensure any previous callbacks
// are handled in the on-demand-entry-handler
if (!initial) {
this.invalidate()
}
}

public invalidate() {
Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/dev/next-dev-server.ts
Expand Up @@ -713,7 +713,7 @@ export default class DevServer extends Server {
})
await super.prepare()
await this.addExportPathMapRoutes()
await this.hotReloader.start(true)
await this.hotReloader.start()
await this.startWatcher()
this.setDevReady!()

Expand Down