Unverified Commit 91d09bba authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

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

Given that it's not just pages now I've renamed the entry handling.


## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
parent 6ff05b68
...@@ -398,34 +398,34 @@ export function onDemandEntryHandler({ ...@@ -398,34 +398,34 @@ export function onDemandEntryHandler({
const isInsideAppDir = const isInsideAppDir =
appDir && pagePathData.absolutePagePath.startsWith(appDir) appDir && pagePathData.absolutePagePath.startsWith(appDir)
const addPageEntry = ( const addEntry = (
compilerType: CompilerNameValues compilerType: CompilerNameValues
): { ): {
pageKey: string entryKey: string
newEntry: boolean newEntry: boolean
shouldInvalidate: boolean shouldInvalidate: boolean
} => { } => {
const pageKey = `${compilerType}${pagePathData.page}` const entryKey = `${compilerType}${pagePathData.page}`
if (entries[pageKey]) { if (entries[entryKey]) {
entries[pageKey].dispose = false entries[entryKey].dispose = false
entries[pageKey].lastActiveTime = Date.now() entries[entryKey].lastActiveTime = Date.now()
if (entries[pageKey].status === BUILT) { if (entries[entryKey].status === BUILT) {
return { return {
pageKey, entryKey,
newEntry: false, newEntry: false,
shouldInvalidate: false, shouldInvalidate: false,
} }
} }
return { return {
pageKey, entryKey,
newEntry: false, newEntry: false,
shouldInvalidate: true, shouldInvalidate: true,
} }
} }
entries[pageKey] = { entries[entryKey] = {
type: EntryTypes.ENTRY, type: EntryTypes.ENTRY,
absolutePagePath: pagePathData.absolutePagePath, absolutePagePath: pagePathData.absolutePagePath,
request: pagePathData.absolutePagePath, request: pagePathData.absolutePagePath,
...@@ -436,7 +436,7 @@ export function onDemandEntryHandler({ ...@@ -436,7 +436,7 @@ export function onDemandEntryHandler({
} }
return { return {
pageKey, entryKey: entryKey,
newEntry: true, newEntry: true,
shouldInvalidate: true, shouldInvalidate: true,
} }
...@@ -447,10 +447,7 @@ export function onDemandEntryHandler({ ...@@ -447,10 +447,7 @@ export function onDemandEntryHandler({
nextConfig, nextConfig,
}) })
const added = new Map< const added = new Map<CompilerNameValues, ReturnType<typeof addEntry>>()
CompilerNameValues,
ReturnType<typeof addPageEntry>
>()
await runDependingOnPageType({ await runDependingOnPageType({
page: pagePathData.page, page: pagePathData.page,
...@@ -460,15 +457,15 @@ export function onDemandEntryHandler({ ...@@ -460,15 +457,15 @@ export function onDemandEntryHandler({
if (isServerComponent || isInsideAppDir) { if (isServerComponent || isInsideAppDir) {
return return
} }
added.set(COMPILER_NAMES.client, addPageEntry(COMPILER_NAMES.client)) added.set(COMPILER_NAMES.client, addEntry(COMPILER_NAMES.client))
}, },
onServer: () => { onServer: () => {
added.set(COMPILER_NAMES.server, addPageEntry(COMPILER_NAMES.server)) added.set(COMPILER_NAMES.server, addEntry(COMPILER_NAMES.server))
}, },
onEdgeServer: () => { onEdgeServer: () => {
added.set( added.set(
COMPILER_NAMES.edgeServer, COMPILER_NAMES.edgeServer,
addPageEntry(COMPILER_NAMES.edgeServer) addEntry(COMPILER_NAMES.edgeServer)
) )
}, },
}) })
...@@ -489,9 +486,9 @@ export function onDemandEntryHandler({ ...@@ -489,9 +486,9 @@ export function onDemandEntryHandler({
if (entriesThatShouldBeInvalidated.length > 0) { if (entriesThatShouldBeInvalidated.length > 0) {
const invalidatePromises = entriesThatShouldBeInvalidated.map( const invalidatePromises = entriesThatShouldBeInvalidated.map(
({ pageKey }) => { ({ entryKey }) => {
return new Promise<void>((resolve, reject) => { return new Promise<void>((resolve, reject) => {
doneCallbacks!.once(pageKey, (err: Error) => { doneCallbacks!.once(entryKey, (err: Error) => {
if (err) { if (err) {
return reject(err) return reject(err)
} }
......
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