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