Skip to content

Commit

Permalink
Clarify name of configs
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Aug 27, 2023
1 parent b68c636 commit e1e47f7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/next/src/server/dev/hot-reloader-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type getBaseWebpackConfig from '../../build/webpack-config'
import type { RouteMatch } from '../future/route-matches/route-match'

export interface NextJsHotReloaderInterface {
activeConfigs?: Array<Awaited<ReturnType<typeof getBaseWebpackConfig>>>
activeWebpackConfigs?: Array<Awaited<ReturnType<typeof getBaseWebpackConfig>>>
serverStats: webpack.Stats | null
edgeServerStats: webpack.Stats | null
run(
Expand Down
12 changes: 6 additions & 6 deletions packages/next/src/server/dev/hot-reloader-webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export default class HotReloader implements NextJsHotReloaderInterface {
public serverStats: webpack.Stats | null
public edgeServerStats: webpack.Stats | null
public multiCompiler?: webpack.MultiCompiler
public activeConfigs?: Array<
public activeWebpackConfigs?: Array<
UnwrapPromise<ReturnType<typeof getBaseWebpackConfig>>
>

Expand Down Expand Up @@ -721,9 +721,9 @@ export default class HotReloader implements NextJsHotReloaderInterface {
// Files outside of the distDir can be "type": "module"
await fs.writeFile(distPackageJsonPath, '{"type": "commonjs"}')

this.activeConfigs = await this.getWebpackConfig(startSpan)
this.activeWebpackConfigs = await this.getWebpackConfig(startSpan)

for (const config of this.activeConfigs) {
for (const config of this.activeWebpackConfigs) {
const defaultEntry = config.entry
config.entry = async (...args) => {
const outputPath = this.multiCompiler?.outputPath || ''
Expand Down Expand Up @@ -995,10 +995,10 @@ export default class HotReloader implements NextJsHotReloaderInterface {

// Enable building of client compilation before server compilation in development
// @ts-ignore webpack 5
this.activeConfigs.parallelism = 1
this.activeWebpackConfigs.parallelism = 1

this.multiCompiler = webpack(
this.activeConfigs
this.activeWebpackConfigs
) as unknown as webpack.MultiCompiler

// Copy over the filesystem so that it is shared between all compilers.
Expand Down Expand Up @@ -1359,7 +1359,7 @@ export default class HotReloader implements NextJsHotReloaderInterface {
this.watcher = await new Promise((resolve) => {
const watcher = this.multiCompiler?.watch(
// @ts-ignore webpack supports an array of watchOptions when using a multiCompiler
this.activeConfigs.map((config) => config.watchOptions!),
this.activeWebpackConfigs.map((config) => config.watchOptions!),
// Errors are handled separately
(_err: any) => {
if (!booted) {
Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/server/lib/router-utils/setup-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ async function startWatcher(opts: SetupOpts) {
await writeOtherManifests()

const turbopackHotReloader: NextJsHotReloaderInterface = {
activeConfigs: undefined,
activeWebpackConfigs: undefined,
serverStats: null,
edgeServerStats: null,
async run(req, _res, _parsedUrl) {
Expand Down Expand Up @@ -1199,7 +1199,7 @@ async function startWatcher(opts: SetupOpts) {
}
}

hotReloader.activeConfigs?.forEach((config, idx) => {
hotReloader.activeWebpackConfigs?.forEach((config, idx) => {
const isClient = idx === 0
const isNodeServer = idx === 1
const isEdgeServer = idx === 2
Expand Down

0 comments on commit e1e47f7

Please sign in to comment.