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

Rename page -> entry in on-demand-entry-handler #39564

Merged
merged 2 commits into from Aug 12, 2022
Merged
Changes from 1 commit
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
37 changes: 17 additions & 20 deletions packages/next/server/dev/on-demand-entry-handler.ts
Expand Up @@ -398,34 +398,34 @@ export function onDemandEntryHandler({
const isInsideAppDir =
appDir && pagePathData.absolutePagePath.startsWith(appDir)

const addPageEntry = (
const addEntry = (
compilerType: CompilerNameValues
): {
pageKey: string
entryKey: string
newEntry: boolean
shouldInvalidate: boolean
} => {
const pageKey = `${compilerType}${pagePathData.page}`
const entryKey = `${compilerType}${pagePathData.page}`

if (entries[pageKey]) {
entries[pageKey].dispose = false
entries[pageKey].lastActiveTime = Date.now()
if (entries[pageKey].status === BUILT) {
if (entries[entryKey]) {
entries[entryKey].dispose = false
entries[entryKey].lastActiveTime = Date.now()
if (entries[entryKey].status === BUILT) {
return {
pageKey,
entryKey,
newEntry: false,
shouldInvalidate: false,
}
}

return {
pageKey,
entryKey,
newEntry: false,
shouldInvalidate: true,
}
}

entries[pageKey] = {
entries[entryKey] = {
type: EntryTypes.ENTRY,
absolutePagePath: pagePathData.absolutePagePath,
request: pagePathData.absolutePagePath,
Expand All @@ -436,7 +436,7 @@ export function onDemandEntryHandler({
}

return {
pageKey,
entryKey: entryKey,
newEntry: true,
shouldInvalidate: true,
}
Expand All @@ -447,10 +447,7 @@ export function onDemandEntryHandler({
nextConfig,
})

const added = new Map<
CompilerNameValues,
ReturnType<typeof addPageEntry>
>()
const added = new Map<CompilerNameValues, ReturnType<typeof addEntry>>()

await runDependingOnPageType({
page: pagePathData.page,
Expand All @@ -460,15 +457,15 @@ export function onDemandEntryHandler({
if (isServerComponent || isInsideAppDir) {
return
}
added.set(COMPILER_NAMES.client, addPageEntry(COMPILER_NAMES.client))
added.set(COMPILER_NAMES.client, addEntry(COMPILER_NAMES.client))
},
onServer: () => {
added.set(COMPILER_NAMES.server, addPageEntry(COMPILER_NAMES.server))
added.set(COMPILER_NAMES.server, addEntry(COMPILER_NAMES.server))
},
onEdgeServer: () => {
added.set(
COMPILER_NAMES.edgeServer,
addPageEntry(COMPILER_NAMES.edgeServer)
addEntry(COMPILER_NAMES.edgeServer)
)
},
})
Expand All @@ -489,9 +486,9 @@ export function onDemandEntryHandler({

if (entriesThatShouldBeInvalidated.length > 0) {
const invalidatePromises = entriesThatShouldBeInvalidated.map(
({ pageKey }) => {
({ entryKey }) => {
return new Promise<void>((resolve, reject) => {
doneCallbacks!.once(pageKey, (err: Error) => {
doneCallbacks!.once(entryKey, (err: Error) => {
if (err) {
return reject(err)
}
Expand Down