Commit c8db3497 authored by Luke Sandberg's avatar Luke Sandberg Committed by Luke Sandberg

simplify types even more

parent 52602936
......@@ -98,9 +98,7 @@ declare const tree: LoaderTree
// These are injected by the loader afterwards.
declare const __next_app_require__: (id: string | number) => unknown
declare const __next_app_load_chunk__: (
id: string | number
) => Promise<unknown> | void
declare const __next_app_load_chunk__: (id: string | number) => void
// We inject the tree and pages here so that we can use them in the route
// module.
......
......@@ -1103,7 +1103,7 @@ const nextAppLoader: AppLoader = async function nextAppLoader() {
tree: treeCodeResult.treeCode,
__next_app_require__: '__webpack_require__',
// all modules are in the entry chunk, so we never actually need to load chunks in webpack
__next_app_load_chunk__: '() => Promise.resolve()',
__next_app_load_chunk__: '() => undefined',
}
)
......
......@@ -227,7 +227,6 @@ import { createServerInsertedMetadata } from './metadata-insertion/create-server
import { getPreviouslyRevalidatedTags } from '../server-utils'
import { executeRevalidates } from '../revalidation-utils'
import {
trackPendingChunkLoad,
trackPendingImport,
trackPendingModules,
} from './module-loading/track-module-loading.external'
......@@ -2195,15 +2194,7 @@ function installGlobalModuleLoadingHandlers(
}
// @ts-expect-error
globalThis.__next_chunk_load__ = (
id: Parameters<typeof instrumented.loadChunk>[0]
) => {
const result = instrumented.loadChunk(id)
if (shouldTrackModuleLoading()) {
trackPendingChunkLoad(result)
}
return result
}
globalThis.__next_chunk_load__ = instrumented.loadChunk
}
async function renderToHTMLOrFlightImpl(
......
......@@ -3,9 +3,8 @@
// and helpers used in transformed page code (which register pending imports)
import {
trackPendingChunkLoad,
trackPendingImport,
trackPendingModules,
} from './track-module-loading.instance' with { 'turbopack-transition': 'next-shared' }
export { trackPendingChunkLoad, trackPendingImport, trackPendingModules }
export { trackPendingImport, trackPendingModules }
......@@ -13,14 +13,6 @@ function getModuleLoadingSignal() {
return _moduleLoadingSignal
}
export function trackPendingChunkLoad(promiseOrVoid: Promise<unknown> | void) {
// On Node.js with Turbopack, chunk loading is synchronous and returns void.
// Only track when we have an actual promise.
if (!promiseOrVoid) return
const moduleLoadingSignal = getModuleLoadingSignal()
moduleLoadingSignal.trackRead(promiseOrVoid)
}
export function trackPendingImport(exportsOrPromise: unknown) {
const moduleLoadingSignal = getModuleLoadingSignal()
......
......@@ -29,18 +29,8 @@ export function wrapClientComponentLoader(
},
loadChunk: (id) => {
const startTime = performance.now()
const result = ComponentMod.__next_app__.loadChunk(id)
if (result) {
// Avoid wrapping `loadChunk`'s result in an extra promise in case something like React depends on its identity.
// We only need to know when it's settled.
result.finally(() => {
clientComponentLoadTimes += performance.now() - startTime
})
} else {
// Synchronous chunk load (e.g. Node.js Turbopack runtime)
clientComponentLoadTimes += performance.now() - startTime
}
return result
ComponentMod.__next_app__.loadChunk(id)
clientComponentLoadTimes += performance.now() - startTime
},
}
}
......
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