From 0f4478df61e55a0535e6a9e4dd727dc928975202 Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Tue, 30 Aug 2022 22:30:54 +0200 Subject: [PATCH 01/11] fix route resolution in next-app-loader --- packages/next/build/entries.ts | 26 ++- packages/next/build/index.ts | 51 +++--- .../build/webpack/loaders/next-app-loader.ts | 159 ++++++++++++------ packages/next/server/base-server.ts | 52 +++--- packages/next/server/dev/hot-reloader.ts | 23 ++- packages/next/server/dev/next-dev-server.ts | 57 ++++--- .../server/dev/on-demand-entry-handler.ts | 16 +- packages/next/server/next-server.ts | 68 +++++--- packages/next/server/web-server.ts | 13 +- .../next/shared/lib/router/utils/app-paths.ts | 4 + .../parallel/(new)/@baz/nested/page.server.js | 3 + .../parallel/@bar/nested/@a/page.server.js | 3 + .../parallel/@bar/nested/@b/page.server.js | 3 + .../app/parallel/@bar/nested/layout.server.js | 16 ++ .../app/app/parallel/@bar/page.server.js | 3 + .../parallel/@foo/nested/@a/page.server.js | 3 + .../parallel/@foo/nested/@b/page.server.js | 3 + .../app/parallel/@foo/nested/layout.server.js | 16 ++ .../app/app/parallel/@foo/page.server.js | 3 + .../app-dir/app/app/parallel/layout.server.js | 21 +++ .../app/app/parallel/nested/page.server.js | 3 + test/e2e/app-dir/app/app/parallel/style.css | 15 ++ 22 files changed, 397 insertions(+), 164 deletions(-) create mode 100644 test/e2e/app-dir/app/app/parallel/(new)/@baz/nested/page.server.js create mode 100644 test/e2e/app-dir/app/app/parallel/@bar/nested/@a/page.server.js create mode 100644 test/e2e/app-dir/app/app/parallel/@bar/nested/@b/page.server.js create mode 100644 test/e2e/app-dir/app/app/parallel/@bar/nested/layout.server.js create mode 100644 test/e2e/app-dir/app/app/parallel/@bar/page.server.js create mode 100644 test/e2e/app-dir/app/app/parallel/@foo/nested/@a/page.server.js create mode 100644 test/e2e/app-dir/app/app/parallel/@foo/nested/@b/page.server.js create mode 100644 test/e2e/app-dir/app/app/parallel/@foo/nested/layout.server.js create mode 100644 test/e2e/app-dir/app/app/parallel/@foo/page.server.js create mode 100644 test/e2e/app-dir/app/app/parallel/layout.server.js create mode 100644 test/e2e/app-dir/app/app/parallel/nested/page.server.js create mode 100644 test/e2e/app-dir/app/app/parallel/style.css diff --git a/packages/next/build/entries.ts b/packages/next/build/entries.ts index 210c7226c34d..e23970bd6f01 100644 --- a/packages/next/build/entries.ts +++ b/packages/next/build/entries.ts @@ -42,6 +42,7 @@ import { normalizePathSep } from '../shared/lib/page-path/normalize-path-sep' import { normalizePagePath } from '../shared/lib/page-path/normalize-page-path' import { serverComponentRegex } from './webpack/loaders/utils' import { ServerRuntime } from '../types' +import { normalizeAppPath } from '../shared/lib/router/utils/app-paths' type ObjectValue = T extends { [key: string]: infer V } ? V : never @@ -144,6 +145,7 @@ interface CreateEntrypointsParams { envFiles: LoadedEnvFiles isDev?: boolean pages: { [page: string]: string } + appPathsPerRoute?: { [route: string]: string[] } pagesDir: string previewMode: __ApiPreviewProps rootDir: string @@ -219,6 +221,7 @@ export function getAppEntry(opts: { name: string pagePath: string appDir: string + appPaths: string[] | null pageExtensions: string[] }) { return { @@ -335,6 +338,7 @@ export async function createEntrypoints(params: CreateEntrypointsParams) { config, pages, pagesDir, + appPathsPerRoute = {}, isDev, rootDir, rootPaths, @@ -425,10 +429,12 @@ export async function createEntrypoints(params: CreateEntrypointsParams) { }, onServer: () => { if (pagesType === 'app' && appDir) { + const matchedAppPaths = appPathsPerRoute[normalizeAppPath(page)] server[serverBundlePath] = getAppEntry({ name: serverBundlePath, pagePath: mappings[page], appDir, + appPaths: matchedAppPaths, pageExtensions, }) } else if (isTargetLikeServerless(target)) { @@ -449,15 +455,17 @@ export async function createEntrypoints(params: CreateEntrypointsParams) { } }, onEdgeServer: () => { - const appDirLoader = - pagesType === 'app' - ? getAppEntry({ - name: serverBundlePath, - pagePath: mappings[page], - appDir: appDir!, - pageExtensions, - }).import - : '' + let appDirLoader: string = '' + if (pagesType === 'app') { + const matchedAppPaths = appPathsPerRoute[normalizeAppPath(page)] + appDirLoader = getAppEntry({ + name: serverBundlePath, + pagePath: mappings[page], + appDir: appDir!, + appPaths: matchedAppPaths, + pageExtensions, + }).import + } edgeServer[serverBundlePath] = getEdgeServerEntry({ ...params, diff --git a/packages/next/build/index.ts b/packages/next/build/index.ts index 3a24961a3fca..03b1bb052717 100644 --- a/packages/next/build/index.ts +++ b/packages/next/build/index.ts @@ -517,6 +517,35 @@ export default async function build( }) } + const serverDir = isLikeServerless + ? SERVERLESS_DIRECTORY + : SERVER_DIRECTORY + + let appPathsPerRoute: Record = {} + if (appDir) { + const appPathsManifest = JSON.parse( + await promises.readFile( + path.join(distDir, serverDir, APP_PATHS_MANIFEST), + 'utf8' + ) + ) + const appPathRoutes: Record = {} + + Object.keys(appPathsManifest).forEach((entry) => { + const normalizedPath = normalizeAppPath(entry) || '/' + appPathRoutes[entry] = normalizedPath + if (!appPathsPerRoute[normalizedPath]) { + appPathsPerRoute[normalizedPath] = [] + } + appPathsPerRoute[normalizedPath].push(entry) + }) + + await promises.writeFile( + path.join(distDir, APP_PATH_ROUTES_MANIFEST), + JSON.stringify(appPathRoutes, null, 2) + ) + } + const entrypoints = await nextBuildSpan .traceChild('create-entrypoints') .traceAsyncFn(() => @@ -526,6 +555,7 @@ export default async function build( envFiles: loadedEnvFiles, isDev: false, pages: mappedPages, + appPathsPerRoute, pagesDir, previewMode: previewProps, target, @@ -780,9 +810,6 @@ export default async function build( ) ) - const serverDir = isLikeServerless - ? SERVERLESS_DIRECTORY - : SERVER_DIRECTORY const manifestPath = path.join(distDir, serverDir, PAGES_MANIFEST) const requiredServerFiles = nextBuildSpan @@ -1791,24 +1818,6 @@ export default async function build( 'utf8' ) - if (appDir) { - const appPathsManifest = JSON.parse( - await promises.readFile( - path.join(distDir, serverDir, APP_PATHS_MANIFEST), - 'utf8' - ) - ) - const appPathRoutes: Record = {} - - Object.keys(appPathsManifest).forEach((entry) => { - appPathRoutes[entry] = normalizeAppPath(entry) || '/' - }) - await promises.writeFile( - path.join(distDir, APP_PATH_ROUTES_MANIFEST), - JSON.stringify(appPathRoutes, null, 2) - ) - } - const middlewareManifest: MiddlewareManifest = JSON.parse( await promises.readFile( path.join(distDir, serverDir, MIDDLEWARE_MANIFEST), diff --git a/packages/next/build/webpack/loaders/next-app-loader.ts b/packages/next/build/webpack/loaders/next-app-loader.ts index bf7a405e1913..e0ce2c6bbcb8 100644 --- a/packages/next/build/webpack/loaders/next-app-loader.ts +++ b/packages/next/build/webpack/loaders/next-app-loader.ts @@ -5,86 +5,109 @@ import { getModuleBuildInfo } from './get-module-build-info' async function createTreeCodeFromPath({ pagePath, resolve, - removeExt, + resolveParallelSegments, }: { pagePath: string resolve: (pathname: string) => Promise - removeExt: (pathToRemoveExtensions: string) => string + resolveParallelSegments: (pathname: string) => string[] }) { - let tree: undefined | string const splittedPath = pagePath.split(/[\\/]/) const appDirPrefix = splittedPath[0] - const segments = ['', ...splittedPath.slice(1)] - - // segment.length - 1 because arrays start at 0 and we're decrementing - for (let i = segments.length - 1; i >= 0; i--) { - const segment = removeExt(segments[i]) - const segmentPath = segments.slice(0, i + 1).join('/') - - // First item in the list is the page which can't have layouts by itself - if (i === segments.length - 1) { - const resolvedPagePath = await resolve(pagePath) + async function createSubtreePropsFromSegmentPath( + segments: string[] + ): Promise { + const segmentPath = segments.join('/') + + // Last item in the list is the page which can't have layouts by itself + if ( + segments[segments.length - 1] === 'page' || + segments[segments.length - 1]?.endsWith('/page') + ) { + const matchedPagePath = `${appDirPrefix}${segmentPath}` + const resolvedPagePath = await resolve(matchedPagePath) // Use '' for segment as it's the page. There can't be a segment called '' so this is the safest way to add it. - tree = `['', {}, {filePath: ${JSON.stringify( - resolvedPagePath - )}, page: () => require(${JSON.stringify(resolvedPagePath)})}]` - continue + return `{ + children: ${`['', {}, {filePath: ${JSON.stringify( + resolvedPagePath + )}, page: () => require(${JSON.stringify(resolvedPagePath)})}]`} + }` } - // For segmentPath === '' avoid double `/` - const layoutPath = `${appDirPrefix}${segmentPath}/layout` - // For segmentPath === '' avoid double `/` - const loadingPath = `${appDirPrefix}${segmentPath}/loading` - - const resolvedLayoutPath = await resolve(layoutPath) - const resolvedLoadingPath = await resolve(loadingPath) - // Existing tree are the children of the current segment - const children = tree + const props: Record = {} + + // We need to resolve all parallel routes in this level. + const parallelSegments: string[] = [] + if (segments.length === 0) { + parallelSegments.push('') + } else { + parallelSegments.push(...resolveParallelSegments(segmentPath)) + } - tree = `['${segment}', { - ${ - // When there are no children the current index is the page component - children ? `children: ${children},` : '' - } - }, { - filePath: '${resolvedLayoutPath}', - ${ - resolvedLayoutPath - ? `layout: () => require(${JSON.stringify(resolvedLayoutPath)}),` - : '' - } - ${ - resolvedLoadingPath - ? `loading: () => require(${JSON.stringify(resolvedLoadingPath)}),` - : '' - } - }]` + for (const parallelSegment of parallelSegments) { + const parallelSegmentPath = segmentPath + '/' + parallelSegment + const subtree = await createSubtreePropsFromSegmentPath([ + ...segments, + parallelSegment, + ]) + + // For segmentPath === '' avoid double `/` + const layoutPath = `${appDirPrefix}${parallelSegmentPath}/layout` + // For segmentPath === '' avoid double `/` + const loadingPath = `${appDirPrefix}${parallelSegmentPath}/loading` + + const resolvedLayoutPath = await resolve(layoutPath) + const resolvedLoadingPath = await resolve(loadingPath) + + const matchedSlot = parallelSegment.match(/@(.+)/) + const segmentKey = matchedSlot ? matchedSlot[1] : 'children' + + props[segmentKey] = `[ + '${parallelSegment}', + ${subtree}, + { + filePath: ${JSON.stringify(resolvedLayoutPath)}, + ${ + resolvedLayoutPath + ? `layout: () => require(${JSON.stringify(resolvedLayoutPath)}),` + : '' + } + ${ + resolvedLoadingPath + ? `loading: () => require(${JSON.stringify( + resolvedLoadingPath + )}),` + : '' + } + } + ]` + } + + return `{ + ${Object.entries(props) + .map(([key, value]) => `${key}: ${value}`) + .join(',\n')} + }` } - return `const tree = ${tree};` + const tree = await createSubtreePropsFromSegmentPath([]) + return `const tree = ${tree}.children;` } function createAbsolutePath(appDir: string, pathToTurnAbsolute: string) { return pathToTurnAbsolute.replace(/^private-next-app-dir/, appDir) } -function removeExtensions( - extensions: string[], - pathToRemoveExtensions: string -) { - const regex = new RegExp(`(${extensions.join('|')})$`.replace(/\./g, '\\.')) - return pathToRemoveExtensions.replace(regex, '') -} - const nextAppLoader: webpack.LoaderDefinitionFunction<{ name: string pagePath: string appDir: string + appPaths: string[] | null pageExtensions: string[] }> = async function nextAppLoader() { - const { name, appDir, pagePath, pageExtensions } = this.getOptions() || {} + const { name, appDir, appPaths, pagePath, pageExtensions } = + this.getOptions() || {} const buildInfo = getModuleBuildInfo((this as any)._module) buildInfo.route = { @@ -99,6 +122,32 @@ const nextAppLoader: webpack.LoaderDefinitionFunction<{ } const resolve = this.getResolve(resolveOptions) + const resolveParallelSegments = (pathname: string) => { + const matched = new Set() + for (const path of appPaths || []) { + if (path.startsWith(pathname + '/')) { + const restPath = path.slice(pathname.length + 1) + + const pathSegments = restPath.split('/') + let matchedSegments = '' + for (const segment of pathSegments) { + if (matchedSegments) { + matchedSegments += '/' + } + if (segment.startsWith('(')) { + // Include all prefixed (...) segments. + matchedSegments += segment + } else { + matchedSegments += segment + break + } + } + matched.add(matchedSegments) + } + } + return Array.from(matched) + } + const resolver = async (pathname: string) => { try { const resolved = await resolve(this.rootContext, pathname) @@ -120,7 +169,7 @@ const nextAppLoader: webpack.LoaderDefinitionFunction<{ const treeCode = await createTreeCodeFromPath({ pagePath, resolve: resolver, - removeExt: (p) => removeExtensions(extensions, p), + resolveParallelSegments, }) const result = ` diff --git a/packages/next/server/base-server.ts b/packages/next/server/base-server.ts index df3413e07faf..2c0c9783f086 100644 --- a/packages/next/server/base-server.ts +++ b/packages/next/server/base-server.ts @@ -217,7 +217,7 @@ export default abstract class Server { private responseCache: ResponseCacheBase protected router: Router protected dynamicRoutes?: DynamicRoutes - protected appPathRoutes?: Record + protected appPathRoutes?: Record protected customRoutes: CustomRoutes protected serverComponentManifest?: any protected serverCSSManifest?: any @@ -231,12 +231,13 @@ export default abstract class Server { protected abstract getBuildId(): string protected abstract getFilesystemPaths(): Set - protected abstract findPageComponents( - pathname: string, - query?: NextParsedUrlQuery, - params?: Params, + protected abstract findPageComponents(params: { + pathname: string + query?: NextParsedUrlQuery + params?: Params isAppDir?: boolean - ): Promise + appPaths?: string[] | null + }): Promise protected abstract getFontManifest(): FontManifest | undefined protected abstract getPrerenderManifest(): PrerenderManifest protected abstract getServerComponentManifest(): any @@ -750,11 +751,15 @@ export default abstract class Server { .filter((item): item is RoutingItem => Boolean(item)) } - protected getAppPathRoutes(): Record { - const appPathRoutes: Record = {} + protected getAppPathRoutes(): Record { + const appPathRoutes: Record = {} Object.keys(this.appPathsManifest || {}).forEach((entry) => { - appPathRoutes[normalizeAppPath(entry) || '/'] = entry + const normalizedPath = normalizeAppPath(entry) || '/' + if (!appPathRoutes[normalizedPath]) { + appPathRoutes[normalizedPath] = [] + } + appPathRoutes[normalizedPath].push(entry) }) return appPathRoutes } @@ -1495,7 +1500,7 @@ export default abstract class Server { } // map the route to the actual bundle name - protected getOriginalAppPath(route: string) { + protected getOriginalAppPaths(route: string) { if (this.nextConfig.experimental.appDir) { const originalAppPath = this.appPathRoutes?.[route] @@ -1513,19 +1518,21 @@ export default abstract class Server { bubbleNoFallback: boolean ) { const { query, pathname } = ctx - const appPath = this.getOriginalAppPath(pathname) + const appPaths = this.getOriginalAppPaths(pathname) let page = pathname - if (typeof appPath === 'string') { - page = appPath + if (Array.isArray(appPaths)) { + // When it's an array, we need to pass all parallel routes to the loader. + page = appPaths[0] } - const result = await this.findPageComponents( - page, + const result = await this.findPageComponents({ + pathname: page, query, - ctx.renderOpts.params, - typeof appPath === 'string' - ) + params: ctx.renderOpts.params, + isAppDir: Array.isArray(appPaths), + appPaths, + }) if (result) { try { return await this.renderToResponseWithComponents(ctx, result) @@ -1707,7 +1714,7 @@ export default abstract class Server { // use static 404 page if available and is 404 response if (is404 && (await this.hasPage('/404'))) { - result = await this.findPageComponents('/404', query) + result = await this.findPageComponents({ pathname: '/404', query }) using404Page = result !== null } let statusPage = `/${res.statusCode}` @@ -1716,12 +1723,15 @@ export default abstract class Server { // skip ensuring /500 in dev mode as it isn't used and the // dev overlay is used instead if (statusPage !== '/500' || !this.renderOpts.dev) { - result = await this.findPageComponents(statusPage, query) + result = await this.findPageComponents({ + pathname: statusPage, + query, + }) } } if (!result) { - result = await this.findPageComponents('/_error', query) + result = await this.findPageComponents({ pathname: '/_error', query }) statusPage = '/_error' } diff --git a/packages/next/server/dev/hot-reloader.ts b/packages/next/server/dev/hot-reloader.ts index 76aa45105996..e20d0ee7db6c 100644 --- a/packages/next/server/dev/hot-reloader.ts +++ b/packages/next/server/dev/hot-reloader.ts @@ -272,7 +272,7 @@ export default class HotReloader { if (page === '/_error' || BLOCKED_PAGES.indexOf(page) === -1) { try { - await this.ensurePage(page, true) + await this.ensurePage({ page, clientOnly: true }) } catch (error) { await renderScriptError(pageBundleRes, getProperError(error)) return { finished: true } @@ -608,6 +608,7 @@ export default class HotReloader { isApp && this.appDir ? getAppEntry({ name: bundlePath, + appPaths: entryData.appPaths, pagePath: posix.join( APP_DIR_ALIAS, relative( @@ -685,6 +686,7 @@ export default class HotReloader { this.appDir && bundlePath.startsWith('app/') ? getAppEntry({ name: bundlePath, + appPaths: entryData.appPaths, pagePath: posix.join( APP_DIR_ALIAS, relative( @@ -1060,10 +1062,15 @@ export default class HotReloader { ) } - public async ensurePage( - page: string, - clientOnly: boolean = false - ): Promise { + public async ensurePage({ + page, + clientOnly = false, + appPaths, + }: { + page: string + clientOnly?: boolean + appPaths?: string[] | null + }): Promise { // Make sure we don't re-build or dispose prebuilt pages if (page !== '/_error' && BLOCKED_PAGES.indexOf(page) !== -1) { return @@ -1074,6 +1081,10 @@ export default class HotReloader { if (error) { return Promise.reject(error) } - return this.onDemandEntries?.ensurePage(page, clientOnly) as any + return this.onDemandEntries?.ensurePage({ + page, + clientOnly, + appPaths, + }) as any } } diff --git a/packages/next/server/dev/next-dev-server.ts b/packages/next/server/dev/next-dev-server.ts index 461c3b08866b..8a534c1d9049 100644 --- a/packages/next/server/dev/next-dev-server.ts +++ b/packages/next/server/dev/next-dev-server.ts @@ -309,7 +309,7 @@ export default class DevServer extends Server { let middlewareMatcher: RegExp | undefined const routedPages: string[] = [] const knownFiles = wp.getTimeInfoEntries() - const appPaths: Record = {} + const appPaths: Record = {} const edgeRoutesSet = new Set() let envChange = false let tsconfigChange = false @@ -393,7 +393,10 @@ export default class DevServer extends Server { const originalPageName = pageName pageName = normalizeAppPath(pageName) || '/' - appPaths[pageName] = originalPageName + if (!appPaths[pageName]) { + appPaths[pageName] = [] + } + appPaths[pageName].push(originalPageName) if (routedPages.includes(pageName)) { continue @@ -536,14 +539,17 @@ export default class DevServer extends Server { nestedMiddleware = [] } - this.appPathRoutes = appPaths + this.appPathRoutes = Object.fromEntries( + // Make sure to sort parallel routes to make the result deterministic. + Object.entries(appPaths).map(([k, v]) => [k, v.sort()]) + ) this.edgeFunctions = [] const edgeRoutes = Array.from(edgeRoutesSet) getSortedRoutes(edgeRoutes).forEach((page) => { - let appPath = this.getOriginalAppPath(page) + let appPaths = this.getOriginalAppPaths(page) - if (typeof appPath === 'string') { - page = appPath + if (typeof appPaths === 'string') { + page = appPaths } const isRootMiddleware = page === '/' && !!middlewareMatcher @@ -1103,11 +1109,17 @@ export default class DevServer extends Server { } protected async ensureMiddleware() { - return this.hotReloader!.ensurePage(this.actualMiddlewareFile!) + return this.hotReloader!.ensurePage({ page: this.actualMiddlewareFile! }) } - protected async ensureEdgeFunction(pathname: string) { - return this.hotReloader!.ensurePage(pathname) + protected async ensureEdgeFunction({ + page, + appPaths, + }: { + page: string + appPaths: string[] | null + }) { + return this.hotReloader!.ensurePage({ page, appPaths }) } generateRoutes() { @@ -1283,15 +1295,22 @@ export default class DevServer extends Server { } protected async ensureApiPage(pathname: string): Promise { - return this.hotReloader!.ensurePage(pathname) + return this.hotReloader!.ensurePage({ page: pathname }) } - protected async findPageComponents( - pathname: string, - query: ParsedUrlQuery = {}, - params: Params | null = null, - isAppDir: boolean = false - ): Promise { + protected async findPageComponents({ + pathname, + query = {}, + params = null, + isAppDir = false, + appPaths, + }: { + pathname: string + query?: ParsedUrlQuery + params?: Params | null + isAppDir?: boolean + appPaths?: string[] | null + }): Promise { await this.devReady const compilationErr = await this.getCompilationError(pathname) if (compilationErr) { @@ -1299,7 +1318,7 @@ export default class DevServer extends Server { throw new WrappedBuildError(compilationErr) } try { - await this.hotReloader!.ensurePage(pathname) + await this.hotReloader!.ensurePage({ page: pathname, appPaths }) const serverComponents = this.nextConfig.experimental.serverComponents @@ -1310,7 +1329,7 @@ export default class DevServer extends Server { this.serverCSSManifest = super.getServerCSSManifest() } - return super.findPageComponents(pathname, query, params, isAppDir) + return super.findPageComponents({ pathname, query, params, isAppDir }) } catch (err) { if ((err as any).code !== 'ENOENT') { throw err @@ -1323,7 +1342,7 @@ export default class DevServer extends Server { await this.hotReloader!.buildFallbackError() // Build the error page to ensure the fallback is built too. // TODO: See if this can be moved into hotReloader or removed. - await this.hotReloader!.ensurePage('/_error') + await this.hotReloader!.ensurePage({ page: '/_error' }) return await loadDefaultErrorComponents(this.distDir) } diff --git a/packages/next/server/dev/on-demand-entry-handler.ts b/packages/next/server/dev/on-demand-entry-handler.ts index 09570760812f..5d19df6ac477 100644 --- a/packages/next/server/dev/on-demand-entry-handler.ts +++ b/packages/next/server/dev/on-demand-entry-handler.ts @@ -143,6 +143,11 @@ interface Entry extends EntryType { * `/Users/Rick/project/pages/about/index.js` */ absolutePagePath: string + /** + * All parallel pages that match the same entry, for example: + * ['/parallel/@bar/nested/@a/page', '/parallel/@bar/nested/@b/page', '/parallel/@foo/nested/@a/page', '/parallel/@foo/nested/@b/page'] + */ + appPaths: string[] | null } interface ChildEntry extends EntryType { @@ -534,7 +539,15 @@ export function onDemandEntryHandler({ } return { - async ensurePage(page: string, clientOnly: boolean): Promise { + async ensurePage({ + page, + clientOnly, + appPaths = null, + }: { + page: string + clientOnly: boolean + appPaths?: string[] | null + }): Promise { const stalledTime = 60 const stalledEnsureTimeout = setTimeout(() => { debug( @@ -586,6 +599,7 @@ export function onDemandEntryHandler({ entries[entryKey] = { type: EntryTypes.ENTRY, + appPaths, absolutePagePath: pagePathData.absolutePagePath, request: pagePathData.absolutePagePath, bundlePath: pagePathData.bundlePath, diff --git a/packages/next/server/next-server.ts b/packages/next/server/next-server.ts index 2d8e3aac0a33..927699650fc8 100644 --- a/packages/next/server/next-server.ts +++ b/packages/next/server/next-server.ts @@ -811,37 +811,44 @@ export default class NextNodeServer extends BaseServer { ctx: RequestContext, bubbleNoFallback: boolean ) { - const appPath = this.getOriginalAppPath(ctx.pathname) - let page = ctx.pathname - - if (typeof appPath === 'string') { - page = appPath - } - const edgeFunctions = this.getEdgeFunctions() || [] + if (edgeFunctions.length) { + const appPaths = this.getOriginalAppPaths(ctx.pathname) + let page = ctx.pathname - for (const item of edgeFunctions) { - if (item.page === page) { - await this.runEdgeFunction({ - req: ctx.req, - res: ctx.res, - query: ctx.query, - params: ctx.renderOpts.params, - page, - }) - return null + if (Array.isArray(appPaths)) { + // When it's an array, we need to pass all parallel routes to the loader. + page = appPaths[0] + } + + for (const item of edgeFunctions) { + if (item.page === page) { + await this.runEdgeFunction({ + req: ctx.req, + res: ctx.res, + query: ctx.query, + params: ctx.renderOpts.params, + page, + }) + return null + } } } return super.renderPageComponent(ctx, bubbleNoFallback) } - protected async findPageComponents( - pathname: string, - query: NextParsedUrlQuery = {}, - params: Params | null = null, - isAppDir: boolean = false - ): Promise { + protected async findPageComponents({ + pathname, + query = {}, + params = null, + isAppDir = false, + }: { + pathname: string + query?: NextParsedUrlQuery + params?: Params | null + isAppDir?: boolean + }): Promise { let paths = [ // try serving a static AMP version first query.amp ? normalizePagePath(pathname) + '.amp' : null, @@ -1580,7 +1587,10 @@ export default class NextNodeServer extends BaseServer { * so that we can run it. */ protected async ensureMiddleware() {} - protected async ensureEdgeFunction(_pathname: string) {} + protected async ensureEdgeFunction(_params: { + page: string + appPaths: string[] | null + }) {} /** * This method gets all middleware matchers and execute them when the request @@ -1933,13 +1943,15 @@ export default class NextNodeServer extends BaseServer { onWarning?: (warning: Error) => void }): Promise { let middlewareInfo: ReturnType | undefined - let appPath = this.getOriginalAppPath(params.page) + let appPaths = this.getOriginalAppPaths(params.page) - if (typeof appPath === 'string') { - params.page = appPath + if (Array.isArray(appPaths)) { + // When it's an array, we need to pass all parallel routes to the loader. + params.page = appPaths[0] + // params.appPaths = appPaths } - await this.ensureEdgeFunction(params.page) + await this.ensureEdgeFunction({ page: params.page, appPaths }) middlewareInfo = this.getEdgeFunctionInfo({ page: params.page, middleware: false, diff --git a/packages/next/server/web-server.ts b/packages/next/server/web-server.ts index 657b05bbc375..6733caafc64a 100644 --- a/packages/next/server/web-server.ts +++ b/packages/next/server/web-server.ts @@ -406,11 +406,16 @@ export default class NextWebServer extends BaseServer { // @TODO return true } - protected async findPageComponents( - pathname: string, - query?: NextParsedUrlQuery, + protected async findPageComponents({ + pathname, + query, + params, + }: { + pathname: string + query?: NextParsedUrlQuery params?: Params | null - ) { + isAppDir?: boolean + }) { const result = await this.serverOptions.webServerConfig.loadComponent( pathname ) diff --git a/packages/next/shared/lib/router/utils/app-paths.ts b/packages/next/shared/lib/router/utils/app-paths.ts index bf69f05e0902..f48b324d1a6c 100644 --- a/packages/next/shared/lib/router/utils/app-paths.ts +++ b/packages/next/shared/lib/router/utils/app-paths.ts @@ -10,6 +10,10 @@ export function normalizeAppPath(pathname: string) { return acc } + if (segment.startsWith('@')) { + return acc + } + if (segment === 'page' && index === segments.length - 1) { return acc } diff --git a/test/e2e/app-dir/app/app/parallel/(new)/@baz/nested/page.server.js b/test/e2e/app-dir/app/app/parallel/(new)/@baz/nested/page.server.js new file mode 100644 index 000000000000..05c172f81b1f --- /dev/null +++ b/test/e2e/app-dir/app/app/parallel/(new)/@baz/nested/page.server.js @@ -0,0 +1,3 @@ +export default function Page() { + return
parallel/(new)/@baz/nested/page
+} diff --git a/test/e2e/app-dir/app/app/parallel/@bar/nested/@a/page.server.js b/test/e2e/app-dir/app/app/parallel/@bar/nested/@a/page.server.js new file mode 100644 index 000000000000..d1c6fc71e12e --- /dev/null +++ b/test/e2e/app-dir/app/app/parallel/@bar/nested/@a/page.server.js @@ -0,0 +1,3 @@ +export default function Page() { + return
parallel/@bar/nested/@a/page
+} diff --git a/test/e2e/app-dir/app/app/parallel/@bar/nested/@b/page.server.js b/test/e2e/app-dir/app/app/parallel/@bar/nested/@b/page.server.js new file mode 100644 index 000000000000..15ef0b7a3992 --- /dev/null +++ b/test/e2e/app-dir/app/app/parallel/@bar/nested/@b/page.server.js @@ -0,0 +1,3 @@ +export default function Page() { + return
parallel/@bar/nested/@b/page
+} diff --git a/test/e2e/app-dir/app/app/parallel/@bar/nested/layout.server.js b/test/e2e/app-dir/app/app/parallel/@bar/nested/layout.server.js new file mode 100644 index 000000000000..4ba7b399385d --- /dev/null +++ b/test/e2e/app-dir/app/app/parallel/@bar/nested/layout.server.js @@ -0,0 +1,16 @@ +export default function Parallel({ a, b, children }) { + return ( +
+ parallel/@bar/nested/layout +
+ {a} +
+
+ {b} +
+
+ {children} +
+
+ ) +} diff --git a/test/e2e/app-dir/app/app/parallel/@bar/page.server.js b/test/e2e/app-dir/app/app/parallel/@bar/page.server.js new file mode 100644 index 000000000000..568f5ed06461 --- /dev/null +++ b/test/e2e/app-dir/app/app/parallel/@bar/page.server.js @@ -0,0 +1,3 @@ +export default function Page() { + return
Bar
+} diff --git a/test/e2e/app-dir/app/app/parallel/@foo/nested/@a/page.server.js b/test/e2e/app-dir/app/app/parallel/@foo/nested/@a/page.server.js new file mode 100644 index 000000000000..31c604844adb --- /dev/null +++ b/test/e2e/app-dir/app/app/parallel/@foo/nested/@a/page.server.js @@ -0,0 +1,3 @@ +export default function Page() { + return
parallel/@foo/nested/@a/page
+} diff --git a/test/e2e/app-dir/app/app/parallel/@foo/nested/@b/page.server.js b/test/e2e/app-dir/app/app/parallel/@foo/nested/@b/page.server.js new file mode 100644 index 000000000000..79481da1a03a --- /dev/null +++ b/test/e2e/app-dir/app/app/parallel/@foo/nested/@b/page.server.js @@ -0,0 +1,3 @@ +export default function Page() { + return
parallel/@foo/nested/@b/page
+} diff --git a/test/e2e/app-dir/app/app/parallel/@foo/nested/layout.server.js b/test/e2e/app-dir/app/app/parallel/@foo/nested/layout.server.js new file mode 100644 index 000000000000..19d532a37424 --- /dev/null +++ b/test/e2e/app-dir/app/app/parallel/@foo/nested/layout.server.js @@ -0,0 +1,16 @@ +export default function Parallel({ a, b, children }) { + return ( +
+ parallel/@foo/nested/layout +
+ {a} +
+
+ {b} +
+
+ {children} +
+
+ ) +} diff --git a/test/e2e/app-dir/app/app/parallel/@foo/page.server.js b/test/e2e/app-dir/app/app/parallel/@foo/page.server.js new file mode 100644 index 000000000000..9e30ce2b2bc3 --- /dev/null +++ b/test/e2e/app-dir/app/app/parallel/@foo/page.server.js @@ -0,0 +1,3 @@ +export default function Page() { + return
Foo
+} diff --git a/test/e2e/app-dir/app/app/parallel/layout.server.js b/test/e2e/app-dir/app/app/parallel/layout.server.js new file mode 100644 index 000000000000..362fefc38e62 --- /dev/null +++ b/test/e2e/app-dir/app/app/parallel/layout.server.js @@ -0,0 +1,21 @@ +import './style.css' + +export default function Parallel({ foo, bar, baz, children }) { + return ( +
+ parallel/layout1: +
+ {foo} +
+
+ {bar} +
+
+ {baz} +
+
+ {children} +
+
+ ) +} diff --git a/test/e2e/app-dir/app/app/parallel/nested/page.server.js b/test/e2e/app-dir/app/app/parallel/nested/page.server.js new file mode 100644 index 000000000000..d7992d71980e --- /dev/null +++ b/test/e2e/app-dir/app/app/parallel/nested/page.server.js @@ -0,0 +1,3 @@ +export default function Page() { + return
parallel/nested/page
+} diff --git a/test/e2e/app-dir/app/app/parallel/style.css b/test/e2e/app-dir/app/app/parallel/style.css new file mode 100644 index 000000000000..723ece56ac88 --- /dev/null +++ b/test/e2e/app-dir/app/app/parallel/style.css @@ -0,0 +1,15 @@ +div { + font-size: 16px; +} + +.parallel { + border: 1px solid; + margin: 10px; +} + +.parallel::before { + content: attr(title); + background: black; + color: white; + padding: 1px; +} From db8e43721953c49800fc2266206b1402d9dc20ec Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Tue, 30 Aug 2022 23:23:39 +0200 Subject: [PATCH 02/11] add test --- test/e2e/app-dir/index.test.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/e2e/app-dir/index.test.ts b/test/e2e/app-dir/index.test.ts index e22823c3d79d..13dcd3fc4ffa 100644 --- a/test/e2e/app-dir/index.test.ts +++ b/test/e2e/app-dir/index.test.ts @@ -273,6 +273,18 @@ describe('app dir', () => { } }) + it('should match parallel routes', async () => { + const html = await renderViaHTTP(next.url, '/parallel/nested') + expect(html).toContain('parallel/@foo/nested/layout') + expect(html).toContain('parallel/@foo/nested/@a/page') + expect(html).toContain('parallel/@foo/nested/@b/page') + expect(html).toContain('parallel/@bar/nested/layout') + expect(html).toContain('parallel/@bar/nested/@a/page') + expect(html).toContain('parallel/@bar/nested/@b/page') + expect(html).toContain('parallel/(new)/@baz/nested/page') + expect(html).toContain('parallel/nested/page') + }) + describe('', () => { // TODO-APP: fix development test it.skip('should hard push', async () => { From 18f36db69f52f191db37d9ae2ae07883e38c58ce Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Wed, 31 Aug 2022 17:13:22 +0200 Subject: [PATCH 03/11] fix failed test --- packages/next/build/webpack/loaders/next-app-loader.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/next/build/webpack/loaders/next-app-loader.ts b/packages/next/build/webpack/loaders/next-app-loader.ts index e0ce2c6bbcb8..4814b7e0f094 100644 --- a/packages/next/build/webpack/loaders/next-app-loader.ts +++ b/packages/next/build/webpack/loaders/next-app-loader.ts @@ -122,9 +122,11 @@ const nextAppLoader: webpack.LoaderDefinitionFunction<{ } const resolve = this.getResolve(resolveOptions) + const normalizedAppPaths = + typeof appPaths === 'string' ? [appPaths] : appPaths || [] const resolveParallelSegments = (pathname: string) => { const matched = new Set() - for (const path of appPaths || []) { + for (const path of normalizedAppPaths) { if (path.startsWith(pathname + '/')) { const restPath = path.slice(pathname.length + 1) From 6a458eaa4a546d6bd4da213a2edb6ea2688a9945 Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Wed, 31 Aug 2022 22:58:48 +0200 Subject: [PATCH 04/11] bug fixes --- packages/next/build/entries.ts | 18 ++++++- packages/next/build/index.ts | 51 ++++++++----------- .../build/webpack/loaders/next-app-loader.ts | 44 ++++++---------- .../@baz/{nested => nested-2}/page.server.js | 0 .../app/app/parallel/(new)/layout.server.js | 10 ++++ .../app-dir/app/app/parallel/layout.server.js | 7 +-- test/e2e/app-dir/index.test.ts | 9 +++- 7 files changed, 72 insertions(+), 67 deletions(-) rename test/e2e/app-dir/app/app/parallel/(new)/@baz/{nested => nested-2}/page.server.js (100%) create mode 100644 test/e2e/app-dir/app/app/parallel/(new)/layout.server.js diff --git a/packages/next/build/entries.ts b/packages/next/build/entries.ts index e23970bd6f01..67606be56308 100644 --- a/packages/next/build/entries.ts +++ b/packages/next/build/entries.ts @@ -145,7 +145,6 @@ interface CreateEntrypointsParams { envFiles: LoadedEnvFiles isDev?: boolean pages: { [page: string]: string } - appPathsPerRoute?: { [route: string]: string[] } pagesDir: string previewMode: __ApiPreviewProps rootDir: string @@ -338,7 +337,6 @@ export async function createEntrypoints(params: CreateEntrypointsParams) { config, pages, pagesDir, - appPathsPerRoute = {}, isDev, rootDir, rootPaths, @@ -353,6 +351,22 @@ export async function createEntrypoints(params: CreateEntrypointsParams) { const nestedMiddleware: string[] = [] let middlewareRegex: string | undefined = undefined + let appPathsPerRoute: Record = {} + if (appDir && appPaths) { + for (const pathname in appPaths) { + const normalizedPath = normalizeAppPath(pathname) || '/' + if (!appPathsPerRoute[normalizedPath]) { + appPathsPerRoute[normalizedPath] = [] + } + appPathsPerRoute[normalizedPath].push(pathname) + } + + // Make sure to sort parallel routes to make the result deterministic. + appPathsPerRoute = Object.fromEntries( + Object.entries(appPathsPerRoute).map(([k, v]) => [k, v.sort()]) + ) + } + const getEntryHandler = (mappings: Record, pagesType: 'app' | 'pages' | 'root') => async (page: string) => { diff --git a/packages/next/build/index.ts b/packages/next/build/index.ts index 2f6d20c2a5ad..1cec41de0b50 100644 --- a/packages/next/build/index.ts +++ b/packages/next/build/index.ts @@ -517,35 +517,6 @@ export default async function build( }) } - const serverDir = isLikeServerless - ? SERVERLESS_DIRECTORY - : SERVER_DIRECTORY - - let appPathsPerRoute: Record = {} - if (appDir) { - const appPathsManifest = JSON.parse( - await promises.readFile( - path.join(distDir, serverDir, APP_PATHS_MANIFEST), - 'utf8' - ) - ) - const appPathRoutes: Record = {} - - Object.keys(appPathsManifest).forEach((entry) => { - const normalizedPath = normalizeAppPath(entry) || '/' - appPathRoutes[entry] = normalizedPath - if (!appPathsPerRoute[normalizedPath]) { - appPathsPerRoute[normalizedPath] = [] - } - appPathsPerRoute[normalizedPath].push(entry) - }) - - await promises.writeFile( - path.join(distDir, APP_PATH_ROUTES_MANIFEST), - JSON.stringify(appPathRoutes, null, 2) - ) - } - const entrypoints = await nextBuildSpan .traceChild('create-entrypoints') .traceAsyncFn(() => @@ -555,7 +526,6 @@ export default async function build( envFiles: loadedEnvFiles, isDev: false, pages: mappedPages, - appPathsPerRoute, pagesDir, previewMode: previewProps, target, @@ -810,6 +780,9 @@ export default async function build( ) ) + const serverDir = isLikeServerless + ? SERVERLESS_DIRECTORY + : SERVER_DIRECTORY const manifestPath = path.join(distDir, serverDir, PAGES_MANIFEST) const requiredServerFiles = nextBuildSpan @@ -1843,6 +1816,24 @@ export default async function build( 'utf8' ) + if (appDir) { + const appPathsManifest = JSON.parse( + await promises.readFile( + path.join(distDir, serverDir, APP_PATHS_MANIFEST), + 'utf8' + ) + ) + const appPathRoutes: Record = {} + + Object.keys(appPathsManifest).forEach((entry) => { + appPathRoutes[entry] = normalizeAppPath(entry) || '/' + }) + await promises.writeFile( + path.join(distDir, APP_PATH_ROUTES_MANIFEST), + JSON.stringify(appPathRoutes, null, 2) + ) + } + const middlewareManifest: MiddlewareManifest = JSON.parse( await promises.readFile( path.join(distDir, serverDir, MIDDLEWARE_MANIFEST), diff --git a/packages/next/build/webpack/loaders/next-app-loader.ts b/packages/next/build/webpack/loaders/next-app-loader.ts index 4814b7e0f094..19e22e46bf13 100644 --- a/packages/next/build/webpack/loaders/next-app-loader.ts +++ b/packages/next/build/webpack/loaders/next-app-loader.ts @@ -9,7 +9,9 @@ async function createTreeCodeFromPath({ }: { pagePath: string resolve: (pathname: string) => Promise - resolveParallelSegments: (pathname: string) => string[] + resolveParallelSegments: ( + pathname: string + ) => [key: string, segment: string][] }) { const splittedPath = pagePath.split(/[\\/]/) const appDirPrefix = splittedPath[0] @@ -20,10 +22,7 @@ async function createTreeCodeFromPath({ const segmentPath = segments.join('/') // Last item in the list is the page which can't have layouts by itself - if ( - segments[segments.length - 1] === 'page' || - segments[segments.length - 1]?.endsWith('/page') - ) { + if (segments[segments.length - 1] === 'page') { const matchedPagePath = `${appDirPrefix}${segmentPath}` const resolvedPagePath = await resolve(matchedPagePath) // Use '' for segment as it's the page. There can't be a segment called '' so this is the safest way to add it. @@ -38,14 +37,14 @@ async function createTreeCodeFromPath({ const props: Record = {} // We need to resolve all parallel routes in this level. - const parallelSegments: string[] = [] + const parallelSegments: [key: string, segment: string][] = [] if (segments.length === 0) { - parallelSegments.push('') + parallelSegments.push(['children', '']) } else { parallelSegments.push(...resolveParallelSegments(segmentPath)) } - for (const parallelSegment of parallelSegments) { + for (const [parallelKey, parallelSegment] of parallelSegments) { const parallelSegmentPath = segmentPath + '/' + parallelSegment const subtree = await createSubtreePropsFromSegmentPath([ ...segments, @@ -60,10 +59,7 @@ async function createTreeCodeFromPath({ const resolvedLayoutPath = await resolve(layoutPath) const resolvedLoadingPath = await resolve(loadingPath) - const matchedSlot = parallelSegment.match(/@(.+)/) - const segmentKey = matchedSlot ? matchedSlot[1] : 'children' - - props[segmentKey] = `[ + props[parallelKey] = `[ '${parallelSegment}', ${subtree}, { @@ -125,29 +121,19 @@ const nextAppLoader: webpack.LoaderDefinitionFunction<{ const normalizedAppPaths = typeof appPaths === 'string' ? [appPaths] : appPaths || [] const resolveParallelSegments = (pathname: string) => { - const matched = new Set() + const matched: Record = {} for (const path of normalizedAppPaths) { if (path.startsWith(pathname + '/')) { const restPath = path.slice(pathname.length + 1) - const pathSegments = restPath.split('/') - let matchedSegments = '' - for (const segment of pathSegments) { - if (matchedSegments) { - matchedSegments += '/' - } - if (segment.startsWith('(')) { - // Include all prefixed (...) segments. - matchedSegments += segment - } else { - matchedSegments += segment - break - } - } - matched.add(matchedSegments) + const matchedSegment = restPath.split('/')[0] + const matchedKey = matchedSegment.startsWith('@') + ? matchedSegment.slice(1) + : 'children' + matched[matchedKey] = matchedSegment } } - return Array.from(matched) + return Object.entries(matched) } const resolver = async (pathname: string) => { diff --git a/test/e2e/app-dir/app/app/parallel/(new)/@baz/nested/page.server.js b/test/e2e/app-dir/app/app/parallel/(new)/@baz/nested-2/page.server.js similarity index 100% rename from test/e2e/app-dir/app/app/parallel/(new)/@baz/nested/page.server.js rename to test/e2e/app-dir/app/app/parallel/(new)/@baz/nested-2/page.server.js diff --git a/test/e2e/app-dir/app/app/parallel/(new)/layout.server.js b/test/e2e/app-dir/app/app/parallel/(new)/layout.server.js new file mode 100644 index 000000000000..491d122a9633 --- /dev/null +++ b/test/e2e/app-dir/app/app/parallel/(new)/layout.server.js @@ -0,0 +1,10 @@ +export default function Layout({ baz }) { + return ( +
+ parallel/(new)/layout: +
+ {baz} +
+
+ ) +} diff --git a/test/e2e/app-dir/app/app/parallel/layout.server.js b/test/e2e/app-dir/app/app/parallel/layout.server.js index 362fefc38e62..a1474ba6d07a 100644 --- a/test/e2e/app-dir/app/app/parallel/layout.server.js +++ b/test/e2e/app-dir/app/app/parallel/layout.server.js @@ -1,18 +1,15 @@ import './style.css' -export default function Parallel({ foo, bar, baz, children }) { +export default function Parallel({ foo, bar, children }) { return (
- parallel/layout1: + parallel/layout:
{foo}
{bar}
-
- {baz} -
{children}
diff --git a/test/e2e/app-dir/index.test.ts b/test/e2e/app-dir/index.test.ts index 13dcd3fc4ffa..a8199666e06c 100644 --- a/test/e2e/app-dir/index.test.ts +++ b/test/e2e/app-dir/index.test.ts @@ -275,16 +275,23 @@ describe('app dir', () => { it('should match parallel routes', async () => { const html = await renderViaHTTP(next.url, '/parallel/nested') + expect(html).toContain('parallel/layout') expect(html).toContain('parallel/@foo/nested/layout') expect(html).toContain('parallel/@foo/nested/@a/page') expect(html).toContain('parallel/@foo/nested/@b/page') expect(html).toContain('parallel/@bar/nested/layout') expect(html).toContain('parallel/@bar/nested/@a/page') expect(html).toContain('parallel/@bar/nested/@b/page') - expect(html).toContain('parallel/(new)/@baz/nested/page') expect(html).toContain('parallel/nested/page') }) + it('should match parallel routes in route groups', async () => { + const html = await renderViaHTTP(next.url, '/parallel/nested-2') + expect(html).toContain('parallel/layout') + expect(html).toContain('parallel/(new)/layout') + expect(html).toContain('parallel/(new)/@baz/nested/page') + }) + describe('', () => { // TODO-APP: fix development test it.skip('should hard push', async () => { From 1829509bcc1e8c3aa87b32e9d0ad32ae0ddcf6e3 Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Wed, 31 Aug 2022 23:53:31 +0200 Subject: [PATCH 05/11] fix default path --- packages/next/build/entries.ts | 6 ++++-- packages/next/build/index.ts | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/next/build/entries.ts b/packages/next/build/entries.ts index 22e84677ba99..06e71e3fc8ff 100644 --- a/packages/next/build/entries.ts +++ b/packages/next/build/entries.ts @@ -447,7 +447,8 @@ export async function createEntrypoints(params: CreateEntrypointsParams) { }, onServer: () => { if (pagesType === 'app' && appDir) { - const matchedAppPaths = appPathsPerRoute[normalizeAppPath(page)] + const matchedAppPaths = + appPathsPerRoute[normalizeAppPath(page) || '/'] server[serverBundlePath] = getAppEntry({ name: serverBundlePath, pagePath: mappings[page], @@ -475,7 +476,8 @@ export async function createEntrypoints(params: CreateEntrypointsParams) { onEdgeServer: () => { let appDirLoader: string = '' if (pagesType === 'app') { - const matchedAppPaths = appPathsPerRoute[normalizeAppPath(page)] + const matchedAppPaths = + appPathsPerRoute[normalizeAppPath(page) || '/'] appDirLoader = getAppEntry({ name: serverBundlePath, pagePath: mappings[page], diff --git a/packages/next/build/index.ts b/packages/next/build/index.ts index 72ff1b2de1fd..89ae2014e57a 100644 --- a/packages/next/build/index.ts +++ b/packages/next/build/index.ts @@ -540,7 +540,9 @@ export default async function build( const pageKeys = { pages: Object.keys(mappedPages), app: mappedAppPages - ? Object.keys(mappedAppPages).map((key) => normalizeAppPath(key)) + ? Object.keys(mappedAppPages).map( + (key) => normalizeAppPath(key) || '/' + ) : undefined, } From 56307a0231853ce6d41ba8b0f459151a81b5a0f3 Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Thu, 1 Sep 2022 00:11:42 +0200 Subject: [PATCH 06/11] fix lint error --- packages/next/server/app-render.js | 835 ++++++++++ packages/next/server/app-render.js.map | 1 + packages/next/server/dev/next-dev-server.js | 1461 +++++++++++++++++ .../next/server/dev/next-dev-server.js.map | 1 + packages/next/server/dev/next-dev-server.ts | 7 +- 5 files changed, 2301 insertions(+), 4 deletions(-) create mode 100644 packages/next/server/app-render.js create mode 100644 packages/next/server/app-render.js.map create mode 100644 packages/next/server/dev/next-dev-server.js create mode 100644 packages/next/server/dev/next-dev-server.js.map diff --git a/packages/next/server/app-render.js b/packages/next/server/app-render.js new file mode 100644 index 000000000000..68eed45bdb51 --- /dev/null +++ b/packages/next/server/app-render.js @@ -0,0 +1,835 @@ +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) +exports.renderToHTMLOrFlight = renderToHTMLOrFlight +var _react = _interopRequireDefault(require('react')) +var _querystring = require('querystring') +var _reactServerDomWebpack = require('next/dist/compiled/react-server-dom-webpack') +var _writerBrowserServer = require('next/dist/compiled/react-server-dom-webpack/writer.browser.server') +var _renderResult = _interopRequireDefault(require('./render-result')) +var _nodeWebStreamsHelper = require('./node-web-streams-helper') +var _utils = require('../shared/lib/router/utils') +var _htmlescape = require('./htmlescape') +var _utils1 = require('./utils') +var _matchSegments = require('../client/components/match-segments') +var _hooksClient = require('../client/components/hooks-client') +function _interopRequireDefault(obj) { + return obj && obj.__esModule + ? obj + : { + default: obj, + } +} +// this needs to be required lazily so that `next-server` can set +// the env before we require +const ReactDOMServer = _utils1.shouldUseReactRoot + ? require('react-dom/server.browser') + : require('react-dom/server') +/** + * Interop between "export default" and "module.exports". + */ function interopDefault(mod) { + return mod.default || mod +} +const rscCache = new Map() +var // Shadowing check does not work with TypeScript enums + // eslint-disable-next-line no-shadow + RecordStatus +;(function (RecordStatus) { + RecordStatus[(RecordStatus['Pending'] = 0)] = 'Pending' + RecordStatus[(RecordStatus['Resolved'] = 1)] = 'Resolved' + RecordStatus[(RecordStatus['Rejected'] = 2)] = 'Rejected' +})(RecordStatus || (RecordStatus = {})) +/** + * Create data fetching record for Promise. + */ function createRecordFromThenable(thenable) { + const record = { + status: 0, + value: thenable, + } + thenable.then( + function (value) { + if (record.status === 0) { + const resolvedRecord = record + resolvedRecord.status = 1 + resolvedRecord.value = value + } + }, + function (err) { + if (record.status === 0) { + const rejectedRecord = record + rejectedRecord.status = 2 + rejectedRecord.value = err + } + } + ) + return record +} +/** + * Read record value or throw Promise if it's not resolved yet. + */ function readRecordValue(record) { + if (record.status === 1) { + return record.value + } else { + throw record.value + } +} +/** + * Preload data fetching record before it is called during React rendering. + * If the record is already in the cache returns that record. + */ function preloadDataFetchingRecord(map, key, fetcher) { + let record = map.get(key) + if (!record) { + const thenable = fetcher() + record = createRecordFromThenable(thenable) + map.set(key, record) + } + return record +} +/** + * Render Flight stream. + * This is only used for renderToHTML, the Flight response does not need additional wrappers. + */ function useFlightResponse( + writable, + cachePrefix, + req, + serverComponentManifest +) { + const id = cachePrefix + ',' + _react.default.useId() + let entry = rscCache.get(id) + if (!entry) { + const [renderStream, forwardStream] = (0, + _nodeWebStreamsHelper).readableStreamTee(req) + entry = (0, _reactServerDomWebpack).createFromReadableStream(renderStream, { + moduleMap: serverComponentManifest.__ssr_module_mapping__, + }) + rscCache.set(id, entry) + let bootstrapped = false + // We only attach CSS chunks to the inlined data. + const forwardReader = forwardStream.getReader() + const writer = writable.getWriter() + function process() { + forwardReader.read().then(({ done, value }) => { + if (!bootstrapped) { + bootstrapped = true + writer.write( + (0, _nodeWebStreamsHelper).encodeText( + `` + ) + ) + } + if (done) { + rscCache.delete(id) + writer.close() + } else { + const responsePartial = (0, _nodeWebStreamsHelper).decodeText(value) + const scripts = `` + writer.write((0, _nodeWebStreamsHelper).encodeText(scripts)) + process() + } + }) + } + process() + } + return entry +} +/** + * Create a component that renders the Flight stream. + * This is only used for renderToHTML, the Flight response does not need additional wrappers. + */ function createServerComponentRenderer( + ComponentToRender, + ComponentMod, + { cachePrefix, transformStream, serverComponentManifest, serverContexts } +) { + // We need to expose the `__webpack_require__` API globally for + // react-server-dom-webpack. This is a hack until we find a better way. + if (ComponentMod.__next_app_webpack_require__ || ComponentMod.__next_rsc__) { + var ref + // @ts-ignore + globalThis.__next_require__ = + ComponentMod.__next_app_webpack_require__ || + ((ref = ComponentMod.__next_rsc__) == null + ? void 0 + : ref.__webpack_require__) + // @ts-ignore + globalThis.__next_chunk_load__ = () => Promise.resolve() + } + let RSCStream + const createRSCStream = () => { + if (!RSCStream) { + RSCStream = (0, _writerBrowserServer).renderToReadableStream( + /*#__PURE__*/ _react.default.createElement(ComponentToRender, null), + serverComponentManifest, + { + context: serverContexts, + } + ) + } + return RSCStream + } + const writable = transformStream.writable + return function ServerComponentWrapper() { + const reqStream = createRSCStream() + const response = useFlightResponse( + writable, + cachePrefix, + reqStream, + serverComponentManifest + ) + return response.readRoot() + } +} +/** + * Shorten the dynamic param in order to make it smaller when transmitted to the browser. + */ function getShortDynamicParamType(type) { + switch (type) { + case 'catchall': + return 'c' + case 'optional-catchall': + return 'oc' + case 'dynamic': + return 'd' + default: + throw new Error('Unknown dynamic param type') + } +} +/** + * Parse dynamic route segment to type of parameter + */ function getSegmentParam(segment) { + if (segment.startsWith('[[...') && segment.endsWith(']]')) { + return { + type: 'optional-catchall', + param: segment.slice(5, -2), + } + } + if (segment.startsWith('[...') && segment.endsWith(']')) { + return { + type: 'catchall', + param: segment.slice(4, -1), + } + } + if (segment.startsWith('[') && segment.endsWith(']')) { + return { + type: 'dynamic', + param: segment.slice(1, -1), + } + } + return null +} +/** + * Get inline tags based on server CSS manifest. Only used when rendering to HTML. + */ function getCssInlinedLinkTags( + serverComponentManifest, + serverCSSManifest, + filePath +) { + var ref + const layoutOrPageCss = + serverCSSManifest[filePath] || + ((ref = serverComponentManifest.__client_css_manifest__) == null + ? void 0 + : ref[filePath]) + if (!layoutOrPageCss) { + return [] + } + const chunks = new Set() + for (const css of layoutOrPageCss) { + const mod = serverComponentManifest[css] + if (mod) { + for (const chunk of mod.default.chunks) { + chunks.add(chunk) + } + } + } + return [...chunks] +} +async function renderToHTMLOrFlight( + req, + res, + pathname, + query, + renderOpts, + isPagesDir +) { + // @ts-expect-error createServerContext exists in react@experimental + react-dom@experimental + if (typeof _react.default.createServerContext === 'undefined') { + throw new Error( + '"app" directory requires React.createServerContext which is not available in the version of React you are using. Please update to react@experimental and react-dom@experimental.' + ) + } + // don't modify original query object + query = Object.assign({}, query) + const { + buildManifest, + serverComponentManifest, + serverCSSManifest = {}, + supportsDynamicHTML, + ComponentMod, + } = renderOpts + const isFlight = query.__flight__ !== undefined + // Handle client-side navigation to pages directory + if (isFlight && isPagesDir) { + ;(0, _utils1).stripInternalQueries(query) + const search = (0, _querystring).stringify(query) + // Empty so that the client-side router will do a full page navigation. + const flightData = pathname + (search ? `?${search}` : '') + return new _renderResult.default( + (0, _writerBrowserServer) + .renderToReadableStream(flightData, serverComponentManifest) + .pipeThrough((0, _nodeWebStreamsHelper).createBufferedTransformStream()) + ) + } + // TODO-APP: verify the tree is valid + // TODO-APP: verify query param is single value (not an array) + // TODO-APP: verify tree can't grow out of control + /** + * Router state provided from the client-side router. Used to handle rendering from the common layout down. + */ const providedFlightRouterState = isFlight + ? query.__flight_router_state_tree__ + ? JSON.parse(query.__flight_router_state_tree__) + : {} + : undefined + ;(0, _utils1).stripInternalQueries(query) + const pageIsDynamic = (0, _utils).isDynamicRoute(pathname) + const LayoutRouter = ComponentMod.LayoutRouter + const HotReloader = ComponentMod.HotReloader + const headers = req.headers + // TODO-APP: fix type of req + // @ts-expect-error + const cookies = req.cookies + /** + * The tree created in next-app-loader that holds component segments and modules + */ const loaderTree = ComponentMod.tree + const tryGetPreviewData = + process.env.NEXT_RUNTIME === 'edge' + ? () => false + : require('./api-utils/node').tryGetPreviewData + // Reads of this are cached on the `req` object, so this should resolve + // instantly. There's no need to pass this data down from a previous + // invoke, where we'd have to consider server & serverless. + const previewData = tryGetPreviewData(req, res, renderOpts.previewProps) + const isPreview = previewData !== false + /** + * Server Context is specifically only available in Server Components. + * It has to hold values that can't change while rendering from the common layout down. + * An example of this would be that `headers` are available but `searchParams` are not because that'd mean we have to render from the root layout down on all requests. + */ const serverContexts = [ + ['WORKAROUND', null], + ['HeadersContext', headers], + ['CookiesContext', cookies], + ['PreviewDataContext', previewData], + ] + /** + * Used to keep track of in-flight / resolved data fetching Promises. + */ const dataCache = new Map() + /** + * Dynamic parameters. E.g. when you visit `/dashboard/vercel` which is rendered by `/dashboard/[slug]` the value will be {"slug": "vercel"}. + */ const pathParams = renderOpts.params + /** + * Parse the dynamic segment and return the associated value. + */ const getDynamicParamFromSegment = ( + // [slug] / [[slug]] / [...slug] + segment + ) => { + const segmentParam = getSegmentParam(segment) + if (!segmentParam) { + return null + } + const key = segmentParam.param + const value = pathParams[key] + if (!value) { + // Handle case where optional catchall does not have a value, e.g. `/dashboard/[...slug]` when requesting `/dashboard` + if (segmentParam.type === 'optional-catchall') { + const type = getShortDynamicParamType(segmentParam.type) + return { + param: key, + value: null, + type: type, + // This value always has to be a string. + treeSegment: [key, '', type], + } + } + return null + } + const type = getShortDynamicParamType(segmentParam.type) + return { + param: key, + // The value that is passed to user code. + value: value, + // The value that is rendered in the router tree. + treeSegment: [key, Array.isArray(value) ? value.join('/') : value, type], + type: type, + } + } + const createFlightRouterStateFromLoaderTree = ([ + segment, + parallelRoutes, + { loading }, + ]) => { + const hasLoading = Boolean(loading) + const dynamicParam = getDynamicParamFromSegment(segment) + const segmentTree = [dynamicParam ? dynamicParam.treeSegment : segment, {}] + if (parallelRoutes) { + segmentTree[1] = Object.keys(parallelRoutes).reduce( + (existingValue, currentValue) => { + existingValue[currentValue] = createFlightRouterStateFromLoaderTree( + parallelRoutes[currentValue] + ) + return existingValue + }, + {} + ) + } + if (hasLoading) { + segmentTree[4] = 'loading' + } + return segmentTree + } + /** + * Use the provided loader tree to create the React Component tree. + */ const createComponentTree = async ({ + createSegmentPath, + loaderTree: [segment, parallelRoutes, { filePath, layout, loading, page }], + parentParams, + firstItem, + rootLayoutIncluded, + }) => { + // TODO-APP: enable stylesheet per layout/page + const stylesheets = getCssInlinedLinkTags( + serverComponentManifest, + serverCSSManifest, + filePath + ) + const Loading = loading ? await interopDefault(loading()) : undefined + const isLayout = typeof layout !== 'undefined' + const isPage = typeof page !== 'undefined' + const layoutOrPageMod = isLayout + ? await layout() + : isPage + ? await page() + : undefined + /** + * Checks if the current segment is a root layout. + */ const rootLayoutAtThisLevel = isLayout && !rootLayoutIncluded + /** + * Checks if the current segment or any level above it has a root layout. + */ const rootLayoutIncludedAtThisLevelOrAbove = + rootLayoutIncluded || rootLayoutAtThisLevel + /** + * Check if the current layout/page is a client component + */ const isClientComponentModule = + layoutOrPageMod && !layoutOrPageMod.hasOwnProperty('__next_rsc__') + /** + * The React Component to render. + */ const Component = layoutOrPageMod + ? interopDefault(layoutOrPageMod) + : undefined + // Handle dynamic segment params. + const segmentParam = getDynamicParamFromSegment(segment) + /** + * Create object holding the parent params and current params, this is passed to getServerSideProps and getStaticProps. + */ const currentParams = // Handle null case where dynamic param is optional + segmentParam && segmentParam.value !== null + ? { + ...parentParams, + [segmentParam.param]: segmentParam.value, + } + : parentParams + // Resolve the segment param + const actualSegment = segmentParam ? segmentParam.treeSegment : segment + // This happens outside of rendering in order to eagerly kick off data fetching for layouts / the page further down + const parallelRouteMap = await Promise.all( + Object.keys(parallelRoutes).map(async (parallelRouteKey) => { + const currentSegmentPath = firstItem + ? [parallelRouteKey] + : [actualSegment, parallelRouteKey] + // Create the child component + const { Component: ChildComponent } = await createComponentTree({ + createSegmentPath: (child) => { + return createSegmentPath([...currentSegmentPath, ...child]) + }, + loaderTree: parallelRoutes[parallelRouteKey], + parentParams: currentParams, + rootLayoutIncluded: rootLayoutIncludedAtThisLevelOrAbove, + }) + const childSegment = parallelRoutes[parallelRouteKey][0] + const childSegmentParam = getDynamicParamFromSegment(childSegment) + const childProp = { + current: /*#__PURE__*/ _react.default.createElement( + ChildComponent, + null + ), + segment: childSegmentParam + ? childSegmentParam.treeSegment + : childSegment, + } + // This is turned back into an object below. + return [ + parallelRouteKey, + /*#__PURE__*/ _react.default.createElement(LayoutRouter, { + parallelRouterKey: parallelRouteKey, + segmentPath: createSegmentPath(currentSegmentPath), + loading: Loading + ? /*#__PURE__*/ _react.default.createElement(Loading, null) + : undefined, + childProp: childProp, + rootLayoutIncluded: rootLayoutIncludedAtThisLevelOrAbove, + }), + ] + }) + ) + // Convert the parallel route map into an object after all promises have been resolved. + const parallelRouteComponents = parallelRouteMap.reduce( + (list, [parallelRouteKey, Comp]) => { + list[parallelRouteKey] = Comp + return list + }, + {} + ) + // When the segment does not have a layout or page we still have to add the layout router to ensure the path holds the loading component + if (!Component) { + return { + Component: () => + /*#__PURE__*/ _react.default.createElement( + _react.default.Fragment, + null, + parallelRouteComponents.children + ), + } + } + const segmentPath = createSegmentPath([actualSegment]) + const dataCacheKey = JSON.stringify(segmentPath) + let fetcher = null + // TODO-APP: pass a shared cache from previous getStaticProps/getServerSideProps calls? + if (!isClientComponentModule && layoutOrPageMod.getServerSideProps) { + // TODO-APP: recommendation for i18n + // locales: (renderOpts as any).locales, // always the same + // locale: (renderOpts as any).locale, // /nl/something -> nl + // defaultLocale: (renderOpts as any).defaultLocale, // changes based on domain + const getServerSidePropsContext = { + headers, + cookies, + layoutSegments: segmentPath, + // TODO-APP: change pathname to actual pathname, it holds the dynamic parameter currently + ...(isPage + ? { + searchParams: query, + pathname, + } + : {}), + ...(pageIsDynamic + ? { + params: currentParams, + } + : undefined), + ...(isPreview + ? { + preview: true, + previewData: previewData, + } + : undefined), + } + fetcher = () => + Promise.resolve( + layoutOrPageMod.getServerSideProps(getServerSidePropsContext) + ) + } + // TODO-APP: implement layout specific caching for getStaticProps + if (!isClientComponentModule && layoutOrPageMod.getStaticProps) { + const getStaticPropsContext = { + layoutSegments: segmentPath, + ...(isPage + ? { + pathname, + } + : {}), + ...(pageIsDynamic + ? { + params: currentParams, + } + : undefined), + ...(isPreview + ? { + preview: true, + previewData: previewData, + } + : undefined), + } + fetcher = () => + Promise.resolve(layoutOrPageMod.getStaticProps(getStaticPropsContext)) + } + if (fetcher) { + // Kick off data fetching before rendering, this ensures there is no waterfall for layouts as + // all data fetching required to render the page is kicked off simultaneously + preloadDataFetchingRecord(dataCache, dataCacheKey, fetcher) + } + return { + Component: () => { + let props + // The data fetching was kicked off before rendering (see above) + // if the data was not resolved yet the layout rendering will be suspended + if (fetcher) { + const record = preloadDataFetchingRecord( + dataCache, + dataCacheKey, + fetcher + ) + // Result of calling getStaticProps or getServerSideProps. If promise is not resolve yet it will suspend. + const recordValue = readRecordValue(record) + if (props) { + props = Object.assign({}, props, recordValue.props) + } else { + props = recordValue.props + } + } + return /*#__PURE__*/ _react.default.createElement( + _react.default.Fragment, + null, + stylesheets + ? stylesheets.map((href) => + /*#__PURE__*/ _react.default.createElement('link', { + rel: 'stylesheet', + href: `/_next/${href}?ts=${Date.now()}`, + // `Precedence` is an opt-in signal for React to handle + // resource loading and deduplication, etc: + // https://github.com/facebook/react/pull/25060 + // @ts-ignore + precedence: 'high', + key: href, + }) + ) + : null, + /*#__PURE__*/ _react.default.createElement( + Component, + Object.assign( + {}, + props, + parallelRouteComponents, + { + // TODO-APP: params and query have to be blocked parallel route names. Might have to add a reserved name list. + // Params are always the current params that apply to the layout + // If you have a `/dashboard/[team]/layout.js` it will provide `team` as a param but not anything further down. + params: currentParams, + }, + isPage + ? { + searchParams: query, + } + : {} + ) + ) + ) + }, + } + } + // Handle Flight render request. This is only used when client-side navigating. E.g. when you `router.push('/dashboard')` or `router.reload()`. + if (isFlight) { + // TODO-APP: throw on invalid flightRouterState + /** + * Use router state to decide at what common layout to render the page. + * This can either be the common layout between two pages or a specific place to start rendering from using the "refetch" marker in the tree. + */ const walkTreeWithFlightRouterState = async ( + loaderTreeToFilter, + parentParams, + flightRouterState, + parentRendered + ) => { + const [segment, parallelRoutes] = loaderTreeToFilter + const parallelRoutesKeys = Object.keys(parallelRoutes) + // Because this function walks to a deeper point in the tree to start rendering we have to track the dynamic parameters up to the point where rendering starts + // That way even when rendering the subtree getServerSideProps/getStaticProps get the right parameters. + const segmentParam = getDynamicParamFromSegment(segment) + const currentParams = // Handle null case where dynamic param is optional + segmentParam && segmentParam.value !== null + ? { + ...parentParams, + [segmentParam.param]: segmentParam.value, + } + : parentParams + const actualSegment = segmentParam ? segmentParam.treeSegment : segment + /** + * Decide if the current segment is where rendering has to start. + */ const renderComponentsOnThisLevel = // No further router state available + !flightRouterState || // Segment in router state does not match current segment + !(0, _matchSegments).matchSegment( + actualSegment, + flightRouterState[0] + ) || // Last item in the tree + parallelRoutesKeys.length === 0 || // Explicit refresh + flightRouterState[3] === 'refetch' + if (!parentRendered && renderComponentsOnThisLevel) { + return [ + actualSegment, + // Create router state using the slice of the loaderTree + createFlightRouterStateFromLoaderTree(loaderTreeToFilter), + // Create component tree using the slice of the loaderTree + /*#__PURE__*/ _react.default.createElement( + ( + await createComponentTree( + // This ensures flightRouterPath is valid and filters down the tree + { + createSegmentPath: (child) => child, + loaderTree: loaderTreeToFilter, + parentParams: currentParams, + firstItem: true, + } + ) + ).Component + ), + ] + } + // Walk through all parallel routes. + for (const parallelRouteKey of parallelRoutesKeys) { + const parallelRoute = parallelRoutes[parallelRouteKey] + const path = await walkTreeWithFlightRouterState( + parallelRoute, + currentParams, + flightRouterState && flightRouterState[1][parallelRouteKey], + parentRendered || renderComponentsOnThisLevel + ) + if (typeof path[path.length - 1] !== 'string') { + return [actualSegment, parallelRouteKey, ...path] + } + } + return [actualSegment] + } + // Flight data that is going to be passed to the browser. + // Currently a single item array but in the future multiple patches might be combined in a single request. + const flightData = [ + // TODO-APP: change walk to output without '' + ( + await walkTreeWithFlightRouterState( + loaderTree, + {}, + providedFlightRouterState + ) + ).slice(1), + ] + return new _renderResult.default( + (0, _writerBrowserServer) + .renderToReadableStream(flightData, serverComponentManifest, { + context: serverContexts, + }) + .pipeThrough((0, _nodeWebStreamsHelper).createBufferedTransformStream()) + ) + } + // Below this line is handling for rendering to HTML. + // Create full component tree from root to leaf. + const { Component: ComponentTree } = await createComponentTree({ + createSegmentPath: (child) => child, + loaderTree: loaderTree, + parentParams: {}, + firstItem: true, + }) + // AppRouter is provided by next-app-loader + const AppRouter = ComponentMod.AppRouter + let serverComponentsInlinedTransformStream = new TransformStream() + // TODO-APP: validate req.url as it gets passed to render. + const initialCanonicalUrl = req.url + /** + * A new React Component that renders the provided React Component + * using Flight which can then be rendered to HTML. + */ const ServerComponentsRenderer = createServerComponentRenderer( + () => { + const initialTree = createFlightRouterStateFromLoaderTree(loaderTree) + return /*#__PURE__*/ _react.default.createElement( + AppRouter, + { + hotReloader: + HotReloader && + /*#__PURE__*/ _react.default.createElement(HotReloader, { + assetPrefix: renderOpts.assetPrefix || '', + }), + initialCanonicalUrl: initialCanonicalUrl, + initialTree: initialTree, + }, + /*#__PURE__*/ _react.default.createElement(ComponentTree, null) + ) + }, + ComponentMod, + { + cachePrefix: initialCanonicalUrl, + transformStream: serverComponentsInlinedTransformStream, + serverComponentManifest, + serverContexts, + } + ) + const flushEffectsCallbacks = new Set() + function FlushEffects({ children }) { + // Reset flushEffectsHandler on each render + flushEffectsCallbacks.clear() + const addFlushEffects = _react.default.useCallback((handler) => { + flushEffectsCallbacks.add(handler) + }, []) + return /*#__PURE__*/ _react.default.createElement( + _hooksClient.FlushEffectsContext.Provider, + { + value: addFlushEffects, + }, + children + ) + } + /** + * Rules of Static & Dynamic HTML: + * + * 1.) We must generate static HTML unless the caller explicitly opts + * in to dynamic HTML support. + * + * 2.) If dynamic HTML support is requested, we must honor that request + * or throw an error. It is the sole responsibility of the caller to + * ensure they aren't e.g. requesting dynamic HTML for an AMP page. + * + * These rules help ensure that other existing features like request caching, + * coalescing, and ISR continue working as intended. + */ const generateStaticHTML = supportsDynamicHTML !== true + const bodyResult = async () => { + const content = /*#__PURE__*/ _react.default.createElement( + FlushEffects, + null, + /*#__PURE__*/ _react.default.createElement(ServerComponentsRenderer, null) + ) + const flushEffectHandler = () => { + const flushed = ReactDOMServer.renderToString( + /*#__PURE__*/ _react.default.createElement( + _react.default.Fragment, + null, + Array.from(flushEffectsCallbacks).map((callback) => callback()) + ) + ) + return flushed + } + const renderStream = await (0, _nodeWebStreamsHelper).renderToInitialStream( + { + ReactDOMServer, + element: content, + streamOptions: { + // Include hydration scripts in the HTML + bootstrapScripts: buildManifest.rootMainFiles.map( + (src) => `${renderOpts.assetPrefix || ''}/_next/` + src + ), + }, + } + ) + return await (0, _nodeWebStreamsHelper).continueFromInitialStream( + renderStream, + { + dataStream: + serverComponentsInlinedTransformStream == null + ? void 0 + : serverComponentsInlinedTransformStream.readable, + generateStaticHTML: generateStaticHTML, + flushEffectHandler, + flushEffectsToHead: true, + } + ) + } + return new _renderResult.default(await bodyResult()) +} + +//# sourceMappingURL=app-render.js.map diff --git a/packages/next/server/app-render.js.map b/packages/next/server/app-render.js.map new file mode 100644 index 000000000000..31445ecc2683 --- /dev/null +++ b/packages/next/server/app-render.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../server/app-render.tsx"],"names":["renderToHTMLOrFlight","ReactDOMServer","shouldUseReactRoot","require","interopDefault","mod","default","rscCache","Map","RecordStatus","Pending","Resolved","Rejected","createRecordFromThenable","thenable","record","status","value","then","resolvedRecord","err","rejectedRecord","readRecordValue","preloadDataFetchingRecord","map","key","fetcher","get","set","useFlightResponse","writable","cachePrefix","req","serverComponentManifest","id","React","useId","entry","renderStream","forwardStream","readableStreamTee","createFromReadableStream","moduleMap","__ssr_module_mapping__","bootstrapped","forwardReader","getReader","writer","getWriter","process","read","done","write","encodeText","htmlEscapeJsonString","JSON","stringify","delete","close","responsePartial","decodeText","scripts","createServerComponentRenderer","ComponentToRender","ComponentMod","transformStream","serverContexts","__next_app_webpack_require__","__next_rsc__","globalThis","__next_require__","__webpack_require__","__next_chunk_load__","Promise","resolve","RSCStream","createRSCStream","renderToReadableStream","context","ServerComponentWrapper","reqStream","response","readRoot","getShortDynamicParamType","type","Error","getSegmentParam","segment","startsWith","endsWith","param","slice","getCssInlinedLinkTags","serverCSSManifest","filePath","layoutOrPageCss","__client_css_manifest__","chunks","Set","css","chunk","add","res","pathname","query","renderOpts","isPagesDir","createServerContext","Object","assign","buildManifest","supportsDynamicHTML","isFlight","__flight__","undefined","stripInternalQueries","search","stringifyQuery","flightData","RenderResult","pipeThrough","createBufferedTransformStream","providedFlightRouterState","__flight_router_state_tree__","parse","pageIsDynamic","isDynamicRoute","LayoutRouter","HotReloader","headers","cookies","loaderTree","tree","tryGetPreviewData","env","NEXT_RUNTIME","previewData","previewProps","isPreview","dataCache","pathParams","params","getDynamicParamFromSegment","segmentParam","treeSegment","Array","isArray","join","createFlightRouterStateFromLoaderTree","parallelRoutes","loading","hasLoading","Boolean","dynamicParam","segmentTree","keys","reduce","existingValue","currentValue","createComponentTree","createSegmentPath","layout","page","parentParams","firstItem","rootLayoutIncluded","stylesheets","Loading","isLayout","isPage","layoutOrPageMod","rootLayoutAtThisLevel","rootLayoutIncludedAtThisLevelOrAbove","isClientComponentModule","hasOwnProperty","Component","currentParams","actualSegment","parallelRouteMap","all","parallelRouteKey","currentSegmentPath","ChildComponent","child","childSegment","childSegmentParam","childProp","current","parallelRouterKey","segmentPath","parallelRouteComponents","list","Comp","children","dataCacheKey","getServerSideProps","getServerSidePropsContext","layoutSegments","searchParams","preview","getStaticProps","getStaticPropsContext","props","recordValue","href","link","rel","Date","now","precedence","walkTreeWithFlightRouterState","loaderTreeToFilter","flightRouterState","parentRendered","parallelRoutesKeys","renderComponentsOnThisLevel","matchSegment","length","createElement","parallelRoute","path","ComponentTree","AppRouter","serverComponentsInlinedTransformStream","TransformStream","initialCanonicalUrl","url","ServerComponentsRenderer","initialTree","hotReloader","assetPrefix","flushEffectsCallbacks","FlushEffects","clear","addFlushEffects","useCallback","handler","FlushEffectsContext","Provider","generateStaticHTML","bodyResult","content","flushEffectHandler","flushed","renderToString","from","callback","renderToInitialStream","element","streamOptions","bootstrapScripts","rootMainFiles","src","continueFromInitialStream","dataStream","readable","flushEffectsToHead"],"mappings":"AAAA;;;;QAsZsBA,oBAAoB,GAApBA,oBAAoB;AAlZxB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACmC,IAAA,YAAa,WAAb,aAAa,CAAA;AAChC,IAAA,sBAA6C,WAA7C,6CAA6C,CAAA;AAC/C,IAAA,oBAAmE,WAAnE,mEAAmE,CAAA;AAEjF,IAAA,aAAiB,kCAAjB,iBAAiB,EAAA;AAQnC,IAAA,qBAA2B,WAA3B,2BAA2B,CAAA;AACH,IAAA,MAA4B,WAA5B,4BAA4B,CAAA;AACtB,IAAA,WAAc,WAAd,cAAc,CAAA;AACM,IAAA,OAAS,WAAT,SAAS,CAAA;AAErC,IAAA,cAAqC,WAArC,qCAAqC,CAAA;AAK9B,IAAA,YAAmC,WAAnC,mCAAmC,CAAA;;;;;;AAEvE,iEAAiE;AACjE,4BAA4B;AAC5B,MAAMC,cAAc,GAAGC,OAAkB,mBAAA,GACrCC,OAAO,CAAC,0BAA0B,CAAC,GACnCA,OAAO,CAAC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AmB,KAAK,IAAI;IACvD,MAAMiI,UAAU,GAAG,UAAY;QAC7B,MAAMC,OAAO,iBACX,6BAACT,YAAY,sBACX,6BAACL,wBAAwB,OAAG,CACf,AAChB;QAED,MAAMe,kBAAkB,GAAG,IAAc;YACvC,MAAMC,OAAO,GAAGlP,cAAc,CAACmP,cAAc,eAC3C,4DAAGnG,KAAK,CAACoG,IAAI,CAACd,qBAAqB,CAAC,CAAC/M,GAAG,CAAC,CAAC8N,QAAQ,GAAKA,QAAQ,EAAE,CAAC,CAAI,CACvE;YACD,OAAOH,OAAO,CAAA;SACf;QAED,MAAM7M,YAAY,GAAG,MAAMiN,CAAAA,GAAAA,qBAAqB,AAS9C,CAAA,sBAT8C,CAAC;YAC/CtP,cAAc;YACduP,OAAO,EAAEP,OAAO;YAChBQ,aAAa,EAAE;gBACb,wCAAwC;gBACxCC,gBAAgB,EAAE5I,aAAa,CAAC6I,aAAa,CAACnO,GAAG,CAC/C,CAACoO,GAAG,GAAK,CAAC,EAAEnJ,UAAU,CAAC6H,WAAW,IAAI,EAAE,CAAC,OAAO,CAAC,GAAGsB,GAAG,CACxD;aACF;SACF,CAAC;QAEF,OAAO,MAAMC,CAAAA,GAAAA,qBAAyB,AAKpC,CAAA,0BALoC,CAACvN,YAAY,EAAE;YACnDwN,UAAU,EAAE/B,sCAAsC,QAAU,GAAhDA,KAAAA,CAAgD,GAAhDA,sCAAsC,CAAEgC,QAAQ;YAC5DhB,kBAAkB,EAAEA,kBAAkB;YACtCG,kBAAkB;YAClBc,kBAAkB,EAAE,IAAI;SACzB,CAAC,CAAA;KACH;IAED,OAAO,IAAIzI,aAAY,QAAA,CAAC,MAAMyH,UAAU,EAAE,CAAC,CAAA;CAC5C"} \ No newline at end of file diff --git a/packages/next/server/dev/next-dev-server.js b/packages/next/server/dev/next-dev-server.js new file mode 100644 index 000000000000..a1f3e68343d4 --- /dev/null +++ b/packages/next/server/dev/next-dev-server.js @@ -0,0 +1,1461 @@ +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) +exports.default = void 0 +var _async_to_generator = + require('@swc/helpers/lib/_async_to_generator.js').default +var _extends = require('@swc/helpers/lib/_extends.js').default +var _interop_require_default = + require('@swc/helpers/lib/_interop_require_default.js').default +var _interop_require_wildcard = + require('@swc/helpers/lib/_interop_require_wildcard.js').default +var _object_without_properties_loose = + require('@swc/helpers/lib/_object_without_properties_loose.js').default +var _crypto = _interop_require_default(require('crypto')) +var _fs = _interop_require_default(require('fs')) +var _jestWorker = require('next/dist/compiled/jest-worker') +var _findUp = _interop_require_default(require('next/dist/compiled/find-up')) +var _path = require('path') +var _react = _interop_require_default(require('react')) +var _watchpack = _interop_require_default( + require('next/dist/compiled/watchpack') +) +var _output = require('../../build/output') +var _constants = require('../../lib/constants') +var _fileExists = require('../../lib/file-exists') +var _findPagesDir = require('../../lib/find-pages-dir') +var _loadCustomRoutes = _interop_require_default( + require('../../lib/load-custom-routes') +) +var _verifyTypeScriptSetup = require('../../lib/verifyTypeScriptSetup') +var _verifyPartytownSetup = require('../../lib/verify-partytown-setup') +var _constants1 = require('../../shared/lib/constants') +var _nextServer = _interop_require_wildcard(require('../next-server')) +var _routeMatcher = require('../../shared/lib/router/utils/route-matcher') +var _normalizePagePath = require('../../shared/lib/page-path/normalize-page-path') +var _absolutePathToPage = require('../../shared/lib/page-path/absolute-path-to-page') +var _router = _interop_require_default(require('../router')) +var _pathMatch = require('../../shared/lib/router/utils/path-match') +var _pathHasPrefix = require('../../shared/lib/router/utils/path-has-prefix') +var _removePathPrefix = require('../../shared/lib/router/utils/remove-path-prefix') +var _events = require('../../telemetry/events') +var _storage = require('../../telemetry/storage') +var _trace = require('../../trace') +var _hotReloader = _interop_require_default(require('./hot-reloader')) +var _findPageFile = require('../lib/find-page-file') +var _utils = require('../lib/utils') +var _coalescedFunction = require('../../lib/coalesced-function') +var _loadComponents = require('../load-components') +var _utils1 = require('../../shared/lib/utils') +var _middleware = require('next/dist/compiled/@next/react-dev-overlay/dist/middleware') +var Log = _interop_require_wildcard(require('../../build/output/log')) +var _isError = _interop_require_wildcard(require('../../lib/is-error')) +var _routeRegex = require('../../shared/lib/router/utils/route-regex') +var _utils2 = require('../../shared/lib/router/utils') +var _entries = require('../../build/entries') +var _getPageStaticInfo = require('../../build/analysis/get-page-static-info') +var _normalizePathSep = require('../../shared/lib/page-path/normalize-path-sep') +var _appPaths = require('../../shared/lib/router/utils/app-paths') +var _utils3 = require('../../build/utils') +var _webpackConfig = require('../../build/webpack-config') +var _loadJsconfig = _interop_require_default( + require('../../build/load-jsconfig') +) +// Load ReactDevOverlay only when needed +let ReactDevOverlayImpl +const ReactDevOverlay = (props) => { + if (ReactDevOverlayImpl === undefined) { + ReactDevOverlayImpl = + require('next/dist/compiled/@next/react-dev-overlay/dist/client').ReactDevOverlay + } + return ReactDevOverlayImpl(props) +} +class DevServer extends _nextServer.default { + getStaticPathsWorker() { + if (this.staticPathsWorker) { + return this.staticPathsWorker + } + this.staticPathsWorker = new _jestWorker.Worker( + require.resolve('./static-paths-worker'), + { + maxRetries: 1, + numWorkers: this.nextConfig.experimental.cpus, + enableWorkerThreads: this.nextConfig.experimental.workerThreads, + forkOptions: { + env: _extends({}, process.env, { + // discard --inspect/--inspect-brk flags from process.env.NODE_OPTIONS. Otherwise multiple Node.js debuggers + // would be started if user launch Next.js in debugging mode. The number of debuggers is linked to + // the number of workers Next.js tries to launch. The only worker users are interested in debugging + // is the main Next.js one + NODE_OPTIONS: (0, _utils).getNodeOptionsWithoutInspect(), + }), + }, + } + ) + this.staticPathsWorker.getStdout().pipe(process.stdout) + this.staticPathsWorker.getStderr().pipe(process.stderr) + return this.staticPathsWorker + } + getBuildId() { + return 'development' + } + addExportPathMapRoutes() { + var _this = this + return _async_to_generator(function* () { + // Makes `next export` exportPathMap work in development mode. + // So that the user doesn't have to define a custom server reading the exportPathMap + if (_this.nextConfig.exportPathMap) { + console.log('Defining routes from exportPathMap') + const exportPathMap = yield _this.nextConfig.exportPathMap( + {}, + { + dev: true, + dir: _this.dir, + outDir: null, + distDir: _this.distDir, + buildId: _this.buildId, + } + ) // In development we can't give a default path mapping + for (const path in exportPathMap) { + const { page, query = {} } = exportPathMap[path] + _this.router.addFsRoute({ + match: (0, _pathMatch).getPathMatch(path), + type: 'route', + name: `${path} exportpathmap route`, + fn: _async_to_generator(function* (req, res, _params, parsedUrl) { + const { query: urlQuery } = parsedUrl + Object.keys(urlQuery) + .filter((key) => query[key] === undefined) + .forEach((key) => + console.warn( + `Url '${path}' defines a query parameter '${key}' that is missing in exportPathMap` + ) + ) + const mergedQuery = _extends({}, urlQuery, query) + yield _this.render(req, res, page, mergedQuery, parsedUrl, true) + return { + finished: true, + } + }), + }) + } + } + })() + } + startWatcher() { + var _this = this + return _async_to_generator(function* () { + if (_this.webpackWatcher) { + return + } + const regexPageExtension = new RegExp( + `\\.+(?:${_this.nextConfig.pageExtensions.join('|')})$` + ) + let resolved = false + return new Promise( + _async_to_generator(function* (resolve, reject) { + // Watchpack doesn't emit an event for an empty directory + _fs.default.readdir(_this.pagesDir, (_, files) => { + if (files == null ? void 0 : files.length) { + return + } + if (!resolved) { + resolve() + resolved = true + } + }) + const wp = (_this.webpackWatcher = new _watchpack.default({ + ignored: + /([/\\]node_modules[/\\]|[/\\]\.next[/\\]|[/\\]\.git[/\\])/, + })) + const pages = [_this.pagesDir] + const app = _this.appDir ? [_this.appDir] : [] + const directories = [...pages, ...app] + const files1 = (0, _utils3).getPossibleMiddlewareFilenames( + (0, _path).join(_this.pagesDir, '..'), + _this.nextConfig.pageExtensions + ) + let nestedMiddleware = [] + const envFiles = [ + '.env.development.local', + '.env.local', + '.env.development', + '.env', + ].map((file) => (0, _path).join(_this.dir, file)) + files1.push(...envFiles) + // tsconfig/jsonfig paths hot-reloading + const tsconfigPaths = [ + (0, _path).join(_this.dir, 'tsconfig.json'), + (0, _path).join(_this.dir, 'jsconfig.json'), + ] + files1.push(...tsconfigPaths) + wp.watch({ + directories: [_this.dir], + startTime: 0, + }) + const fileWatchTimes = new Map() + let enabledTypeScript = _this.usingTypeScript + wp.on( + 'aggregated', + _async_to_generator(function* () { + let middlewareMatcher + const routedPages = [] + const knownFiles = wp.getTimeInfoEntries() + const appPaths1 = {} + const edgeRoutesSet = new Set() + let envChange = false + let tsconfigChange = false + for (const [fileName, meta] of knownFiles) { + if ( + !files1.includes(fileName) && + !directories.some((dir) => fileName.startsWith(dir)) + ) { + continue + } + const watchTime = fileWatchTimes.get(fileName) + const watchTimeChange = + watchTime && + watchTime !== (meta == null ? void 0 : meta.timestamp) + fileWatchTimes.set(fileName, meta.timestamp) + if (envFiles.includes(fileName)) { + if (watchTimeChange) { + envChange = true + } + continue + } + if (tsconfigPaths.includes(fileName)) { + if (fileName.endsWith('tsconfig.json')) { + enabledTypeScript = true + } + if (watchTimeChange) { + tsconfigChange = true + } + continue + } + if ( + (meta == null ? void 0 : meta.accuracy) === undefined || + !regexPageExtension.test(fileName) + ) { + continue + } + const isAppPath = Boolean( + _this.appDir && + (0, _normalizePathSep) + .normalizePathSep(fileName) + .startsWith( + (0, _normalizePathSep).normalizePathSep(_this.appDir) + ) + ) + const rootFile = (0, _absolutePathToPage).absolutePathToPage( + fileName, + { + pagesDir: _this.dir, + extensions: _this.nextConfig.pageExtensions, + } + ) + const staticInfo = yield (0, + _getPageStaticInfo).getPageStaticInfo({ + pageFilePath: fileName, + nextConfig: _this.nextConfig, + page: rootFile, + }) + if ((0, _utils3).isMiddlewareFile(rootFile)) { + var ref + _this.actualMiddlewareFile = rootFile + middlewareMatcher = + ((ref = staticInfo.middleware) == null + ? void 0 + : ref.pathMatcher) || new RegExp('.*') + edgeRoutesSet.add('/') + continue + } + if (fileName.endsWith('.ts') || fileName.endsWith('.tsx')) { + enabledTypeScript = true + } + let pageName = (0, _absolutePathToPage).absolutePathToPage( + fileName, + { + pagesDir: isAppPath ? _this.appDir : _this.pagesDir, + extensions: _this.nextConfig.pageExtensions, + keepIndex: isAppPath, + } + ) + if (isAppPath) { + if (!(0, _findPageFile).isLayoutsLeafPage(fileName)) { + continue + } + const originalPageName = pageName + pageName = (0, _appPaths).normalizeAppPath(pageName) || '/' + if (!appPaths1[pageName]) { + appPaths1[pageName] = [] + } + appPaths1[pageName].push(originalPageName) + if (routedPages.includes(pageName)) { + continue + } + } else { + // /index is preserved for root folder + pageName = pageName.replace(/\/index$/, '') || '/' + } + /** + * If there is a middleware that is not declared in the root we will + * warn without adding it so it doesn't make its way into the system. + */ if (/[\\\\/]_middleware$/.test(pageName)) { + nestedMiddleware.push(pageName) + continue + } + yield (0, _entries).runDependingOnPageType({ + page: pageName, + pageRuntime: staticInfo.runtime, + onClient: () => {}, + onServer: () => { + routedPages.push(pageName) + }, + onEdgeServer: () => { + routedPages.push(pageName) + edgeRoutesSet.add(pageName) + }, + }) + } + if (!_this.usingTypeScript && enabledTypeScript) { + // we tolerate the error here as this is best effort + // and the manual install command will be shown + yield _this + .verifyTypeScript() + .then(() => { + tsconfigChange = true + }) + .catch(() => {}) + } + if (envChange || tsconfigChange) { + var ref1, ref2, ref3 + if (envChange) { + _this.loadEnvConfig({ + dev: true, + forceReload: true, + }) + } + let tsconfigResult + if (tsconfigChange) { + try { + tsconfigResult = yield (0, _loadJsconfig).default( + _this.dir, + _this.nextConfig + ) + } catch (_) { + /* do we want to log if there are syntax errors in tsconfig while editing? */ + } + } + ;(ref1 = _this.hotReloader) == null + ? void 0 + : (ref2 = ref1.activeConfigs) == null + ? void 0 + : ref2.forEach((config, idx) => { + const isClient = idx === 0 + const isNodeServer = idx === 1 + const isEdgeServer = idx === 2 + const hasRewrites = + _this.customRoutes.rewrites.afterFiles.length > 0 || + _this.customRoutes.rewrites.beforeFiles.length > 0 || + _this.customRoutes.rewrites.fallback.length > 0 + if (tsconfigChange) { + var ref13, ref5 + ;(ref13 = config.resolve) == null + ? void 0 + : (ref5 = ref13.plugins) == null + ? void 0 + : ref5.forEach((plugin) => { + // look for the JsConfigPathsPlugin and update with + // the latest paths/baseUrl config + if ( + plugin && + plugin.jsConfigPlugin && + tsconfigResult + ) { + var ref, ref7, ref8 + const { resolvedBaseUrl, jsConfig } = + tsconfigResult + const currentResolvedBaseUrl = + plugin.resolvedBaseUrl + const resolvedUrlIndex = + (ref = config.resolve) == null + ? void 0 + : (ref7 = ref.modules) == null + ? void 0 + : ref7.findIndex( + (item) => + item === currentResolvedBaseUrl + ) + if ( + resolvedBaseUrl && + resolvedBaseUrl !== currentResolvedBaseUrl + ) { + var ref9, ref10 + // remove old baseUrl and add new one + if ( + resolvedUrlIndex && + resolvedUrlIndex > -1 + ) { + var ref11, ref12 + ;(ref11 = config.resolve) == null + ? void 0 + : (ref12 = ref11.modules) == null + ? void 0 + : ref12.splice(resolvedUrlIndex, 1) + } + ;(ref9 = config.resolve) == null + ? void 0 + : (ref10 = ref9.modules) == null + ? void 0 + : ref10.push(resolvedBaseUrl) + } + if ( + (jsConfig == null + ? void 0 + : (ref8 = jsConfig.compilerOptions) == null + ? void 0 + : ref8.paths) && + resolvedBaseUrl + ) { + Object.keys(plugin.paths).forEach((key) => { + delete plugin.paths[key] + }) + Object.assign( + plugin.paths, + jsConfig.compilerOptions.paths + ) + plugin.resolvedBaseUrl = resolvedBaseUrl + } + } + }) + } + if (envChange) { + var ref6 + ;(ref6 = config.plugins) == null + ? void 0 + : ref6.forEach((plugin) => { + // we look for the DefinePlugin definitions so we can + // update them on the active compilers + if ( + plugin && + typeof plugin.definitions === 'object' && + plugin.definitions.__NEXT_DEFINE_ENV + ) { + var ref, ref15 + const newDefine = (0, + _webpackConfig).getDefineEnv({ + dev: true, + config: _this.nextConfig, + distDir: _this.distDir, + isClient, + hasRewrites, + hasReactRoot: + (ref = _this.hotReloader) == null + ? void 0 + : ref.hasReactRoot, + isNodeServer, + isEdgeServer, + hasServerComponents: + (ref15 = _this.hotReloader) == null + ? void 0 + : ref15.hasServerComponents, + }) + Object.keys(plugin.definitions).forEach( + (key) => { + if (!(key in newDefine)) { + delete plugin.definitions[key] + } + } + ) + Object.assign(plugin.definitions, newDefine) + } + }) + } + }) + ;(ref3 = _this.hotReloader) == null ? void 0 : ref3.invalidate() + } + if (nestedMiddleware.length > 0) { + Log.error( + new _utils3.NestedMiddlewareError( + nestedMiddleware, + _this.dir, + _this.pagesDir + ).message + ) + nestedMiddleware = [] + } + _this.appPathRoutes = Object.fromEntries( + // Make sure to sort parallel routes to make the result deterministic. + Object.entries(appPaths1).map(([k, v]) => [k, v.sort()]) + ) + _this.edgeFunctions = [] + const edgeRoutes = Array.from(edgeRoutesSet) + ;(0, _utils2).getSortedRoutes(edgeRoutes).forEach((page) => { + let appPaths = _this.getOriginalAppPaths(page) + if (typeof appPaths === 'string') { + page = appPaths + } + const isRootMiddleware = page === '/' && !!middlewareMatcher + const middlewareRegex = isRootMiddleware + ? { + re: middlewareMatcher, + groups: {}, + } + : (0, _routeRegex).getMiddlewareRegex(page, { + catchAll: false, + }) + const routeItem = { + match: (0, _routeMatcher).getRouteMatcher(middlewareRegex), + page, + re: middlewareRegex.re, + } + if (isRootMiddleware) { + _this.middleware = routeItem + } else { + _this.edgeFunctions.push(routeItem) + } + }) + try { + var ref4 + // we serve a separate manifest with all pages for the client in + // dev mode so that we can match a page after a rewrite on the client + // before it has been built and is populated in the _buildManifest + const sortedRoutes = (0, _utils2).getSortedRoutes(routedPages) + if ( + !((ref4 = _this.sortedRoutes) == null + ? void 0 + : ref4.every((val, idx) => val === sortedRoutes[idx])) + ) { + // emit the change so clients fetch the update + _this.hotReloader.send(undefined, { + devPagesManifest: true, + }) + } + _this.sortedRoutes = sortedRoutes + _this.dynamicRoutes = _this.sortedRoutes + .filter(_utils2.isDynamicRoute) + .map((page) => ({ + page, + match: (0, _routeMatcher).getRouteMatcher( + (0, _routeRegex).getRouteRegex(page) + ), + })) + _this.router.setDynamicRoutes(_this.dynamicRoutes) + _this.router.setCatchallMiddleware( + _this.generateCatchAllMiddlewareRoute(true) + ) + if (!resolved) { + resolve() + resolved = true + } + } catch (e) { + if (!resolved) { + reject(e) + resolved = true + } else { + console.warn('Failed to reload dynamic routes:', e) + } + } + }) + ) + }) + ) + })() + } + stopWatcher() { + var _this = this + return _async_to_generator(function* () { + if (!_this.webpackWatcher) { + return + } + _this.webpackWatcher.close() + _this.webpackWatcher = null + })() + } + verifyTypeScript() { + var _this = this + return _async_to_generator(function* () { + if (_this.verifyingTypeScript) { + return + } + try { + _this.verifyingTypeScript = true + const verifyResult = yield (0, + _verifyTypeScriptSetup).verifyTypeScriptSetup({ + dir: _this.dir, + intentDirs: [_this.pagesDir, _this.appDir].filter(Boolean), + typeCheckPreflight: false, + tsconfigPath: _this.nextConfig.typescript.tsconfigPath, + disableStaticImages: _this.nextConfig.images.disableStaticImages, + }) + if (verifyResult.version) { + _this.usingTypeScript = true + } + } finally { + _this.verifyingTypeScript = false + } + })() + } + prepare() { + var _this = this, + _superprop_get_prepare = () => super.prepare + return _async_to_generator(function* () { + ;(0, _trace).setGlobal('distDir', _this.distDir) + ;(0, _trace).setGlobal('phase', _constants1.PHASE_DEVELOPMENT_SERVER) + yield _this.verifyTypeScript() + _this.customRoutes = yield (0, _loadCustomRoutes).default( + _this.nextConfig + ) + // reload router + const { redirects, rewrites, headers } = _this.customRoutes + if ( + rewrites.beforeFiles.length || + rewrites.afterFiles.length || + rewrites.fallback.length || + redirects.length || + headers.length + ) { + _this.router = new _router.default(_this.generateRoutes()) + } + _this.hotReloader = new _hotReloader.default(_this.dir, { + pagesDir: _this.pagesDir, + distDir: _this.distDir, + config: _this.nextConfig, + previewProps: _this.getPreviewProps(), + buildId: _this.buildId, + rewrites, + appDir: _this.appDir, + }) + yield _superprop_get_prepare().call(_this) + yield _this.addExportPathMapRoutes() + yield _this.hotReloader.start(true) + yield _this.startWatcher() + _this.setDevReady() + if (_this.nextConfig.experimental.nextScriptWorkers) { + yield (0, _verifyPartytownSetup).verifyPartytownSetup( + _this.dir, + (0, _path).join(_this.distDir, _constants1.CLIENT_STATIC_FILES_PATH) + ) + } + const telemetry = new _storage.Telemetry({ + distDir: _this.distDir, + }) + telemetry.record( + (0, _events).eventCliSession(_this.distDir, _this.nextConfig, { + webpackVersion: 5, + cliCommand: 'dev', + isSrcDir: (0, _path) + .relative(_this.dir, _this.pagesDir) + .startsWith('src'), + hasNowJson: !!(yield (0, _findUp).default('now.json', { + cwd: _this.dir, + })), + isCustomServer: _this.isCustomServer, + }) + ) + // This is required by the tracing subsystem. + ;(0, _trace).setGlobal('telemetry', telemetry) + process.on('unhandledRejection', (reason) => { + _this + .logErrorWithOriginalStack(reason, 'unhandledRejection') + .catch(() => {}) + }) + process.on('uncaughtException', (err) => { + _this + .logErrorWithOriginalStack(err, 'uncaughtException') + .catch(() => {}) + }) + })() + } + close() { + var _this = this + return _async_to_generator(function* () { + yield _this.stopWatcher() + yield _this.getStaticPathsWorker().end() + if (_this.hotReloader) { + yield _this.hotReloader.stop() + } + })() + } + hasPage(pathname) { + var _this = this + return _async_to_generator(function* () { + let normalizedPath + try { + normalizedPath = (0, _normalizePagePath).normalizePagePath(pathname) + } catch (err) { + console.error(err) + // if normalizing the page fails it means it isn't valid + // so it doesn't exist so don't throw and return false + // to ensure we return 404 instead of 500 + return false + } + if ((0, _utils3).isMiddlewareFile(normalizedPath)) { + return (0, _findPageFile) + .findPageFile( + _this.dir, + normalizedPath, + _this.nextConfig.pageExtensions + ) + .then(Boolean) + } + // check appDir first if enabled + if (_this.appDir) { + const pageFile = yield (0, _findPageFile).findPageFile( + _this.appDir, + normalizedPath, + _this.nextConfig.pageExtensions + ) + if (pageFile) return true + } + const pageFile = yield (0, _findPageFile).findPageFile( + _this.pagesDir, + normalizedPath, + _this.nextConfig.pageExtensions + ) + return !!pageFile + })() + } + _beforeCatchAllRender(req, res, params, parsedUrl) { + var _this = this + return _async_to_generator(function* () { + const { pathname } = parsedUrl + const pathParts = params.path || [] + const path = `/${pathParts.join('/')}` + // check for a public file, throwing error if there's a + // conflicting page + let decodedPath + try { + decodedPath = decodeURIComponent(path) + } catch (_) { + throw new _utils1.DecodeError('failed to decode param') + } + if (yield _this.hasPublicFile(decodedPath)) { + if (yield _this.hasPage(pathname)) { + const err = new Error( + `A conflicting public file and page file was found for path ${pathname} https://nextjs.org/docs/messages/conflicting-public-file-page` + ) + res.statusCode = 500 + yield _this.renderError(err, req, res, pathname, {}) + return true + } + yield _this.servePublic(req, res, pathParts) + return true + } + return false + })() + } + setupWebSocketHandler(server, _req) { + if (!this.addedUpgradeListener) { + var ref17 + this.addedUpgradeListener = true + server = + server || + ((ref17 = _req == null ? void 0 : _req.originalRequest.socket) == null + ? void 0 + : ref17.server) + if (!server) { + // this is very unlikely to happen but show an error in case + // it does somehow + Log.error( + `Invalid IncomingMessage received, make sure http.createServer is being used to handle requests.` + ) + } else { + const { basePath } = this.nextConfig + server.on('upgrade', (req, socket, head) => { + var ref + let assetPrefix = (this.nextConfig.assetPrefix || '').replace( + /^\/+/, + '' + ) + // assetPrefix can be a proxy server with a url locally + // if so, it's needed to send these HMR requests with a rewritten url directly to /_next/webpack-hmr + // otherwise account for a path-like prefix when listening to socket events + if (assetPrefix.startsWith('http')) { + assetPrefix = '' + } else if (assetPrefix) { + assetPrefix = `/${assetPrefix}` + } + if ( + (ref = req.url) == null + ? void 0 + : ref.startsWith( + `${basePath || assetPrefix || ''}/_next/webpack-hmr` + ) + ) { + var ref16 + ;(ref16 = this.hotReloader) == null + ? void 0 + : ref16.onHMR(req, socket, head) + } else { + this.handleUpgrade(req, socket, head) + } + }) + } + } + } + runMiddleware(params) { + var _this = this, + _superprop_get_runMiddleware = () => super.runMiddleware + return _async_to_generator(function* () { + try { + const result = yield _superprop_get_runMiddleware().call( + _this, + _extends({}, params, { + onWarning: (warn) => { + _this.logErrorWithOriginalStack(warn, 'warning') + }, + }) + ) + if ('finished' in result) { + return result + } + result.waitUntil.catch((error) => { + _this.logErrorWithOriginalStack(error, 'unhandledRejection') + }) + return result + } catch (error) { + if (error instanceof _utils1.DecodeError) { + throw error + } + /** + * We only log the error when it is not a MiddlewareNotFound error as + * in that case we should be already displaying a compilation error + * which is what makes the module not found. + */ if (!(error instanceof _utils1.MiddlewareNotFoundError)) { + _this.logErrorWithOriginalStack(error) + } + const err = (0, _isError).getProperError(error) + err.middleware = true + const { request, response, parsedUrl } = params + /** + * When there is a failure for an internal Next.js request from + * middleware we bypass the error without finishing the request + * so we can serve the required chunks to render the error. + */ if ( + request.url.includes('/_next/static') || + request.url.includes('/__nextjs_original-stack-frame') + ) { + return { + finished: false, + } + } + response.statusCode = 500 + _this.renderError(err, request, response, parsedUrl.pathname) + return { + finished: true, + } + } + })() + } + runEdgeFunction(params) { + var _this = this, + _superprop_get_runEdgeFunction = () => super.runEdgeFunction + return _async_to_generator(function* () { + try { + return _superprop_get_runEdgeFunction().call( + _this, + _extends({}, params, { + onWarning: (warn) => { + _this.logErrorWithOriginalStack(warn, 'warning') + }, + }) + ) + } catch (error) { + if (error instanceof _utils1.DecodeError) { + throw error + } + _this.logErrorWithOriginalStack(error, 'warning') + const err = (0, _isError).getProperError(error) + const { req, res, page } = params + res.statusCode = 500 + _this.renderError(err, req, res, page) + return null + } + })() + } + run(req, res, parsedUrl) { + var _this = this, + _superprop_get_run = () => super.run + return _async_to_generator(function* () { + yield _this.devReady + _this.setupWebSocketHandler(undefined, req) + const { basePath } = _this.nextConfig + let originalPathname = null + if ( + basePath && + (0, _pathHasPrefix).pathHasPrefix(parsedUrl.pathname || '/', basePath) + ) { + // strip basePath before handling dev bundles + // If replace ends up replacing the full url it'll be `undefined`, meaning we have to default it to `/` + originalPathname = parsedUrl.pathname + parsedUrl.pathname = (0, _removePathPrefix).removePathPrefix( + parsedUrl.pathname || '/', + basePath + ) + } + const { pathname } = parsedUrl + if (pathname.startsWith('/_next')) { + if ( + yield (0, _fileExists).fileExists( + (0, _path).join(_this.publicDir, '_next') + ) + ) { + throw new Error(_constants.PUBLIC_DIR_MIDDLEWARE_CONFLICT) + } + } + const { finished = false } = yield _this.hotReloader.run( + req.originalRequest, + res.originalResponse, + parsedUrl + ) + if (finished) { + return + } + if (originalPathname) { + // restore the path before continuing so that custom-routes can accurately determine + // if they should match against the basePath or not + parsedUrl.pathname = originalPathname + } + try { + return yield _superprop_get_run().call(_this, req, res, parsedUrl) + } catch (error) { + res.statusCode = 500 + const err = (0, _isError).getProperError(error) + try { + _this.logErrorWithOriginalStack(err).catch(() => {}) + return yield _this.renderError(err, req, res, pathname, { + __NEXT_PAGE: + ((0, _isError).default(err) && err.page) || pathname || '', + }) + } catch (internalErr) { + console.error(internalErr) + res.body('Internal Server Error').send() + } + } + })() + } + logErrorWithOriginalStack(err, type) { + var _this = this + return _async_to_generator(function* () { + let usedOriginalStack = false + if ((0, _isError).default(err) && err.stack) { + try { + const frames = (0, _middleware).parseStack(err.stack) + const frame = frames.find(({ file }) => { + return ( + !(file == null ? void 0 : file.startsWith('eval')) && + !(file == null ? void 0 : file.includes('web/adapter')) && + !(file == null ? void 0 : file.includes('sandbox/context')) + ) + }) + if (frame.lineNumber && (frame == null ? void 0 : frame.file)) { + var ref, ref19, ref20, ref21, ref22, ref23 + const moduleId = frame.file.replace( + /^(webpack-internal:\/\/\/|file:\/\/)/, + '' + ) + const src = (0, _middleware).getErrorSource(err) + const compilation = + src === _constants1.COMPILER_NAMES.edgeServer + ? (ref = _this.hotReloader) == null + ? void 0 + : (ref19 = ref.edgeServerStats) == null + ? void 0 + : ref19.compilation + : (ref20 = _this.hotReloader) == null + ? void 0 + : (ref21 = ref20.serverStats) == null + ? void 0 + : ref21.compilation + const source = yield (0, _middleware).getSourceById( + !!((ref22 = frame.file) == null + ? void 0 + : ref22.startsWith(_path.sep)) || + !!((ref23 = frame.file) == null + ? void 0 + : ref23.startsWith('file:')), + moduleId, + compilation + ) + const originalFrame = yield (0, + _middleware).createOriginalStackFrame({ + line: frame.lineNumber, + column: frame.column, + source, + frame, + modulePath: moduleId, + rootDirectory: _this.dir, + errorMessage: err.message, + compilation, + }) + if (originalFrame) { + const { originalCodeFrame, originalStackFrame } = originalFrame + const { file, lineNumber, column, methodName } = + originalStackFrame + Log[type === 'warning' ? 'warn' : 'error']( + `${file} (${lineNumber}:${column}) @ ${methodName}` + ) + if (src === _constants1.COMPILER_NAMES.edgeServer) { + err = err.message + } + if (type === 'warning') { + Log.warn(err) + } else if (type) { + Log.error(`${type}:`, err) + } else { + Log.error(err) + } + console[type === 'warning' ? 'warn' : 'error'](originalCodeFrame) + usedOriginalStack = true + } + } + } catch (_) { + // failed to load original stack using source maps + // this un-actionable by users so we don't show the + // internal error and only show the provided stack + } + } + if (!usedOriginalStack) { + if (type === 'warning') { + Log.warn(err) + } else if (type) { + Log.error(`${type}:`, err) + } else { + Log.error(err) + } + } + })() + } + // override production loading of routes-manifest + getCustomRoutes() { + // actual routes will be loaded asynchronously during .prepare() + return { + redirects: [], + rewrites: { + beforeFiles: [], + afterFiles: [], + fallback: [], + }, + headers: [], + } + } + getPreviewProps() { + if (this._devCachedPreviewProps) { + return this._devCachedPreviewProps + } + return (this._devCachedPreviewProps = { + previewModeId: _crypto.default.randomBytes(16).toString('hex'), + previewModeSigningKey: _crypto.default.randomBytes(32).toString('hex'), + previewModeEncryptionKey: _crypto.default.randomBytes(32).toString('hex'), + }) + } + getPagesManifest() { + return undefined + } + getAppPathsManifest() { + return undefined + } + getMiddleware() { + return this.middleware + } + getEdgeFunctions() { + var _edgeFunctions + return (_edgeFunctions = this.edgeFunctions) != null ? _edgeFunctions : [] + } + getServerComponentManifest() { + return undefined + } + getServerCSSManifest() { + return undefined + } + hasMiddleware() { + var _this = this + return _async_to_generator(function* () { + return _this.hasPage(_this.actualMiddlewareFile) + })() + } + ensureMiddleware() { + var _this = this + return _async_to_generator(function* () { + return _this.hotReloader.ensurePage({ + page: _this.actualMiddlewareFile, + }) + })() + } + ensureEdgeFunction({ page, appPaths }) { + var _this = this + return _async_to_generator(function* () { + return _this.hotReloader.ensurePage({ + page, + appPaths, + }) + })() + } + generateRoutes() { + const _ref = super.generateRoutes(), + { fsRoutes } = _ref, + otherRoutes = _object_without_properties_loose(_ref, ['fsRoutes']) + var _this = this + // In development we expose all compiled files for react-error-overlay's line show feature + // We use unshift so that we're sure the routes is defined before Next's default routes + fsRoutes.unshift({ + match: (0, _pathMatch).getPathMatch('/_next/development/:path*'), + type: 'route', + name: '_next/development catchall', + fn: _async_to_generator(function* (req, res, params) { + const p = (0, _path).join(_this.distDir, ...(params.path || [])) + yield _this.serveStatic(req, res, p) + return { + finished: true, + } + }), + }) + var _this1 = this + fsRoutes.unshift({ + match: (0, _pathMatch).getPathMatch( + `/_next/${_constants1.CLIENT_STATIC_FILES_PATH}/${this.buildId}/${_constants1.DEV_CLIENT_PAGES_MANIFEST}` + ), + type: 'route', + name: `_next/${_constants1.CLIENT_STATIC_FILES_PATH}/${this.buildId}/${_constants1.DEV_CLIENT_PAGES_MANIFEST}`, + fn: _async_to_generator(function* (_req, res) { + res.statusCode = 200 + res.setHeader('Content-Type', 'application/json; charset=utf-8') + res + .body( + JSON.stringify({ + pages: _this1.sortedRoutes, + }) + ) + .send() + return { + finished: true, + } + }), + }) + var _this2 = this + fsRoutes.unshift({ + match: (0, _pathMatch).getPathMatch( + `/_next/${_constants1.CLIENT_STATIC_FILES_PATH}/${this.buildId}/${_constants1.DEV_MIDDLEWARE_MANIFEST}` + ), + type: 'route', + name: `_next/${_constants1.CLIENT_STATIC_FILES_PATH}/${this.buildId}/${_constants1.DEV_MIDDLEWARE_MANIFEST}`, + fn: _async_to_generator(function* (_req, res) { + res.statusCode = 200 + res.setHeader('Content-Type', 'application/json; charset=utf-8') + res + .body( + JSON.stringify( + _this2.middleware + ? { + location: _this2.middleware.re.source, + } + : {} + ) + ) + .send() + return { + finished: true, + } + }), + }) + var _this3 = this + fsRoutes.push({ + match: (0, _pathMatch).getPathMatch('/:path*'), + type: 'route', + name: 'catchall public directory route', + fn: _async_to_generator(function* (req, res, params, parsedUrl) { + const { pathname } = parsedUrl + if (!pathname) { + throw new Error('pathname is undefined') + } + // Used in development to check public directory paths + if (yield _this3._beforeCatchAllRender(req, res, params, parsedUrl)) { + return { + finished: true, + } + } + return { + finished: false, + } + }), + }) + return _extends( + { + fsRoutes, + }, + otherRoutes + ) + } + // In development public files are not added to the router but handled as a fallback instead + generatePublicRoutes() { + return [] + } + // In development dynamic routes cannot be known ahead of time + getDynamicRoutes() { + return [] + } + _filterAmpDevelopmentScript(html, event) { + if (event.code !== 'DISALLOWED_SCRIPT_TAG') { + return true + } + const snippetChunks = html.split('\n') + let snippet + if ( + !(snippet = html.split('\n')[event.line - 1]) || + !(snippet = snippet.substring(event.col)) + ) { + return true + } + snippet = snippet + snippetChunks.slice(event.line).join('\n') + snippet = snippet.substring(0, snippet.indexOf('')) + return !snippet.includes('data-amp-development-mode-only') + } + getStaticPaths(pathname) { + var _this = this + return _async_to_generator(function* () { + // we lazy load the staticPaths to prevent the user + // from waiting on them for the page to load in dev mode + const __getStaticPaths = _async_to_generator(function* () { + const { + configFileName, + publicRuntimeConfig, + serverRuntimeConfig, + httpAgentOptions, + } = _this.nextConfig + const { locales, defaultLocale } = _this.nextConfig.i18n || {} + const paths = yield _this.getStaticPathsWorker().loadStaticPaths( + _this.distDir, + pathname, + !_this.renderOpts.dev && _this._isLikeServerless, + { + configFileName, + publicRuntimeConfig, + serverRuntimeConfig, + }, + httpAgentOptions, + locales, + defaultLocale + ) + return paths + }) + const { paths: staticPaths, fallback } = (yield (0, + _coalescedFunction).withCoalescedInvoke(__getStaticPaths)( + `staticPaths-${pathname}`, + [] + )).value + return { + staticPaths, + fallbackMode: + fallback === 'blocking' + ? 'blocking' + : fallback === true + ? 'static' + : false, + } + })() + } + ensureApiPage(pathname) { + var _this = this + return _async_to_generator(function* () { + return _this.hotReloader.ensurePage({ + page: pathname, + }) + })() + } + findPageComponents({ + pathname, + query = {}, + params = null, + isAppDir = false, + appPaths, + }) { + var _this = this, + _superprop_get_getServerComponentManifest = () => + super.getServerComponentManifest, + _superprop_get_getServerCSSManifest = () => super.getServerCSSManifest, + _superprop_get_findPageComponents = () => super.findPageComponents + return _async_to_generator(function* () { + yield _this.devReady + const compilationErr = yield _this.getCompilationError(pathname) + if (compilationErr) { + // Wrap build errors so that they don't get logged again + throw new _nextServer.WrappedBuildError(compilationErr) + } + try { + yield _this.hotReloader.ensurePage({ + page: pathname, + appPaths, + }) + const serverComponents = _this.nextConfig.experimental.serverComponents + // When the new page is compiled, we need to reload the server component + // manifest. + if (serverComponents) { + _this.serverComponentManifest = + _superprop_get_getServerComponentManifest().call(_this) + _this.serverCSSManifest = + _superprop_get_getServerCSSManifest().call(_this) + } + return _superprop_get_findPageComponents().call(_this, { + pathname, + query, + params, + isAppDir, + }) + } catch (err) { + if (err.code !== 'ENOENT') { + throw err + } + return null + } + })() + } + getFallbackErrorComponents() { + var _this = this + return _async_to_generator(function* () { + yield _this.hotReloader.buildFallbackError() + // Build the error page to ensure the fallback is built too. + // TODO: See if this can be moved into hotReloader or removed. + yield _this.hotReloader.ensurePage({ + page: '/_error', + }) + return yield (0, _loadComponents).loadDefaultErrorComponents( + _this.distDir + ) + })() + } + setImmutableAssetCacheControl(res) { + res.setHeader('Cache-Control', 'no-store, must-revalidate') + } + servePublic(req, res, pathParts) { + const p = (0, _path).join(this.publicDir, ...pathParts) + return this.serveStatic(req, res, p) + } + hasPublicFile(path) { + var _this = this + return _async_to_generator(function* () { + try { + const info = yield _fs.default.promises.stat( + (0, _path).join(_this.publicDir, path) + ) + return info.isFile() + } catch (_) { + return false + } + })() + } + getCompilationError(page) { + var _this = this + return _async_to_generator(function* () { + const errors = yield _this.hotReloader.getCompilationErrors(page) + if (errors.length === 0) return + // Return the very first error we found. + return errors[0] + })() + } + isServeableUrl(untrustedFileUrl) { + // This method mimics what the version of `send` we use does: + // 1. decodeURIComponent: + // https://github.com/pillarjs/send/blob/0.17.1/index.js#L989 + // https://github.com/pillarjs/send/blob/0.17.1/index.js#L518-L522 + // 2. resolve: + // https://github.com/pillarjs/send/blob/de073ed3237ade9ff71c61673a34474b30e5d45b/index.js#L561 + let decodedUntrustedFilePath + try { + // (1) Decode the URL so we have the proper file name + decodedUntrustedFilePath = decodeURIComponent(untrustedFileUrl) + } catch (e) { + return false + } + // (2) Resolve "up paths" to determine real request + const untrustedFilePath = (0, _path).resolve(decodedUntrustedFilePath) + // don't allow null bytes anywhere in the file path + if (untrustedFilePath.indexOf('\0') !== -1) { + return false + } + // During development mode, files can be added while the server is running. + // Checks for .next/static, .next/server, static and public. + // Note that in development .next/server is available for error reporting purposes. + // see `packages/next/server/next-server.ts` for more details. + if ( + untrustedFilePath.startsWith( + (0, _path).join(this.distDir, 'static') + _path.sep + ) || + untrustedFilePath.startsWith( + (0, _path).join(this.distDir, 'server') + _path.sep + ) || + untrustedFilePath.startsWith( + (0, _path).join(this.dir, 'static') + _path.sep + ) || + untrustedFilePath.startsWith( + (0, _path).join(this.dir, 'public') + _path.sep + ) + ) { + return true + } + return false + } + constructor(options) { + var ref, ref24 + super( + _extends({}, options, { + dev: true, + }) + ) + this.addedUpgradeListener = false + this.renderOpts.dev = true + this.renderOpts.ErrorDebug = ReactDevOverlay + this.devReady = new Promise((resolve) => { + this.setDevReady = resolve + }) + var ref25 + this.renderOpts.ampSkipValidation = + (ref25 = + (ref = this.nextConfig.experimental) == null + ? void 0 + : (ref24 = ref.amp) == null + ? void 0 + : ref24.skipValidation) != null + ? ref25 + : false + this.renderOpts.ampValidator = (html, pathname) => { + const validatorPath = + this.nextConfig.experimental && + this.nextConfig.experimental.amp && + this.nextConfig.experimental.amp.validator + const AmpHtmlValidator = require('next/dist/compiled/amphtml-validator') + return AmpHtmlValidator.getInstance(validatorPath).then((validator) => { + const result = validator.validateString(html) + ;(0, _output).ampValidation( + pathname, + result.errors + .filter((e) => e.severity === 'ERROR') + .filter((e) => this._filterAmpDevelopmentScript(html, e)), + result.errors.filter((e) => e.severity !== 'ERROR') + ) + }) + } + if (_fs.default.existsSync((0, _path).join(this.dir, 'static'))) { + console.warn( + `The static directory has been deprecated in favor of the public directory. https://nextjs.org/docs/messages/static-dir-deprecated` + ) + } + // setup upgrade listener eagerly when we can otherwise + // it will be done on the first request via req.socket.server + if (options.httpServer) { + this.setupWebSocketHandler(options.httpServer) + } + this.isCustomServer = !options.isNextDevCommand + // TODO: hot-reload root/pages dirs? + const { pages: pagesDir, appDir } = (0, _findPagesDir).findPagesDir( + this.dir, + this.nextConfig.experimental.appDir + ) + this.pagesDir = pagesDir + this.appDir = appDir + } +} +exports.default = DevServer + +//# sourceMappingURL=next-dev-server.js.map diff --git a/packages/next/server/dev/next-dev-server.js.map b/packages/next/server/dev/next-dev-server.js.map new file mode 100644 index 000000000000..324f900fa021 --- /dev/null +++ b/packages/next/server/dev/next-dev-server.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../server/dev/next-dev-server.ts"],"names":["Log","ReactDevOverlayImpl","ReactDevOverlay","props","undefined","require","DevServer","Server","getStaticPathsWorker","staticPathsWorker","Worker","resolve","maxRetries","numWorkers","nextConfig","experimental","cpus","enableWorkerThreads","workerThreads","forkOptions","env","process","NODE_OPTIONS","getNodeOptionsWithoutInspect","getStdout","pipe","stdout","getStderr","stderr","getBuildId","addExportPathMapRoutes","exportPathMap","console","log","dev","dir","outDir","distDir","buildId","path","page","query","router","addFsRoute","match","getPathMatch","type","name","fn","req","res","_params","parsedUrl","urlQuery","Object","keys","filter","key","forEach","warn","mergedQuery","render","finished","startWatcher","webpackWatcher","regexPageExtension","RegExp","pageExtensions","join","resolved","Promise","reject","fs","readdir","pagesDir","_","files","length","wp","Watchpack","ignored","pages","app","appDir","directories","getPossibleMiddlewareFilenames","pathJoin","nestedMiddleware","envFiles","map","file","push","tsconfigPaths","watch","startTime","fileWatchTimes","Map","enabledTypeScript","usingTypeScript","on","middlewareMatcher","routedPages","knownFiles","getTimeInfoEntries","appPaths","edgeRoutesSet","Set","envChange","tsconfigChange","fileName","meta","includes","some","startsWith","watchTime","get","watchTimeChange","timestamp","set","endsWith","accuracy","test","isAppPath","Boolean","normalizePathSep","rootFile","absolutePathToPage","extensions","staticInfo","getPageStaticInfo","pageFilePath","isMiddlewareFile","actualMiddlewareFile","middleware","pathMatcher","add","pageName","keepIndex","isLayoutsLeafPage","originalPageName","normalizeAppPath","replace","runDependingOnPageType","pageRuntime","runtime","onClient","onServer","onEdgeServer","verifyTypeScript","then","catch","loadEnvConfig","forceReload","tsconfigResult","loadJsConfig","hotReloader","activeConfigs","config","idx","isClient","isNodeServer","isEdgeServer","hasRewrites","customRoutes","rewrites","afterFiles","beforeFiles","fallback","plugins","plugin","jsConfigPlugin","jsConfig","resolvedBaseUrl","currentResolvedBaseUrl","resolvedUrlIndex","modules","findIndex","item","splice","compilerOptions","paths","assign","definitions","__NEXT_DEFINE_ENV","newDefine","getDefineEnv","hasReactRoot","hasServerComponents","invalidate","error","NestedMiddlewareError","message","appPathRoutes","fromEntries","entries","k","v","sort","edgeFunctions","edgeRoutes","Array","from","getSortedRoutes","getOriginalAppPaths","isRootMiddleware","middlewareRegex","re","groups","getMiddlewareRegex","catchAll","routeItem","getRouteMatcher","sortedRoutes","every","val","send","devPagesManifest","dynamicRoutes","isDynamicRoute","getRouteRegex","setDynamicRoutes","setCatchallMiddleware","generateCatchAllMiddlewareRoute","e","stopWatcher","close","verifyingTypeScript","verifyResult","verifyTypeScriptSetup","intentDirs","typeCheckPreflight","tsconfigPath","typescript","disableStaticImages","images","version","prepare","setGlobal","PHASE_DEVELOPMENT_SERVER","loadCustomRoutes","redirects","headers","Router","generateRoutes","HotReloader","previewProps","getPreviewProps","start","setDevReady","nextScriptWorkers","verifyPartytownSetup","CLIENT_STATIC_FILES_PATH","telemetry","Telemetry","record","eventCliSession","webpackVersion","cliCommand","isSrcDir","relative","hasNowJson","findUp","cwd","isCustomServer","reason","logErrorWithOriginalStack","err","end","stop","hasPage","pathname","normalizedPath","normalizePagePath","findPageFile","pageFile","_beforeCatchAllRender","params","pathParts","decodedPath","decodeURIComponent","DecodeError","hasPublicFile","Error","statusCode","renderError","servePublic","setupWebSocketHandler","server","_req","addedUpgradeListener","originalRequest","socket","basePath","head","assetPrefix","url","onHMR","handleUpgrade","runMiddleware","result","onWarning","waitUntil","MiddlewareNotFoundError","getProperError","request","response","runEdgeFunction","run","devReady","originalPathname","pathHasPrefix","removePathPrefix","fileExists","publicDir","PUBLIC_DIR_MIDDLEWARE_CONFLICT","originalResponse","__NEXT_PAGE","isError","internalErr","body","usedOriginalStack","stack","frames","parseStack","frame","find","lineNumber","moduleId","src","getErrorSource","compilation","COMPILER_NAMES","edgeServer","edgeServerStats","serverStats","source","getSourceById","sep","originalFrame","createOriginalStackFrame","line","column","modulePath","rootDirectory","errorMessage","originalCodeFrame","originalStackFrame","methodName","getCustomRoutes","_devCachedPreviewProps","previewModeId","crypto","randomBytes","toString","previewModeSigningKey","previewModeEncryptionKey","getPagesManifest","getAppPathsManifest","getMiddleware","getEdgeFunctions","getServerComponentManifest","getServerCSSManifest","hasMiddleware","ensureMiddleware","ensurePage","ensureEdgeFunction","fsRoutes","otherRoutes","unshift","p","serveStatic","DEV_CLIENT_PAGES_MANIFEST","setHeader","JSON","stringify","DEV_MIDDLEWARE_MANIFEST","location","generatePublicRoutes","getDynamicRoutes","_filterAmpDevelopmentScript","html","event","code","snippetChunks","split","snippet","substring","col","slice","indexOf","getStaticPaths","__getStaticPaths","configFileName","publicRuntimeConfig","serverRuntimeConfig","httpAgentOptions","locales","defaultLocale","i18n","loadStaticPaths","renderOpts","_isLikeServerless","staticPaths","withCoalescedInvoke","value","fallbackMode","ensureApiPage","findPageComponents","isAppDir","compilationErr","getCompilationError","WrappedBuildError","serverComponents","serverComponentManifest","serverCSSManifest","getFallbackErrorComponents","buildFallbackError","loadDefaultErrorComponents","setImmutableAssetCacheControl","info","promises","stat","isFile","errors","getCompilationErrors","isServeableUrl","untrustedFileUrl","decodedUntrustedFilePath","untrustedFilePath","pathResolve","constructor","options","ErrorDebug","ampSkipValidation","amp","skipValidation","ampValidator","validatorPath","validator","AmpHtmlValidator","getInstance","validateString","ampValidation","severity","existsSync","httpServer","isNextDevCommand","findPagesDir"],"mappings":"AAAA;;;;;;;;;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GAAGA,QAAQ;QACxB,IAAI,CAACS,MAAM,GAAGA,MAAM;KACrB;CAgsCF;kBAvyCoB7E,SAAS"} \ No newline at end of file diff --git a/packages/next/server/dev/next-dev-server.ts b/packages/next/server/dev/next-dev-server.ts index a65143e2e6df..0c5c0e34b908 100644 --- a/packages/next/server/dev/next-dev-server.ts +++ b/packages/next/server/dev/next-dev-server.ts @@ -544,10 +544,9 @@ export default class DevServer extends Server { ) const edgeRoutes = Array.from(edgeRoutesSet) this.edgeFunctions = getSortedRoutes(edgeRoutes).map((page) => { - const appPaths = this.getOriginalAppPaths(page) - - if (Array.isArray(appPaths)) { - page = appPaths[0] + const matchedAppPaths = this.getOriginalAppPaths(page) + if (Array.isArray(matchedAppPaths)) { + page = matchedAppPaths[0] } const edgeRegex = getRouteRegex(page) return { From e8e1332fac8337be0854479b52be0dad2002686b Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Thu, 1 Sep 2022 20:19:55 +0200 Subject: [PATCH 07/11] fix failed test --- .../build/webpack/loaders/next-app-loader.ts | 23 +++++++++---------- .../server/dev/on-demand-entry-handler.ts | 5 +++- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/next/build/webpack/loaders/next-app-loader.ts b/packages/next/build/webpack/loaders/next-app-loader.ts index 19e22e46bf13..16c89ce73b35 100644 --- a/packages/next/build/webpack/loaders/next-app-loader.ts +++ b/packages/next/build/webpack/loaders/next-app-loader.ts @@ -21,18 +21,6 @@ async function createTreeCodeFromPath({ ): Promise { const segmentPath = segments.join('/') - // Last item in the list is the page which can't have layouts by itself - if (segments[segments.length - 1] === 'page') { - const matchedPagePath = `${appDirPrefix}${segmentPath}` - const resolvedPagePath = await resolve(matchedPagePath) - // Use '' for segment as it's the page. There can't be a segment called '' so this is the safest way to add it. - return `{ - children: ${`['', {}, {filePath: ${JSON.stringify( - resolvedPagePath - )}, page: () => require(${JSON.stringify(resolvedPagePath)})}]`} - }` - } - // Existing tree are the children of the current segment const props: Record = {} @@ -46,6 +34,17 @@ async function createTreeCodeFromPath({ for (const [parallelKey, parallelSegment] of parallelSegments) { const parallelSegmentPath = segmentPath + '/' + parallelSegment + + if (parallelSegment === 'page') { + const matchedPagePath = `${appDirPrefix}${parallelSegmentPath}` + const resolvedPagePath = await resolve(matchedPagePath) + // Use '' for segment as it's the page. There can't be a segment called '' so this is the safest way to add it. + props[parallelKey] = `['', {}, {filePath: ${JSON.stringify( + resolvedPagePath + )}, page: () => require(${JSON.stringify(resolvedPagePath)})}]` + continue + } + const subtree = await createSubtreePropsFromSegmentPath([ ...segments, parallelSegment, diff --git a/packages/next/server/dev/on-demand-entry-handler.ts b/packages/next/server/dev/on-demand-entry-handler.ts index 5d19df6ac477..dc8868a5433f 100644 --- a/packages/next/server/dev/on-demand-entry-handler.ts +++ b/packages/next/server/dev/on-demand-entry-handler.ts @@ -41,7 +41,9 @@ function treePathToEntrypoint( // TODO-APP: modify this path to cover parallelRouteKey convention const path = (parentPath ? parentPath + '/' : '') + - (parallelRouteKey !== 'children' ? parallelRouteKey + '/' : '') + + (parallelRouteKey !== 'children' && !segment.startsWith('@') + ? parallelRouteKey + '/' + : '') + (segment === '' ? 'page' : segment) // Last segment @@ -493,6 +495,7 @@ export function onDemandEntryHandler({ toSend = { success: true } } } + return toSend } From 7e9ca278daaeab72b1ae45419fb19155ba7958fc Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Thu, 1 Sep 2022 20:40:29 +0200 Subject: [PATCH 08/11] remove built files --- packages/next/server/app-render.js | 835 ---------- packages/next/server/app-render.js.map | 1 - packages/next/server/dev/next-dev-server.js | 1461 ----------------- .../next/server/dev/next-dev-server.js.map | 1 - 4 files changed, 2298 deletions(-) delete mode 100644 packages/next/server/app-render.js delete mode 100644 packages/next/server/app-render.js.map delete mode 100644 packages/next/server/dev/next-dev-server.js delete mode 100644 packages/next/server/dev/next-dev-server.js.map diff --git a/packages/next/server/app-render.js b/packages/next/server/app-render.js deleted file mode 100644 index 68eed45bdb51..000000000000 --- a/packages/next/server/app-render.js +++ /dev/null @@ -1,835 +0,0 @@ -'use strict' -Object.defineProperty(exports, '__esModule', { - value: true, -}) -exports.renderToHTMLOrFlight = renderToHTMLOrFlight -var _react = _interopRequireDefault(require('react')) -var _querystring = require('querystring') -var _reactServerDomWebpack = require('next/dist/compiled/react-server-dom-webpack') -var _writerBrowserServer = require('next/dist/compiled/react-server-dom-webpack/writer.browser.server') -var _renderResult = _interopRequireDefault(require('./render-result')) -var _nodeWebStreamsHelper = require('./node-web-streams-helper') -var _utils = require('../shared/lib/router/utils') -var _htmlescape = require('./htmlescape') -var _utils1 = require('./utils') -var _matchSegments = require('../client/components/match-segments') -var _hooksClient = require('../client/components/hooks-client') -function _interopRequireDefault(obj) { - return obj && obj.__esModule - ? obj - : { - default: obj, - } -} -// this needs to be required lazily so that `next-server` can set -// the env before we require -const ReactDOMServer = _utils1.shouldUseReactRoot - ? require('react-dom/server.browser') - : require('react-dom/server') -/** - * Interop between "export default" and "module.exports". - */ function interopDefault(mod) { - return mod.default || mod -} -const rscCache = new Map() -var // Shadowing check does not work with TypeScript enums - // eslint-disable-next-line no-shadow - RecordStatus -;(function (RecordStatus) { - RecordStatus[(RecordStatus['Pending'] = 0)] = 'Pending' - RecordStatus[(RecordStatus['Resolved'] = 1)] = 'Resolved' - RecordStatus[(RecordStatus['Rejected'] = 2)] = 'Rejected' -})(RecordStatus || (RecordStatus = {})) -/** - * Create data fetching record for Promise. - */ function createRecordFromThenable(thenable) { - const record = { - status: 0, - value: thenable, - } - thenable.then( - function (value) { - if (record.status === 0) { - const resolvedRecord = record - resolvedRecord.status = 1 - resolvedRecord.value = value - } - }, - function (err) { - if (record.status === 0) { - const rejectedRecord = record - rejectedRecord.status = 2 - rejectedRecord.value = err - } - } - ) - return record -} -/** - * Read record value or throw Promise if it's not resolved yet. - */ function readRecordValue(record) { - if (record.status === 1) { - return record.value - } else { - throw record.value - } -} -/** - * Preload data fetching record before it is called during React rendering. - * If the record is already in the cache returns that record. - */ function preloadDataFetchingRecord(map, key, fetcher) { - let record = map.get(key) - if (!record) { - const thenable = fetcher() - record = createRecordFromThenable(thenable) - map.set(key, record) - } - return record -} -/** - * Render Flight stream. - * This is only used for renderToHTML, the Flight response does not need additional wrappers. - */ function useFlightResponse( - writable, - cachePrefix, - req, - serverComponentManifest -) { - const id = cachePrefix + ',' + _react.default.useId() - let entry = rscCache.get(id) - if (!entry) { - const [renderStream, forwardStream] = (0, - _nodeWebStreamsHelper).readableStreamTee(req) - entry = (0, _reactServerDomWebpack).createFromReadableStream(renderStream, { - moduleMap: serverComponentManifest.__ssr_module_mapping__, - }) - rscCache.set(id, entry) - let bootstrapped = false - // We only attach CSS chunks to the inlined data. - const forwardReader = forwardStream.getReader() - const writer = writable.getWriter() - function process() { - forwardReader.read().then(({ done, value }) => { - if (!bootstrapped) { - bootstrapped = true - writer.write( - (0, _nodeWebStreamsHelper).encodeText( - `` - ) - ) - } - if (done) { - rscCache.delete(id) - writer.close() - } else { - const responsePartial = (0, _nodeWebStreamsHelper).decodeText(value) - const scripts = `` - writer.write((0, _nodeWebStreamsHelper).encodeText(scripts)) - process() - } - }) - } - process() - } - return entry -} -/** - * Create a component that renders the Flight stream. - * This is only used for renderToHTML, the Flight response does not need additional wrappers. - */ function createServerComponentRenderer( - ComponentToRender, - ComponentMod, - { cachePrefix, transformStream, serverComponentManifest, serverContexts } -) { - // We need to expose the `__webpack_require__` API globally for - // react-server-dom-webpack. This is a hack until we find a better way. - if (ComponentMod.__next_app_webpack_require__ || ComponentMod.__next_rsc__) { - var ref - // @ts-ignore - globalThis.__next_require__ = - ComponentMod.__next_app_webpack_require__ || - ((ref = ComponentMod.__next_rsc__) == null - ? void 0 - : ref.__webpack_require__) - // @ts-ignore - globalThis.__next_chunk_load__ = () => Promise.resolve() - } - let RSCStream - const createRSCStream = () => { - if (!RSCStream) { - RSCStream = (0, _writerBrowserServer).renderToReadableStream( - /*#__PURE__*/ _react.default.createElement(ComponentToRender, null), - serverComponentManifest, - { - context: serverContexts, - } - ) - } - return RSCStream - } - const writable = transformStream.writable - return function ServerComponentWrapper() { - const reqStream = createRSCStream() - const response = useFlightResponse( - writable, - cachePrefix, - reqStream, - serverComponentManifest - ) - return response.readRoot() - } -} -/** - * Shorten the dynamic param in order to make it smaller when transmitted to the browser. - */ function getShortDynamicParamType(type) { - switch (type) { - case 'catchall': - return 'c' - case 'optional-catchall': - return 'oc' - case 'dynamic': - return 'd' - default: - throw new Error('Unknown dynamic param type') - } -} -/** - * Parse dynamic route segment to type of parameter - */ function getSegmentParam(segment) { - if (segment.startsWith('[[...') && segment.endsWith(']]')) { - return { - type: 'optional-catchall', - param: segment.slice(5, -2), - } - } - if (segment.startsWith('[...') && segment.endsWith(']')) { - return { - type: 'catchall', - param: segment.slice(4, -1), - } - } - if (segment.startsWith('[') && segment.endsWith(']')) { - return { - type: 'dynamic', - param: segment.slice(1, -1), - } - } - return null -} -/** - * Get inline tags based on server CSS manifest. Only used when rendering to HTML. - */ function getCssInlinedLinkTags( - serverComponentManifest, - serverCSSManifest, - filePath -) { - var ref - const layoutOrPageCss = - serverCSSManifest[filePath] || - ((ref = serverComponentManifest.__client_css_manifest__) == null - ? void 0 - : ref[filePath]) - if (!layoutOrPageCss) { - return [] - } - const chunks = new Set() - for (const css of layoutOrPageCss) { - const mod = serverComponentManifest[css] - if (mod) { - for (const chunk of mod.default.chunks) { - chunks.add(chunk) - } - } - } - return [...chunks] -} -async function renderToHTMLOrFlight( - req, - res, - pathname, - query, - renderOpts, - isPagesDir -) { - // @ts-expect-error createServerContext exists in react@experimental + react-dom@experimental - if (typeof _react.default.createServerContext === 'undefined') { - throw new Error( - '"app" directory requires React.createServerContext which is not available in the version of React you are using. Please update to react@experimental and react-dom@experimental.' - ) - } - // don't modify original query object - query = Object.assign({}, query) - const { - buildManifest, - serverComponentManifest, - serverCSSManifest = {}, - supportsDynamicHTML, - ComponentMod, - } = renderOpts - const isFlight = query.__flight__ !== undefined - // Handle client-side navigation to pages directory - if (isFlight && isPagesDir) { - ;(0, _utils1).stripInternalQueries(query) - const search = (0, _querystring).stringify(query) - // Empty so that the client-side router will do a full page navigation. - const flightData = pathname + (search ? `?${search}` : '') - return new _renderResult.default( - (0, _writerBrowserServer) - .renderToReadableStream(flightData, serverComponentManifest) - .pipeThrough((0, _nodeWebStreamsHelper).createBufferedTransformStream()) - ) - } - // TODO-APP: verify the tree is valid - // TODO-APP: verify query param is single value (not an array) - // TODO-APP: verify tree can't grow out of control - /** - * Router state provided from the client-side router. Used to handle rendering from the common layout down. - */ const providedFlightRouterState = isFlight - ? query.__flight_router_state_tree__ - ? JSON.parse(query.__flight_router_state_tree__) - : {} - : undefined - ;(0, _utils1).stripInternalQueries(query) - const pageIsDynamic = (0, _utils).isDynamicRoute(pathname) - const LayoutRouter = ComponentMod.LayoutRouter - const HotReloader = ComponentMod.HotReloader - const headers = req.headers - // TODO-APP: fix type of req - // @ts-expect-error - const cookies = req.cookies - /** - * The tree created in next-app-loader that holds component segments and modules - */ const loaderTree = ComponentMod.tree - const tryGetPreviewData = - process.env.NEXT_RUNTIME === 'edge' - ? () => false - : require('./api-utils/node').tryGetPreviewData - // Reads of this are cached on the `req` object, so this should resolve - // instantly. There's no need to pass this data down from a previous - // invoke, where we'd have to consider server & serverless. - const previewData = tryGetPreviewData(req, res, renderOpts.previewProps) - const isPreview = previewData !== false - /** - * Server Context is specifically only available in Server Components. - * It has to hold values that can't change while rendering from the common layout down. - * An example of this would be that `headers` are available but `searchParams` are not because that'd mean we have to render from the root layout down on all requests. - */ const serverContexts = [ - ['WORKAROUND', null], - ['HeadersContext', headers], - ['CookiesContext', cookies], - ['PreviewDataContext', previewData], - ] - /** - * Used to keep track of in-flight / resolved data fetching Promises. - */ const dataCache = new Map() - /** - * Dynamic parameters. E.g. when you visit `/dashboard/vercel` which is rendered by `/dashboard/[slug]` the value will be {"slug": "vercel"}. - */ const pathParams = renderOpts.params - /** - * Parse the dynamic segment and return the associated value. - */ const getDynamicParamFromSegment = ( - // [slug] / [[slug]] / [...slug] - segment - ) => { - const segmentParam = getSegmentParam(segment) - if (!segmentParam) { - return null - } - const key = segmentParam.param - const value = pathParams[key] - if (!value) { - // Handle case where optional catchall does not have a value, e.g. `/dashboard/[...slug]` when requesting `/dashboard` - if (segmentParam.type === 'optional-catchall') { - const type = getShortDynamicParamType(segmentParam.type) - return { - param: key, - value: null, - type: type, - // This value always has to be a string. - treeSegment: [key, '', type], - } - } - return null - } - const type = getShortDynamicParamType(segmentParam.type) - return { - param: key, - // The value that is passed to user code. - value: value, - // The value that is rendered in the router tree. - treeSegment: [key, Array.isArray(value) ? value.join('/') : value, type], - type: type, - } - } - const createFlightRouterStateFromLoaderTree = ([ - segment, - parallelRoutes, - { loading }, - ]) => { - const hasLoading = Boolean(loading) - const dynamicParam = getDynamicParamFromSegment(segment) - const segmentTree = [dynamicParam ? dynamicParam.treeSegment : segment, {}] - if (parallelRoutes) { - segmentTree[1] = Object.keys(parallelRoutes).reduce( - (existingValue, currentValue) => { - existingValue[currentValue] = createFlightRouterStateFromLoaderTree( - parallelRoutes[currentValue] - ) - return existingValue - }, - {} - ) - } - if (hasLoading) { - segmentTree[4] = 'loading' - } - return segmentTree - } - /** - * Use the provided loader tree to create the React Component tree. - */ const createComponentTree = async ({ - createSegmentPath, - loaderTree: [segment, parallelRoutes, { filePath, layout, loading, page }], - parentParams, - firstItem, - rootLayoutIncluded, - }) => { - // TODO-APP: enable stylesheet per layout/page - const stylesheets = getCssInlinedLinkTags( - serverComponentManifest, - serverCSSManifest, - filePath - ) - const Loading = loading ? await interopDefault(loading()) : undefined - const isLayout = typeof layout !== 'undefined' - const isPage = typeof page !== 'undefined' - const layoutOrPageMod = isLayout - ? await layout() - : isPage - ? await page() - : undefined - /** - * Checks if the current segment is a root layout. - */ const rootLayoutAtThisLevel = isLayout && !rootLayoutIncluded - /** - * Checks if the current segment or any level above it has a root layout. - */ const rootLayoutIncludedAtThisLevelOrAbove = - rootLayoutIncluded || rootLayoutAtThisLevel - /** - * Check if the current layout/page is a client component - */ const isClientComponentModule = - layoutOrPageMod && !layoutOrPageMod.hasOwnProperty('__next_rsc__') - /** - * The React Component to render. - */ const Component = layoutOrPageMod - ? interopDefault(layoutOrPageMod) - : undefined - // Handle dynamic segment params. - const segmentParam = getDynamicParamFromSegment(segment) - /** - * Create object holding the parent params and current params, this is passed to getServerSideProps and getStaticProps. - */ const currentParams = // Handle null case where dynamic param is optional - segmentParam && segmentParam.value !== null - ? { - ...parentParams, - [segmentParam.param]: segmentParam.value, - } - : parentParams - // Resolve the segment param - const actualSegment = segmentParam ? segmentParam.treeSegment : segment - // This happens outside of rendering in order to eagerly kick off data fetching for layouts / the page further down - const parallelRouteMap = await Promise.all( - Object.keys(parallelRoutes).map(async (parallelRouteKey) => { - const currentSegmentPath = firstItem - ? [parallelRouteKey] - : [actualSegment, parallelRouteKey] - // Create the child component - const { Component: ChildComponent } = await createComponentTree({ - createSegmentPath: (child) => { - return createSegmentPath([...currentSegmentPath, ...child]) - }, - loaderTree: parallelRoutes[parallelRouteKey], - parentParams: currentParams, - rootLayoutIncluded: rootLayoutIncludedAtThisLevelOrAbove, - }) - const childSegment = parallelRoutes[parallelRouteKey][0] - const childSegmentParam = getDynamicParamFromSegment(childSegment) - const childProp = { - current: /*#__PURE__*/ _react.default.createElement( - ChildComponent, - null - ), - segment: childSegmentParam - ? childSegmentParam.treeSegment - : childSegment, - } - // This is turned back into an object below. - return [ - parallelRouteKey, - /*#__PURE__*/ _react.default.createElement(LayoutRouter, { - parallelRouterKey: parallelRouteKey, - segmentPath: createSegmentPath(currentSegmentPath), - loading: Loading - ? /*#__PURE__*/ _react.default.createElement(Loading, null) - : undefined, - childProp: childProp, - rootLayoutIncluded: rootLayoutIncludedAtThisLevelOrAbove, - }), - ] - }) - ) - // Convert the parallel route map into an object after all promises have been resolved. - const parallelRouteComponents = parallelRouteMap.reduce( - (list, [parallelRouteKey, Comp]) => { - list[parallelRouteKey] = Comp - return list - }, - {} - ) - // When the segment does not have a layout or page we still have to add the layout router to ensure the path holds the loading component - if (!Component) { - return { - Component: () => - /*#__PURE__*/ _react.default.createElement( - _react.default.Fragment, - null, - parallelRouteComponents.children - ), - } - } - const segmentPath = createSegmentPath([actualSegment]) - const dataCacheKey = JSON.stringify(segmentPath) - let fetcher = null - // TODO-APP: pass a shared cache from previous getStaticProps/getServerSideProps calls? - if (!isClientComponentModule && layoutOrPageMod.getServerSideProps) { - // TODO-APP: recommendation for i18n - // locales: (renderOpts as any).locales, // always the same - // locale: (renderOpts as any).locale, // /nl/something -> nl - // defaultLocale: (renderOpts as any).defaultLocale, // changes based on domain - const getServerSidePropsContext = { - headers, - cookies, - layoutSegments: segmentPath, - // TODO-APP: change pathname to actual pathname, it holds the dynamic parameter currently - ...(isPage - ? { - searchParams: query, - pathname, - } - : {}), - ...(pageIsDynamic - ? { - params: currentParams, - } - : undefined), - ...(isPreview - ? { - preview: true, - previewData: previewData, - } - : undefined), - } - fetcher = () => - Promise.resolve( - layoutOrPageMod.getServerSideProps(getServerSidePropsContext) - ) - } - // TODO-APP: implement layout specific caching for getStaticProps - if (!isClientComponentModule && layoutOrPageMod.getStaticProps) { - const getStaticPropsContext = { - layoutSegments: segmentPath, - ...(isPage - ? { - pathname, - } - : {}), - ...(pageIsDynamic - ? { - params: currentParams, - } - : undefined), - ...(isPreview - ? { - preview: true, - previewData: previewData, - } - : undefined), - } - fetcher = () => - Promise.resolve(layoutOrPageMod.getStaticProps(getStaticPropsContext)) - } - if (fetcher) { - // Kick off data fetching before rendering, this ensures there is no waterfall for layouts as - // all data fetching required to render the page is kicked off simultaneously - preloadDataFetchingRecord(dataCache, dataCacheKey, fetcher) - } - return { - Component: () => { - let props - // The data fetching was kicked off before rendering (see above) - // if the data was not resolved yet the layout rendering will be suspended - if (fetcher) { - const record = preloadDataFetchingRecord( - dataCache, - dataCacheKey, - fetcher - ) - // Result of calling getStaticProps or getServerSideProps. If promise is not resolve yet it will suspend. - const recordValue = readRecordValue(record) - if (props) { - props = Object.assign({}, props, recordValue.props) - } else { - props = recordValue.props - } - } - return /*#__PURE__*/ _react.default.createElement( - _react.default.Fragment, - null, - stylesheets - ? stylesheets.map((href) => - /*#__PURE__*/ _react.default.createElement('link', { - rel: 'stylesheet', - href: `/_next/${href}?ts=${Date.now()}`, - // `Precedence` is an opt-in signal for React to handle - // resource loading and deduplication, etc: - // https://github.com/facebook/react/pull/25060 - // @ts-ignore - precedence: 'high', - key: href, - }) - ) - : null, - /*#__PURE__*/ _react.default.createElement( - Component, - Object.assign( - {}, - props, - parallelRouteComponents, - { - // TODO-APP: params and query have to be blocked parallel route names. Might have to add a reserved name list. - // Params are always the current params that apply to the layout - // If you have a `/dashboard/[team]/layout.js` it will provide `team` as a param but not anything further down. - params: currentParams, - }, - isPage - ? { - searchParams: query, - } - : {} - ) - ) - ) - }, - } - } - // Handle Flight render request. This is only used when client-side navigating. E.g. when you `router.push('/dashboard')` or `router.reload()`. - if (isFlight) { - // TODO-APP: throw on invalid flightRouterState - /** - * Use router state to decide at what common layout to render the page. - * This can either be the common layout between two pages or a specific place to start rendering from using the "refetch" marker in the tree. - */ const walkTreeWithFlightRouterState = async ( - loaderTreeToFilter, - parentParams, - flightRouterState, - parentRendered - ) => { - const [segment, parallelRoutes] = loaderTreeToFilter - const parallelRoutesKeys = Object.keys(parallelRoutes) - // Because this function walks to a deeper point in the tree to start rendering we have to track the dynamic parameters up to the point where rendering starts - // That way even when rendering the subtree getServerSideProps/getStaticProps get the right parameters. - const segmentParam = getDynamicParamFromSegment(segment) - const currentParams = // Handle null case where dynamic param is optional - segmentParam && segmentParam.value !== null - ? { - ...parentParams, - [segmentParam.param]: segmentParam.value, - } - : parentParams - const actualSegment = segmentParam ? segmentParam.treeSegment : segment - /** - * Decide if the current segment is where rendering has to start. - */ const renderComponentsOnThisLevel = // No further router state available - !flightRouterState || // Segment in router state does not match current segment - !(0, _matchSegments).matchSegment( - actualSegment, - flightRouterState[0] - ) || // Last item in the tree - parallelRoutesKeys.length === 0 || // Explicit refresh - flightRouterState[3] === 'refetch' - if (!parentRendered && renderComponentsOnThisLevel) { - return [ - actualSegment, - // Create router state using the slice of the loaderTree - createFlightRouterStateFromLoaderTree(loaderTreeToFilter), - // Create component tree using the slice of the loaderTree - /*#__PURE__*/ _react.default.createElement( - ( - await createComponentTree( - // This ensures flightRouterPath is valid and filters down the tree - { - createSegmentPath: (child) => child, - loaderTree: loaderTreeToFilter, - parentParams: currentParams, - firstItem: true, - } - ) - ).Component - ), - ] - } - // Walk through all parallel routes. - for (const parallelRouteKey of parallelRoutesKeys) { - const parallelRoute = parallelRoutes[parallelRouteKey] - const path = await walkTreeWithFlightRouterState( - parallelRoute, - currentParams, - flightRouterState && flightRouterState[1][parallelRouteKey], - parentRendered || renderComponentsOnThisLevel - ) - if (typeof path[path.length - 1] !== 'string') { - return [actualSegment, parallelRouteKey, ...path] - } - } - return [actualSegment] - } - // Flight data that is going to be passed to the browser. - // Currently a single item array but in the future multiple patches might be combined in a single request. - const flightData = [ - // TODO-APP: change walk to output without '' - ( - await walkTreeWithFlightRouterState( - loaderTree, - {}, - providedFlightRouterState - ) - ).slice(1), - ] - return new _renderResult.default( - (0, _writerBrowserServer) - .renderToReadableStream(flightData, serverComponentManifest, { - context: serverContexts, - }) - .pipeThrough((0, _nodeWebStreamsHelper).createBufferedTransformStream()) - ) - } - // Below this line is handling for rendering to HTML. - // Create full component tree from root to leaf. - const { Component: ComponentTree } = await createComponentTree({ - createSegmentPath: (child) => child, - loaderTree: loaderTree, - parentParams: {}, - firstItem: true, - }) - // AppRouter is provided by next-app-loader - const AppRouter = ComponentMod.AppRouter - let serverComponentsInlinedTransformStream = new TransformStream() - // TODO-APP: validate req.url as it gets passed to render. - const initialCanonicalUrl = req.url - /** - * A new React Component that renders the provided React Component - * using Flight which can then be rendered to HTML. - */ const ServerComponentsRenderer = createServerComponentRenderer( - () => { - const initialTree = createFlightRouterStateFromLoaderTree(loaderTree) - return /*#__PURE__*/ _react.default.createElement( - AppRouter, - { - hotReloader: - HotReloader && - /*#__PURE__*/ _react.default.createElement(HotReloader, { - assetPrefix: renderOpts.assetPrefix || '', - }), - initialCanonicalUrl: initialCanonicalUrl, - initialTree: initialTree, - }, - /*#__PURE__*/ _react.default.createElement(ComponentTree, null) - ) - }, - ComponentMod, - { - cachePrefix: initialCanonicalUrl, - transformStream: serverComponentsInlinedTransformStream, - serverComponentManifest, - serverContexts, - } - ) - const flushEffectsCallbacks = new Set() - function FlushEffects({ children }) { - // Reset flushEffectsHandler on each render - flushEffectsCallbacks.clear() - const addFlushEffects = _react.default.useCallback((handler) => { - flushEffectsCallbacks.add(handler) - }, []) - return /*#__PURE__*/ _react.default.createElement( - _hooksClient.FlushEffectsContext.Provider, - { - value: addFlushEffects, - }, - children - ) - } - /** - * Rules of Static & Dynamic HTML: - * - * 1.) We must generate static HTML unless the caller explicitly opts - * in to dynamic HTML support. - * - * 2.) If dynamic HTML support is requested, we must honor that request - * or throw an error. It is the sole responsibility of the caller to - * ensure they aren't e.g. requesting dynamic HTML for an AMP page. - * - * These rules help ensure that other existing features like request caching, - * coalescing, and ISR continue working as intended. - */ const generateStaticHTML = supportsDynamicHTML !== true - const bodyResult = async () => { - const content = /*#__PURE__*/ _react.default.createElement( - FlushEffects, - null, - /*#__PURE__*/ _react.default.createElement(ServerComponentsRenderer, null) - ) - const flushEffectHandler = () => { - const flushed = ReactDOMServer.renderToString( - /*#__PURE__*/ _react.default.createElement( - _react.default.Fragment, - null, - Array.from(flushEffectsCallbacks).map((callback) => callback()) - ) - ) - return flushed - } - const renderStream = await (0, _nodeWebStreamsHelper).renderToInitialStream( - { - ReactDOMServer, - element: content, - streamOptions: { - // Include hydration scripts in the HTML - bootstrapScripts: buildManifest.rootMainFiles.map( - (src) => `${renderOpts.assetPrefix || ''}/_next/` + src - ), - }, - } - ) - return await (0, _nodeWebStreamsHelper).continueFromInitialStream( - renderStream, - { - dataStream: - serverComponentsInlinedTransformStream == null - ? void 0 - : serverComponentsInlinedTransformStream.readable, - generateStaticHTML: generateStaticHTML, - flushEffectHandler, - flushEffectsToHead: true, - } - ) - } - return new _renderResult.default(await bodyResult()) -} - -//# sourceMappingURL=app-render.js.map diff --git a/packages/next/server/app-render.js.map b/packages/next/server/app-render.js.map deleted file mode 100644 index 31445ecc2683..000000000000 --- a/packages/next/server/app-render.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../server/app-render.tsx"],"names":["renderToHTMLOrFlight","ReactDOMServer","shouldUseReactRoot","require","interopDefault","mod","default","rscCache","Map","RecordStatus","Pending","Resolved","Rejected","createRecordFromThenable","thenable","record","status","value","then","resolvedRecord","err","rejectedRecord","readRecordValue","preloadDataFetchingRecord","map","key","fetcher","get","set","useFlightResponse","writable","cachePrefix","req","serverComponentManifest","id","React","useId","entry","renderStream","forwardStream","readableStreamTee","createFromReadableStream","moduleMap","__ssr_module_mapping__","bootstrapped","forwardReader","getReader","writer","getWriter","process","read","done","write","encodeText","htmlEscapeJsonString","JSON","stringify","delete","close","responsePartial","decodeText","scripts","createServerComponentRenderer","ComponentToRender","ComponentMod","transformStream","serverContexts","__next_app_webpack_require__","__next_rsc__","globalThis","__next_require__","__webpack_require__","__next_chunk_load__","Promise","resolve","RSCStream","createRSCStream","renderToReadableStream","context","ServerComponentWrapper","reqStream","response","readRoot","getShortDynamicParamType","type","Error","getSegmentParam","segment","startsWith","endsWith","param","slice","getCssInlinedLinkTags","serverCSSManifest","filePath","layoutOrPageCss","__client_css_manifest__","chunks","Set","css","chunk","add","res","pathname","query","renderOpts","isPagesDir","createServerContext","Object","assign","buildManifest","supportsDynamicHTML","isFlight","__flight__","undefined","stripInternalQueries","search","stringifyQuery","flightData","RenderResult","pipeThrough","createBufferedTransformStream","providedFlightRouterState","__flight_router_state_tree__","parse","pageIsDynamic","isDynamicRoute","LayoutRouter","HotReloader","headers","cookies","loaderTree","tree","tryGetPreviewData","env","NEXT_RUNTIME","previewData","previewProps","isPreview","dataCache","pathParams","params","getDynamicParamFromSegment","segmentParam","treeSegment","Array","isArray","join","createFlightRouterStateFromLoaderTree","parallelRoutes","loading","hasLoading","Boolean","dynamicParam","segmentTree","keys","reduce","existingValue","currentValue","createComponentTree","createSegmentPath","layout","page","parentParams","firstItem","rootLayoutIncluded","stylesheets","Loading","isLayout","isPage","layoutOrPageMod","rootLayoutAtThisLevel","rootLayoutIncludedAtThisLevelOrAbove","isClientComponentModule","hasOwnProperty","Component","currentParams","actualSegment","parallelRouteMap","all","parallelRouteKey","currentSegmentPath","ChildComponent","child","childSegment","childSegmentParam","childProp","current","parallelRouterKey","segmentPath","parallelRouteComponents","list","Comp","children","dataCacheKey","getServerSideProps","getServerSidePropsContext","layoutSegments","searchParams","preview","getStaticProps","getStaticPropsContext","props","recordValue","href","link","rel","Date","now","precedence","walkTreeWithFlightRouterState","loaderTreeToFilter","flightRouterState","parentRendered","parallelRoutesKeys","renderComponentsOnThisLevel","matchSegment","length","createElement","parallelRoute","path","ComponentTree","AppRouter","serverComponentsInlinedTransformStream","TransformStream","initialCanonicalUrl","url","ServerComponentsRenderer","initialTree","hotReloader","assetPrefix","flushEffectsCallbacks","FlushEffects","clear","addFlushEffects","useCallback","handler","FlushEffectsContext","Provider","generateStaticHTML","bodyResult","content","flushEffectHandler","flushed","renderToString","from","callback","renderToInitialStream","element","streamOptions","bootstrapScripts","rootMainFiles","src","continueFromInitialStream","dataStream","readable","flushEffectsToHead"],"mappings":"AAAA;;;;QAsZsBA,oBAAoB,GAApBA,oBAAoB;AAlZxB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACmC,IAAA,YAAa,WAAb,aAAa,CAAA;AAChC,IAAA,sBAA6C,WAA7C,6CAA6C,CAAA;AAC/C,IAAA,oBAAmE,WAAnE,mEAAmE,CAAA;AAEjF,IAAA,aAAiB,kCAAjB,iBAAiB,EAAA;AAQnC,IAAA,qBAA2B,WAA3B,2BAA2B,CAAA;AACH,IAAA,MAA4B,WAA5B,4BAA4B,CAAA;AACtB,IAAA,WAAc,WAAd,cA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C,CAAA;KACH;IAED,OAAO,IAAIzI,aAAY,QAAA,CAAC,MAAMyH,UAAU,EAAE,CAAC,CAAA;CAC5C"} \ No newline at end of file diff --git a/packages/next/server/dev/next-dev-server.js b/packages/next/server/dev/next-dev-server.js deleted file mode 100644 index a1f3e68343d4..000000000000 --- a/packages/next/server/dev/next-dev-server.js +++ /dev/null @@ -1,1461 +0,0 @@ -'use strict' -Object.defineProperty(exports, '__esModule', { - value: true, -}) -exports.default = void 0 -var _async_to_generator = - require('@swc/helpers/lib/_async_to_generator.js').default -var _extends = require('@swc/helpers/lib/_extends.js').default -var _interop_require_default = - require('@swc/helpers/lib/_interop_require_default.js').default -var _interop_require_wildcard = - require('@swc/helpers/lib/_interop_require_wildcard.js').default -var _object_without_properties_loose = - require('@swc/helpers/lib/_object_without_properties_loose.js').default -var _crypto = _interop_require_default(require('crypto')) -var _fs = _interop_require_default(require('fs')) -var _jestWorker = require('next/dist/compiled/jest-worker') -var _findUp = _interop_require_default(require('next/dist/compiled/find-up')) -var _path = require('path') -var _react = _interop_require_default(require('react')) -var _watchpack = _interop_require_default( - require('next/dist/compiled/watchpack') -) -var _output = require('../../build/output') -var _constants = require('../../lib/constants') -var _fileExists = require('../../lib/file-exists') -var _findPagesDir = require('../../lib/find-pages-dir') -var _loadCustomRoutes = _interop_require_default( - require('../../lib/load-custom-routes') -) -var _verifyTypeScriptSetup = require('../../lib/verifyTypeScriptSetup') -var _verifyPartytownSetup = require('../../lib/verify-partytown-setup') -var _constants1 = require('../../shared/lib/constants') -var _nextServer = _interop_require_wildcard(require('../next-server')) -var _routeMatcher = require('../../shared/lib/router/utils/route-matcher') -var _normalizePagePath = require('../../shared/lib/page-path/normalize-page-path') -var _absolutePathToPage = require('../../shared/lib/page-path/absolute-path-to-page') -var _router = _interop_require_default(require('../router')) -var _pathMatch = require('../../shared/lib/router/utils/path-match') -var _pathHasPrefix = require('../../shared/lib/router/utils/path-has-prefix') -var _removePathPrefix = require('../../shared/lib/router/utils/remove-path-prefix') -var _events = require('../../telemetry/events') -var _storage = require('../../telemetry/storage') -var _trace = require('../../trace') -var _hotReloader = _interop_require_default(require('./hot-reloader')) -var _findPageFile = require('../lib/find-page-file') -var _utils = require('../lib/utils') -var _coalescedFunction = require('../../lib/coalesced-function') -var _loadComponents = require('../load-components') -var _utils1 = require('../../shared/lib/utils') -var _middleware = require('next/dist/compiled/@next/react-dev-overlay/dist/middleware') -var Log = _interop_require_wildcard(require('../../build/output/log')) -var _isError = _interop_require_wildcard(require('../../lib/is-error')) -var _routeRegex = require('../../shared/lib/router/utils/route-regex') -var _utils2 = require('../../shared/lib/router/utils') -var _entries = require('../../build/entries') -var _getPageStaticInfo = require('../../build/analysis/get-page-static-info') -var _normalizePathSep = require('../../shared/lib/page-path/normalize-path-sep') -var _appPaths = require('../../shared/lib/router/utils/app-paths') -var _utils3 = require('../../build/utils') -var _webpackConfig = require('../../build/webpack-config') -var _loadJsconfig = _interop_require_default( - require('../../build/load-jsconfig') -) -// Load ReactDevOverlay only when needed -let ReactDevOverlayImpl -const ReactDevOverlay = (props) => { - if (ReactDevOverlayImpl === undefined) { - ReactDevOverlayImpl = - require('next/dist/compiled/@next/react-dev-overlay/dist/client').ReactDevOverlay - } - return ReactDevOverlayImpl(props) -} -class DevServer extends _nextServer.default { - getStaticPathsWorker() { - if (this.staticPathsWorker) { - return this.staticPathsWorker - } - this.staticPathsWorker = new _jestWorker.Worker( - require.resolve('./static-paths-worker'), - { - maxRetries: 1, - numWorkers: this.nextConfig.experimental.cpus, - enableWorkerThreads: this.nextConfig.experimental.workerThreads, - forkOptions: { - env: _extends({}, process.env, { - // discard --inspect/--inspect-brk flags from process.env.NODE_OPTIONS. Otherwise multiple Node.js debuggers - // would be started if user launch Next.js in debugging mode. The number of debuggers is linked to - // the number of workers Next.js tries to launch. The only worker users are interested in debugging - // is the main Next.js one - NODE_OPTIONS: (0, _utils).getNodeOptionsWithoutInspect(), - }), - }, - } - ) - this.staticPathsWorker.getStdout().pipe(process.stdout) - this.staticPathsWorker.getStderr().pipe(process.stderr) - return this.staticPathsWorker - } - getBuildId() { - return 'development' - } - addExportPathMapRoutes() { - var _this = this - return _async_to_generator(function* () { - // Makes `next export` exportPathMap work in development mode. - // So that the user doesn't have to define a custom server reading the exportPathMap - if (_this.nextConfig.exportPathMap) { - console.log('Defining routes from exportPathMap') - const exportPathMap = yield _this.nextConfig.exportPathMap( - {}, - { - dev: true, - dir: _this.dir, - outDir: null, - distDir: _this.distDir, - buildId: _this.buildId, - } - ) // In development we can't give a default path mapping - for (const path in exportPathMap) { - const { page, query = {} } = exportPathMap[path] - _this.router.addFsRoute({ - match: (0, _pathMatch).getPathMatch(path), - type: 'route', - name: `${path} exportpathmap route`, - fn: _async_to_generator(function* (req, res, _params, parsedUrl) { - const { query: urlQuery } = parsedUrl - Object.keys(urlQuery) - .filter((key) => query[key] === undefined) - .forEach((key) => - console.warn( - `Url '${path}' defines a query parameter '${key}' that is missing in exportPathMap` - ) - ) - const mergedQuery = _extends({}, urlQuery, query) - yield _this.render(req, res, page, mergedQuery, parsedUrl, true) - return { - finished: true, - } - }), - }) - } - } - })() - } - startWatcher() { - var _this = this - return _async_to_generator(function* () { - if (_this.webpackWatcher) { - return - } - const regexPageExtension = new RegExp( - `\\.+(?:${_this.nextConfig.pageExtensions.join('|')})$` - ) - let resolved = false - return new Promise( - _async_to_generator(function* (resolve, reject) { - // Watchpack doesn't emit an event for an empty directory - _fs.default.readdir(_this.pagesDir, (_, files) => { - if (files == null ? void 0 : files.length) { - return - } - if (!resolved) { - resolve() - resolved = true - } - }) - const wp = (_this.webpackWatcher = new _watchpack.default({ - ignored: - /([/\\]node_modules[/\\]|[/\\]\.next[/\\]|[/\\]\.git[/\\])/, - })) - const pages = [_this.pagesDir] - const app = _this.appDir ? [_this.appDir] : [] - const directories = [...pages, ...app] - const files1 = (0, _utils3).getPossibleMiddlewareFilenames( - (0, _path).join(_this.pagesDir, '..'), - _this.nextConfig.pageExtensions - ) - let nestedMiddleware = [] - const envFiles = [ - '.env.development.local', - '.env.local', - '.env.development', - '.env', - ].map((file) => (0, _path).join(_this.dir, file)) - files1.push(...envFiles) - // tsconfig/jsonfig paths hot-reloading - const tsconfigPaths = [ - (0, _path).join(_this.dir, 'tsconfig.json'), - (0, _path).join(_this.dir, 'jsconfig.json'), - ] - files1.push(...tsconfigPaths) - wp.watch({ - directories: [_this.dir], - startTime: 0, - }) - const fileWatchTimes = new Map() - let enabledTypeScript = _this.usingTypeScript - wp.on( - 'aggregated', - _async_to_generator(function* () { - let middlewareMatcher - const routedPages = [] - const knownFiles = wp.getTimeInfoEntries() - const appPaths1 = {} - const edgeRoutesSet = new Set() - let envChange = false - let tsconfigChange = false - for (const [fileName, meta] of knownFiles) { - if ( - !files1.includes(fileName) && - !directories.some((dir) => fileName.startsWith(dir)) - ) { - continue - } - const watchTime = fileWatchTimes.get(fileName) - const watchTimeChange = - watchTime && - watchTime !== (meta == null ? void 0 : meta.timestamp) - fileWatchTimes.set(fileName, meta.timestamp) - if (envFiles.includes(fileName)) { - if (watchTimeChange) { - envChange = true - } - continue - } - if (tsconfigPaths.includes(fileName)) { - if (fileName.endsWith('tsconfig.json')) { - enabledTypeScript = true - } - if (watchTimeChange) { - tsconfigChange = true - } - continue - } - if ( - (meta == null ? void 0 : meta.accuracy) === undefined || - !regexPageExtension.test(fileName) - ) { - continue - } - const isAppPath = Boolean( - _this.appDir && - (0, _normalizePathSep) - .normalizePathSep(fileName) - .startsWith( - (0, _normalizePathSep).normalizePathSep(_this.appDir) - ) - ) - const rootFile = (0, _absolutePathToPage).absolutePathToPage( - fileName, - { - pagesDir: _this.dir, - extensions: _this.nextConfig.pageExtensions, - } - ) - const staticInfo = yield (0, - _getPageStaticInfo).getPageStaticInfo({ - pageFilePath: fileName, - nextConfig: _this.nextConfig, - page: rootFile, - }) - if ((0, _utils3).isMiddlewareFile(rootFile)) { - var ref - _this.actualMiddlewareFile = rootFile - middlewareMatcher = - ((ref = staticInfo.middleware) == null - ? void 0 - : ref.pathMatcher) || new RegExp('.*') - edgeRoutesSet.add('/') - continue - } - if (fileName.endsWith('.ts') || fileName.endsWith('.tsx')) { - enabledTypeScript = true - } - let pageName = (0, _absolutePathToPage).absolutePathToPage( - fileName, - { - pagesDir: isAppPath ? _this.appDir : _this.pagesDir, - extensions: _this.nextConfig.pageExtensions, - keepIndex: isAppPath, - } - ) - if (isAppPath) { - if (!(0, _findPageFile).isLayoutsLeafPage(fileName)) { - continue - } - const originalPageName = pageName - pageName = (0, _appPaths).normalizeAppPath(pageName) || '/' - if (!appPaths1[pageName]) { - appPaths1[pageName] = [] - } - appPaths1[pageName].push(originalPageName) - if (routedPages.includes(pageName)) { - continue - } - } else { - // /index is preserved for root folder - pageName = pageName.replace(/\/index$/, '') || '/' - } - /** - * If there is a middleware that is not declared in the root we will - * warn without adding it so it doesn't make its way into the system. - */ if (/[\\\\/]_middleware$/.test(pageName)) { - nestedMiddleware.push(pageName) - continue - } - yield (0, _entries).runDependingOnPageType({ - page: pageName, - pageRuntime: staticInfo.runtime, - onClient: () => {}, - onServer: () => { - routedPages.push(pageName) - }, - onEdgeServer: () => { - routedPages.push(pageName) - edgeRoutesSet.add(pageName) - }, - }) - } - if (!_this.usingTypeScript && enabledTypeScript) { - // we tolerate the error here as this is best effort - // and the manual install command will be shown - yield _this - .verifyTypeScript() - .then(() => { - tsconfigChange = true - }) - .catch(() => {}) - } - if (envChange || tsconfigChange) { - var ref1, ref2, ref3 - if (envChange) { - _this.loadEnvConfig({ - dev: true, - forceReload: true, - }) - } - let tsconfigResult - if (tsconfigChange) { - try { - tsconfigResult = yield (0, _loadJsconfig).default( - _this.dir, - _this.nextConfig - ) - } catch (_) { - /* do we want to log if there are syntax errors in tsconfig while editing? */ - } - } - ;(ref1 = _this.hotReloader) == null - ? void 0 - : (ref2 = ref1.activeConfigs) == null - ? void 0 - : ref2.forEach((config, idx) => { - const isClient = idx === 0 - const isNodeServer = idx === 1 - const isEdgeServer = idx === 2 - const hasRewrites = - _this.customRoutes.rewrites.afterFiles.length > 0 || - _this.customRoutes.rewrites.beforeFiles.length > 0 || - _this.customRoutes.rewrites.fallback.length > 0 - if (tsconfigChange) { - var ref13, ref5 - ;(ref13 = config.resolve) == null - ? void 0 - : (ref5 = ref13.plugins) == null - ? void 0 - : ref5.forEach((plugin) => { - // look for the JsConfigPathsPlugin and update with - // the latest paths/baseUrl config - if ( - plugin && - plugin.jsConfigPlugin && - tsconfigResult - ) { - var ref, ref7, ref8 - const { resolvedBaseUrl, jsConfig } = - tsconfigResult - const currentResolvedBaseUrl = - plugin.resolvedBaseUrl - const resolvedUrlIndex = - (ref = config.resolve) == null - ? void 0 - : (ref7 = ref.modules) == null - ? void 0 - : ref7.findIndex( - (item) => - item === currentResolvedBaseUrl - ) - if ( - resolvedBaseUrl && - resolvedBaseUrl !== currentResolvedBaseUrl - ) { - var ref9, ref10 - // remove old baseUrl and add new one - if ( - resolvedUrlIndex && - resolvedUrlIndex > -1 - ) { - var ref11, ref12 - ;(ref11 = config.resolve) == null - ? void 0 - : (ref12 = ref11.modules) == null - ? void 0 - : ref12.splice(resolvedUrlIndex, 1) - } - ;(ref9 = config.resolve) == null - ? void 0 - : (ref10 = ref9.modules) == null - ? void 0 - : ref10.push(resolvedBaseUrl) - } - if ( - (jsConfig == null - ? void 0 - : (ref8 = jsConfig.compilerOptions) == null - ? void 0 - : ref8.paths) && - resolvedBaseUrl - ) { - Object.keys(plugin.paths).forEach((key) => { - delete plugin.paths[key] - }) - Object.assign( - plugin.paths, - jsConfig.compilerOptions.paths - ) - plugin.resolvedBaseUrl = resolvedBaseUrl - } - } - }) - } - if (envChange) { - var ref6 - ;(ref6 = config.plugins) == null - ? void 0 - : ref6.forEach((plugin) => { - // we look for the DefinePlugin definitions so we can - // update them on the active compilers - if ( - plugin && - typeof plugin.definitions === 'object' && - plugin.definitions.__NEXT_DEFINE_ENV - ) { - var ref, ref15 - const newDefine = (0, - _webpackConfig).getDefineEnv({ - dev: true, - config: _this.nextConfig, - distDir: _this.distDir, - isClient, - hasRewrites, - hasReactRoot: - (ref = _this.hotReloader) == null - ? void 0 - : ref.hasReactRoot, - isNodeServer, - isEdgeServer, - hasServerComponents: - (ref15 = _this.hotReloader) == null - ? void 0 - : ref15.hasServerComponents, - }) - Object.keys(plugin.definitions).forEach( - (key) => { - if (!(key in newDefine)) { - delete plugin.definitions[key] - } - } - ) - Object.assign(plugin.definitions, newDefine) - } - }) - } - }) - ;(ref3 = _this.hotReloader) == null ? void 0 : ref3.invalidate() - } - if (nestedMiddleware.length > 0) { - Log.error( - new _utils3.NestedMiddlewareError( - nestedMiddleware, - _this.dir, - _this.pagesDir - ).message - ) - nestedMiddleware = [] - } - _this.appPathRoutes = Object.fromEntries( - // Make sure to sort parallel routes to make the result deterministic. - Object.entries(appPaths1).map(([k, v]) => [k, v.sort()]) - ) - _this.edgeFunctions = [] - const edgeRoutes = Array.from(edgeRoutesSet) - ;(0, _utils2).getSortedRoutes(edgeRoutes).forEach((page) => { - let appPaths = _this.getOriginalAppPaths(page) - if (typeof appPaths === 'string') { - page = appPaths - } - const isRootMiddleware = page === '/' && !!middlewareMatcher - const middlewareRegex = isRootMiddleware - ? { - re: middlewareMatcher, - groups: {}, - } - : (0, _routeRegex).getMiddlewareRegex(page, { - catchAll: false, - }) - const routeItem = { - match: (0, _routeMatcher).getRouteMatcher(middlewareRegex), - page, - re: middlewareRegex.re, - } - if (isRootMiddleware) { - _this.middleware = routeItem - } else { - _this.edgeFunctions.push(routeItem) - } - }) - try { - var ref4 - // we serve a separate manifest with all pages for the client in - // dev mode so that we can match a page after a rewrite on the client - // before it has been built and is populated in the _buildManifest - const sortedRoutes = (0, _utils2).getSortedRoutes(routedPages) - if ( - !((ref4 = _this.sortedRoutes) == null - ? void 0 - : ref4.every((val, idx) => val === sortedRoutes[idx])) - ) { - // emit the change so clients fetch the update - _this.hotReloader.send(undefined, { - devPagesManifest: true, - }) - } - _this.sortedRoutes = sortedRoutes - _this.dynamicRoutes = _this.sortedRoutes - .filter(_utils2.isDynamicRoute) - .map((page) => ({ - page, - match: (0, _routeMatcher).getRouteMatcher( - (0, _routeRegex).getRouteRegex(page) - ), - })) - _this.router.setDynamicRoutes(_this.dynamicRoutes) - _this.router.setCatchallMiddleware( - _this.generateCatchAllMiddlewareRoute(true) - ) - if (!resolved) { - resolve() - resolved = true - } - } catch (e) { - if (!resolved) { - reject(e) - resolved = true - } else { - console.warn('Failed to reload dynamic routes:', e) - } - } - }) - ) - }) - ) - })() - } - stopWatcher() { - var _this = this - return _async_to_generator(function* () { - if (!_this.webpackWatcher) { - return - } - _this.webpackWatcher.close() - _this.webpackWatcher = null - })() - } - verifyTypeScript() { - var _this = this - return _async_to_generator(function* () { - if (_this.verifyingTypeScript) { - return - } - try { - _this.verifyingTypeScript = true - const verifyResult = yield (0, - _verifyTypeScriptSetup).verifyTypeScriptSetup({ - dir: _this.dir, - intentDirs: [_this.pagesDir, _this.appDir].filter(Boolean), - typeCheckPreflight: false, - tsconfigPath: _this.nextConfig.typescript.tsconfigPath, - disableStaticImages: _this.nextConfig.images.disableStaticImages, - }) - if (verifyResult.version) { - _this.usingTypeScript = true - } - } finally { - _this.verifyingTypeScript = false - } - })() - } - prepare() { - var _this = this, - _superprop_get_prepare = () => super.prepare - return _async_to_generator(function* () { - ;(0, _trace).setGlobal('distDir', _this.distDir) - ;(0, _trace).setGlobal('phase', _constants1.PHASE_DEVELOPMENT_SERVER) - yield _this.verifyTypeScript() - _this.customRoutes = yield (0, _loadCustomRoutes).default( - _this.nextConfig - ) - // reload router - const { redirects, rewrites, headers } = _this.customRoutes - if ( - rewrites.beforeFiles.length || - rewrites.afterFiles.length || - rewrites.fallback.length || - redirects.length || - headers.length - ) { - _this.router = new _router.default(_this.generateRoutes()) - } - _this.hotReloader = new _hotReloader.default(_this.dir, { - pagesDir: _this.pagesDir, - distDir: _this.distDir, - config: _this.nextConfig, - previewProps: _this.getPreviewProps(), - buildId: _this.buildId, - rewrites, - appDir: _this.appDir, - }) - yield _superprop_get_prepare().call(_this) - yield _this.addExportPathMapRoutes() - yield _this.hotReloader.start(true) - yield _this.startWatcher() - _this.setDevReady() - if (_this.nextConfig.experimental.nextScriptWorkers) { - yield (0, _verifyPartytownSetup).verifyPartytownSetup( - _this.dir, - (0, _path).join(_this.distDir, _constants1.CLIENT_STATIC_FILES_PATH) - ) - } - const telemetry = new _storage.Telemetry({ - distDir: _this.distDir, - }) - telemetry.record( - (0, _events).eventCliSession(_this.distDir, _this.nextConfig, { - webpackVersion: 5, - cliCommand: 'dev', - isSrcDir: (0, _path) - .relative(_this.dir, _this.pagesDir) - .startsWith('src'), - hasNowJson: !!(yield (0, _findUp).default('now.json', { - cwd: _this.dir, - })), - isCustomServer: _this.isCustomServer, - }) - ) - // This is required by the tracing subsystem. - ;(0, _trace).setGlobal('telemetry', telemetry) - process.on('unhandledRejection', (reason) => { - _this - .logErrorWithOriginalStack(reason, 'unhandledRejection') - .catch(() => {}) - }) - process.on('uncaughtException', (err) => { - _this - .logErrorWithOriginalStack(err, 'uncaughtException') - .catch(() => {}) - }) - })() - } - close() { - var _this = this - return _async_to_generator(function* () { - yield _this.stopWatcher() - yield _this.getStaticPathsWorker().end() - if (_this.hotReloader) { - yield _this.hotReloader.stop() - } - })() - } - hasPage(pathname) { - var _this = this - return _async_to_generator(function* () { - let normalizedPath - try { - normalizedPath = (0, _normalizePagePath).normalizePagePath(pathname) - } catch (err) { - console.error(err) - // if normalizing the page fails it means it isn't valid - // so it doesn't exist so don't throw and return false - // to ensure we return 404 instead of 500 - return false - } - if ((0, _utils3).isMiddlewareFile(normalizedPath)) { - return (0, _findPageFile) - .findPageFile( - _this.dir, - normalizedPath, - _this.nextConfig.pageExtensions - ) - .then(Boolean) - } - // check appDir first if enabled - if (_this.appDir) { - const pageFile = yield (0, _findPageFile).findPageFile( - _this.appDir, - normalizedPath, - _this.nextConfig.pageExtensions - ) - if (pageFile) return true - } - const pageFile = yield (0, _findPageFile).findPageFile( - _this.pagesDir, - normalizedPath, - _this.nextConfig.pageExtensions - ) - return !!pageFile - })() - } - _beforeCatchAllRender(req, res, params, parsedUrl) { - var _this = this - return _async_to_generator(function* () { - const { pathname } = parsedUrl - const pathParts = params.path || [] - const path = `/${pathParts.join('/')}` - // check for a public file, throwing error if there's a - // conflicting page - let decodedPath - try { - decodedPath = decodeURIComponent(path) - } catch (_) { - throw new _utils1.DecodeError('failed to decode param') - } - if (yield _this.hasPublicFile(decodedPath)) { - if (yield _this.hasPage(pathname)) { - const err = new Error( - `A conflicting public file and page file was found for path ${pathname} https://nextjs.org/docs/messages/conflicting-public-file-page` - ) - res.statusCode = 500 - yield _this.renderError(err, req, res, pathname, {}) - return true - } - yield _this.servePublic(req, res, pathParts) - return true - } - return false - })() - } - setupWebSocketHandler(server, _req) { - if (!this.addedUpgradeListener) { - var ref17 - this.addedUpgradeListener = true - server = - server || - ((ref17 = _req == null ? void 0 : _req.originalRequest.socket) == null - ? void 0 - : ref17.server) - if (!server) { - // this is very unlikely to happen but show an error in case - // it does somehow - Log.error( - `Invalid IncomingMessage received, make sure http.createServer is being used to handle requests.` - ) - } else { - const { basePath } = this.nextConfig - server.on('upgrade', (req, socket, head) => { - var ref - let assetPrefix = (this.nextConfig.assetPrefix || '').replace( - /^\/+/, - '' - ) - // assetPrefix can be a proxy server with a url locally - // if so, it's needed to send these HMR requests with a rewritten url directly to /_next/webpack-hmr - // otherwise account for a path-like prefix when listening to socket events - if (assetPrefix.startsWith('http')) { - assetPrefix = '' - } else if (assetPrefix) { - assetPrefix = `/${assetPrefix}` - } - if ( - (ref = req.url) == null - ? void 0 - : ref.startsWith( - `${basePath || assetPrefix || ''}/_next/webpack-hmr` - ) - ) { - var ref16 - ;(ref16 = this.hotReloader) == null - ? void 0 - : ref16.onHMR(req, socket, head) - } else { - this.handleUpgrade(req, socket, head) - } - }) - } - } - } - runMiddleware(params) { - var _this = this, - _superprop_get_runMiddleware = () => super.runMiddleware - return _async_to_generator(function* () { - try { - const result = yield _superprop_get_runMiddleware().call( - _this, - _extends({}, params, { - onWarning: (warn) => { - _this.logErrorWithOriginalStack(warn, 'warning') - }, - }) - ) - if ('finished' in result) { - return result - } - result.waitUntil.catch((error) => { - _this.logErrorWithOriginalStack(error, 'unhandledRejection') - }) - return result - } catch (error) { - if (error instanceof _utils1.DecodeError) { - throw error - } - /** - * We only log the error when it is not a MiddlewareNotFound error as - * in that case we should be already displaying a compilation error - * which is what makes the module not found. - */ if (!(error instanceof _utils1.MiddlewareNotFoundError)) { - _this.logErrorWithOriginalStack(error) - } - const err = (0, _isError).getProperError(error) - err.middleware = true - const { request, response, parsedUrl } = params - /** - * When there is a failure for an internal Next.js request from - * middleware we bypass the error without finishing the request - * so we can serve the required chunks to render the error. - */ if ( - request.url.includes('/_next/static') || - request.url.includes('/__nextjs_original-stack-frame') - ) { - return { - finished: false, - } - } - response.statusCode = 500 - _this.renderError(err, request, response, parsedUrl.pathname) - return { - finished: true, - } - } - })() - } - runEdgeFunction(params) { - var _this = this, - _superprop_get_runEdgeFunction = () => super.runEdgeFunction - return _async_to_generator(function* () { - try { - return _superprop_get_runEdgeFunction().call( - _this, - _extends({}, params, { - onWarning: (warn) => { - _this.logErrorWithOriginalStack(warn, 'warning') - }, - }) - ) - } catch (error) { - if (error instanceof _utils1.DecodeError) { - throw error - } - _this.logErrorWithOriginalStack(error, 'warning') - const err = (0, _isError).getProperError(error) - const { req, res, page } = params - res.statusCode = 500 - _this.renderError(err, req, res, page) - return null - } - })() - } - run(req, res, parsedUrl) { - var _this = this, - _superprop_get_run = () => super.run - return _async_to_generator(function* () { - yield _this.devReady - _this.setupWebSocketHandler(undefined, req) - const { basePath } = _this.nextConfig - let originalPathname = null - if ( - basePath && - (0, _pathHasPrefix).pathHasPrefix(parsedUrl.pathname || '/', basePath) - ) { - // strip basePath before handling dev bundles - // If replace ends up replacing the full url it'll be `undefined`, meaning we have to default it to `/` - originalPathname = parsedUrl.pathname - parsedUrl.pathname = (0, _removePathPrefix).removePathPrefix( - parsedUrl.pathname || '/', - basePath - ) - } - const { pathname } = parsedUrl - if (pathname.startsWith('/_next')) { - if ( - yield (0, _fileExists).fileExists( - (0, _path).join(_this.publicDir, '_next') - ) - ) { - throw new Error(_constants.PUBLIC_DIR_MIDDLEWARE_CONFLICT) - } - } - const { finished = false } = yield _this.hotReloader.run( - req.originalRequest, - res.originalResponse, - parsedUrl - ) - if (finished) { - return - } - if (originalPathname) { - // restore the path before continuing so that custom-routes can accurately determine - // if they should match against the basePath or not - parsedUrl.pathname = originalPathname - } - try { - return yield _superprop_get_run().call(_this, req, res, parsedUrl) - } catch (error) { - res.statusCode = 500 - const err = (0, _isError).getProperError(error) - try { - _this.logErrorWithOriginalStack(err).catch(() => {}) - return yield _this.renderError(err, req, res, pathname, { - __NEXT_PAGE: - ((0, _isError).default(err) && err.page) || pathname || '', - }) - } catch (internalErr) { - console.error(internalErr) - res.body('Internal Server Error').send() - } - } - })() - } - logErrorWithOriginalStack(err, type) { - var _this = this - return _async_to_generator(function* () { - let usedOriginalStack = false - if ((0, _isError).default(err) && err.stack) { - try { - const frames = (0, _middleware).parseStack(err.stack) - const frame = frames.find(({ file }) => { - return ( - !(file == null ? void 0 : file.startsWith('eval')) && - !(file == null ? void 0 : file.includes('web/adapter')) && - !(file == null ? void 0 : file.includes('sandbox/context')) - ) - }) - if (frame.lineNumber && (frame == null ? void 0 : frame.file)) { - var ref, ref19, ref20, ref21, ref22, ref23 - const moduleId = frame.file.replace( - /^(webpack-internal:\/\/\/|file:\/\/)/, - '' - ) - const src = (0, _middleware).getErrorSource(err) - const compilation = - src === _constants1.COMPILER_NAMES.edgeServer - ? (ref = _this.hotReloader) == null - ? void 0 - : (ref19 = ref.edgeServerStats) == null - ? void 0 - : ref19.compilation - : (ref20 = _this.hotReloader) == null - ? void 0 - : (ref21 = ref20.serverStats) == null - ? void 0 - : ref21.compilation - const source = yield (0, _middleware).getSourceById( - !!((ref22 = frame.file) == null - ? void 0 - : ref22.startsWith(_path.sep)) || - !!((ref23 = frame.file) == null - ? void 0 - : ref23.startsWith('file:')), - moduleId, - compilation - ) - const originalFrame = yield (0, - _middleware).createOriginalStackFrame({ - line: frame.lineNumber, - column: frame.column, - source, - frame, - modulePath: moduleId, - rootDirectory: _this.dir, - errorMessage: err.message, - compilation, - }) - if (originalFrame) { - const { originalCodeFrame, originalStackFrame } = originalFrame - const { file, lineNumber, column, methodName } = - originalStackFrame - Log[type === 'warning' ? 'warn' : 'error']( - `${file} (${lineNumber}:${column}) @ ${methodName}` - ) - if (src === _constants1.COMPILER_NAMES.edgeServer) { - err = err.message - } - if (type === 'warning') { - Log.warn(err) - } else if (type) { - Log.error(`${type}:`, err) - } else { - Log.error(err) - } - console[type === 'warning' ? 'warn' : 'error'](originalCodeFrame) - usedOriginalStack = true - } - } - } catch (_) { - // failed to load original stack using source maps - // this un-actionable by users so we don't show the - // internal error and only show the provided stack - } - } - if (!usedOriginalStack) { - if (type === 'warning') { - Log.warn(err) - } else if (type) { - Log.error(`${type}:`, err) - } else { - Log.error(err) - } - } - })() - } - // override production loading of routes-manifest - getCustomRoutes() { - // actual routes will be loaded asynchronously during .prepare() - return { - redirects: [], - rewrites: { - beforeFiles: [], - afterFiles: [], - fallback: [], - }, - headers: [], - } - } - getPreviewProps() { - if (this._devCachedPreviewProps) { - return this._devCachedPreviewProps - } - return (this._devCachedPreviewProps = { - previewModeId: _crypto.default.randomBytes(16).toString('hex'), - previewModeSigningKey: _crypto.default.randomBytes(32).toString('hex'), - previewModeEncryptionKey: _crypto.default.randomBytes(32).toString('hex'), - }) - } - getPagesManifest() { - return undefined - } - getAppPathsManifest() { - return undefined - } - getMiddleware() { - return this.middleware - } - getEdgeFunctions() { - var _edgeFunctions - return (_edgeFunctions = this.edgeFunctions) != null ? _edgeFunctions : [] - } - getServerComponentManifest() { - return undefined - } - getServerCSSManifest() { - return undefined - } - hasMiddleware() { - var _this = this - return _async_to_generator(function* () { - return _this.hasPage(_this.actualMiddlewareFile) - })() - } - ensureMiddleware() { - var _this = this - return _async_to_generator(function* () { - return _this.hotReloader.ensurePage({ - page: _this.actualMiddlewareFile, - }) - })() - } - ensureEdgeFunction({ page, appPaths }) { - var _this = this - return _async_to_generator(function* () { - return _this.hotReloader.ensurePage({ - page, - appPaths, - }) - })() - } - generateRoutes() { - const _ref = super.generateRoutes(), - { fsRoutes } = _ref, - otherRoutes = _object_without_properties_loose(_ref, ['fsRoutes']) - var _this = this - // In development we expose all compiled files for react-error-overlay's line show feature - // We use unshift so that we're sure the routes is defined before Next's default routes - fsRoutes.unshift({ - match: (0, _pathMatch).getPathMatch('/_next/development/:path*'), - type: 'route', - name: '_next/development catchall', - fn: _async_to_generator(function* (req, res, params) { - const p = (0, _path).join(_this.distDir, ...(params.path || [])) - yield _this.serveStatic(req, res, p) - return { - finished: true, - } - }), - }) - var _this1 = this - fsRoutes.unshift({ - match: (0, _pathMatch).getPathMatch( - `/_next/${_constants1.CLIENT_STATIC_FILES_PATH}/${this.buildId}/${_constants1.DEV_CLIENT_PAGES_MANIFEST}` - ), - type: 'route', - name: `_next/${_constants1.CLIENT_STATIC_FILES_PATH}/${this.buildId}/${_constants1.DEV_CLIENT_PAGES_MANIFEST}`, - fn: _async_to_generator(function* (_req, res) { - res.statusCode = 200 - res.setHeader('Content-Type', 'application/json; charset=utf-8') - res - .body( - JSON.stringify({ - pages: _this1.sortedRoutes, - }) - ) - .send() - return { - finished: true, - } - }), - }) - var _this2 = this - fsRoutes.unshift({ - match: (0, _pathMatch).getPathMatch( - `/_next/${_constants1.CLIENT_STATIC_FILES_PATH}/${this.buildId}/${_constants1.DEV_MIDDLEWARE_MANIFEST}` - ), - type: 'route', - name: `_next/${_constants1.CLIENT_STATIC_FILES_PATH}/${this.buildId}/${_constants1.DEV_MIDDLEWARE_MANIFEST}`, - fn: _async_to_generator(function* (_req, res) { - res.statusCode = 200 - res.setHeader('Content-Type', 'application/json; charset=utf-8') - res - .body( - JSON.stringify( - _this2.middleware - ? { - location: _this2.middleware.re.source, - } - : {} - ) - ) - .send() - return { - finished: true, - } - }), - }) - var _this3 = this - fsRoutes.push({ - match: (0, _pathMatch).getPathMatch('/:path*'), - type: 'route', - name: 'catchall public directory route', - fn: _async_to_generator(function* (req, res, params, parsedUrl) { - const { pathname } = parsedUrl - if (!pathname) { - throw new Error('pathname is undefined') - } - // Used in development to check public directory paths - if (yield _this3._beforeCatchAllRender(req, res, params, parsedUrl)) { - return { - finished: true, - } - } - return { - finished: false, - } - }), - }) - return _extends( - { - fsRoutes, - }, - otherRoutes - ) - } - // In development public files are not added to the router but handled as a fallback instead - generatePublicRoutes() { - return [] - } - // In development dynamic routes cannot be known ahead of time - getDynamicRoutes() { - return [] - } - _filterAmpDevelopmentScript(html, event) { - if (event.code !== 'DISALLOWED_SCRIPT_TAG') { - return true - } - const snippetChunks = html.split('\n') - let snippet - if ( - !(snippet = html.split('\n')[event.line - 1]) || - !(snippet = snippet.substring(event.col)) - ) { - return true - } - snippet = snippet + snippetChunks.slice(event.line).join('\n') - snippet = snippet.substring(0, snippet.indexOf('')) - return !snippet.includes('data-amp-development-mode-only') - } - getStaticPaths(pathname) { - var _this = this - return _async_to_generator(function* () { - // we lazy load the staticPaths to prevent the user - // from waiting on them for the page to load in dev mode - const __getStaticPaths = _async_to_generator(function* () { - const { - configFileName, - publicRuntimeConfig, - serverRuntimeConfig, - httpAgentOptions, - } = _this.nextConfig - const { locales, defaultLocale } = _this.nextConfig.i18n || {} - const paths = yield _this.getStaticPathsWorker().loadStaticPaths( - _this.distDir, - pathname, - !_this.renderOpts.dev && _this._isLikeServerless, - { - configFileName, - publicRuntimeConfig, - serverRuntimeConfig, - }, - httpAgentOptions, - locales, - defaultLocale - ) - return paths - }) - const { paths: staticPaths, fallback } = (yield (0, - _coalescedFunction).withCoalescedInvoke(__getStaticPaths)( - `staticPaths-${pathname}`, - [] - )).value - return { - staticPaths, - fallbackMode: - fallback === 'blocking' - ? 'blocking' - : fallback === true - ? 'static' - : false, - } - })() - } - ensureApiPage(pathname) { - var _this = this - return _async_to_generator(function* () { - return _this.hotReloader.ensurePage({ - page: pathname, - }) - })() - } - findPageComponents({ - pathname, - query = {}, - params = null, - isAppDir = false, - appPaths, - }) { - var _this = this, - _superprop_get_getServerComponentManifest = () => - super.getServerComponentManifest, - _superprop_get_getServerCSSManifest = () => super.getServerCSSManifest, - _superprop_get_findPageComponents = () => super.findPageComponents - return _async_to_generator(function* () { - yield _this.devReady - const compilationErr = yield _this.getCompilationError(pathname) - if (compilationErr) { - // Wrap build errors so that they don't get logged again - throw new _nextServer.WrappedBuildError(compilationErr) - } - try { - yield _this.hotReloader.ensurePage({ - page: pathname, - appPaths, - }) - const serverComponents = _this.nextConfig.experimental.serverComponents - // When the new page is compiled, we need to reload the server component - // manifest. - if (serverComponents) { - _this.serverComponentManifest = - _superprop_get_getServerComponentManifest().call(_this) - _this.serverCSSManifest = - _superprop_get_getServerCSSManifest().call(_this) - } - return _superprop_get_findPageComponents().call(_this, { - pathname, - query, - params, - isAppDir, - }) - } catch (err) { - if (err.code !== 'ENOENT') { - throw err - } - return null - } - })() - } - getFallbackErrorComponents() { - var _this = this - return _async_to_generator(function* () { - yield _this.hotReloader.buildFallbackError() - // Build the error page to ensure the fallback is built too. - // TODO: See if this can be moved into hotReloader or removed. - yield _this.hotReloader.ensurePage({ - page: '/_error', - }) - return yield (0, _loadComponents).loadDefaultErrorComponents( - _this.distDir - ) - })() - } - setImmutableAssetCacheControl(res) { - res.setHeader('Cache-Control', 'no-store, must-revalidate') - } - servePublic(req, res, pathParts) { - const p = (0, _path).join(this.publicDir, ...pathParts) - return this.serveStatic(req, res, p) - } - hasPublicFile(path) { - var _this = this - return _async_to_generator(function* () { - try { - const info = yield _fs.default.promises.stat( - (0, _path).join(_this.publicDir, path) - ) - return info.isFile() - } catch (_) { - return false - } - })() - } - getCompilationError(page) { - var _this = this - return _async_to_generator(function* () { - const errors = yield _this.hotReloader.getCompilationErrors(page) - if (errors.length === 0) return - // Return the very first error we found. - return errors[0] - })() - } - isServeableUrl(untrustedFileUrl) { - // This method mimics what the version of `send` we use does: - // 1. decodeURIComponent: - // https://github.com/pillarjs/send/blob/0.17.1/index.js#L989 - // https://github.com/pillarjs/send/blob/0.17.1/index.js#L518-L522 - // 2. resolve: - // https://github.com/pillarjs/send/blob/de073ed3237ade9ff71c61673a34474b30e5d45b/index.js#L561 - let decodedUntrustedFilePath - try { - // (1) Decode the URL so we have the proper file name - decodedUntrustedFilePath = decodeURIComponent(untrustedFileUrl) - } catch (e) { - return false - } - // (2) Resolve "up paths" to determine real request - const untrustedFilePath = (0, _path).resolve(decodedUntrustedFilePath) - // don't allow null bytes anywhere in the file path - if (untrustedFilePath.indexOf('\0') !== -1) { - return false - } - // During development mode, files can be added while the server is running. - // Checks for .next/static, .next/server, static and public. - // Note that in development .next/server is available for error reporting purposes. - // see `packages/next/server/next-server.ts` for more details. - if ( - untrustedFilePath.startsWith( - (0, _path).join(this.distDir, 'static') + _path.sep - ) || - untrustedFilePath.startsWith( - (0, _path).join(this.distDir, 'server') + _path.sep - ) || - untrustedFilePath.startsWith( - (0, _path).join(this.dir, 'static') + _path.sep - ) || - untrustedFilePath.startsWith( - (0, _path).join(this.dir, 'public') + _path.sep - ) - ) { - return true - } - return false - } - constructor(options) { - var ref, ref24 - super( - _extends({}, options, { - dev: true, - }) - ) - this.addedUpgradeListener = false - this.renderOpts.dev = true - this.renderOpts.ErrorDebug = ReactDevOverlay - this.devReady = new Promise((resolve) => { - this.setDevReady = resolve - }) - var ref25 - this.renderOpts.ampSkipValidation = - (ref25 = - (ref = this.nextConfig.experimental) == null - ? void 0 - : (ref24 = ref.amp) == null - ? void 0 - : ref24.skipValidation) != null - ? ref25 - : false - this.renderOpts.ampValidator = (html, pathname) => { - const validatorPath = - this.nextConfig.experimental && - this.nextConfig.experimental.amp && - this.nextConfig.experimental.amp.validator - const AmpHtmlValidator = require('next/dist/compiled/amphtml-validator') - return AmpHtmlValidator.getInstance(validatorPath).then((validator) => { - const result = validator.validateString(html) - ;(0, _output).ampValidation( - pathname, - result.errors - .filter((e) => e.severity === 'ERROR') - .filter((e) => this._filterAmpDevelopmentScript(html, e)), - result.errors.filter((e) => e.severity !== 'ERROR') - ) - }) - } - if (_fs.default.existsSync((0, _path).join(this.dir, 'static'))) { - console.warn( - `The static directory has been deprecated in favor of the public directory. https://nextjs.org/docs/messages/static-dir-deprecated` - ) - } - // setup upgrade listener eagerly when we can otherwise - // it will be done on the first request via req.socket.server - if (options.httpServer) { - this.setupWebSocketHandler(options.httpServer) - } - this.isCustomServer = !options.isNextDevCommand - // TODO: hot-reload root/pages dirs? - const { pages: pagesDir, appDir } = (0, _findPagesDir).findPagesDir( - this.dir, - this.nextConfig.experimental.appDir - ) - this.pagesDir = pagesDir - this.appDir = appDir - } -} -exports.default = DevServer - -//# sourceMappingURL=next-dev-server.js.map diff --git a/packages/next/server/dev/next-dev-server.js.map b/packages/next/server/dev/next-dev-server.js.map deleted file mode 100644 index 324f900fa021..000000000000 --- a/packages/next/server/dev/next-dev-server.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../../server/dev/next-dev-server.ts"],"names":["Log","ReactDevOverlayImpl","ReactDevOverlay","props","undefined","require","DevServer","Server","getStaticPathsWorker","staticPathsWorker","Worker","resolve","maxRetries","numWorkers","nextConfig","experimental","cpus","enableWorkerThreads","workerThreads","forkOptions","env","process","NODE_OPTIONS","getNodeOptionsWithoutInspect","getStdout","pipe","stdout","getStderr","stderr","getBuildId","addExportPathMapRoutes","exportPathMap","console","log","dev","dir","outDir","distDir","buildId","path","page","query","router","addFsRoute","match","getPathMatch","type","name","fn","req","res","_params","parsedUrl","urlQuery","Object","keys","filter","key","forEach","warn","mergedQuery","render","finished","startWatcher","webpackWatcher","regexPageExtension","RegExp","pageExtensions","join","resolved","Promise","reject","fs","readdir","pagesDir","_","files","length","wp","Watchpack","ignored","pages","app","appDir","directories","getPossibleMiddlewareFilenames","pathJoin","nestedMiddleware","envFiles","map","file","push","tsconfigPaths","watch","startTime","fileWatchTimes","Map","enabledTypeScript","usingTypeScript","on","middlewareMatcher","routedPages","knownFiles","getTimeInfoEntries","appPaths","edgeRoutesSet","Set","envChange","tsconfigChange","fileName","meta","includes","some","startsWith","watchTime","get","watchTimeChange","timestamp","set","endsWith","accuracy","test","isAppPath","Boolean","normalizePathSep","rootFile","absolutePathToPage","extensions","staticInfo","getPageStaticInfo","pageFilePath","isMiddlewareFile","actualMiddlewareFile","middleware","pathMatcher","add","pageName","keepIndex","isLayoutsLeafPage","originalPageName","normalizeAppPath","replace","runDependingOnPageType","pageRuntime","runtime","onClient","onServer","onEdgeServer","verifyTypeScript","then","catch","loadEnvConfig","forceReload","tsconfigResult","loadJsConfig","hotReloader","activeConfigs","config","idx","isClient","isNodeServer","isEdgeServer","hasRewrites","customRoutes","rewrites","afterFiles","beforeFiles","fallback","plugins","plugin","jsConfigPlugin","jsConfig","resolvedBaseUrl","currentResolvedBaseUrl","resolvedUrlIndex","modules","findIndex","item","splice","compilerOptions","paths","assign","definitions","__NEXT_DEFINE_ENV","newDefine","getDefineEnv","hasReactRoot","hasServerComponents","invalidate","error","NestedMiddlewareError","message","appPathRoutes","fromEntries","entries","k","v","sort","edgeFunctions","edgeRoutes","Array","from","getSortedRoutes","getOriginalAppPaths","isRootMiddleware","middlewareRegex","re","groups","getMiddlewareRegex","catchAll","routeItem","getRouteMatcher","sortedRoutes","every","val","send","devPagesManifest","dynamicRoutes","isDynamicRoute","getRouteRegex","setDynamicRoutes","setCatchallMiddleware","generateCatchAllMiddlewareRoute","e","stopWatcher","close","verifyingTypeScript","verifyResult","verifyTypeScriptSetup","intentDirs","typeCheckPreflight","tsconfigPath","typescript","disableStaticImages","images","version","prepare","setGlobal","PHASE_DEVELOPMENT_SERVER","loadCustomRoutes","redirects","headers","Router","generateRoutes","HotReloader","previewProps","getPreviewProps","start","setDevReady","nextScriptWorkers","verifyPartytownSetup","CLIENT_STATIC_FILES_PATH","telemetry","Telemetry","record","eventCliSession","webpackVersion","cliCommand","isSrcDir","relative","hasNowJson","findUp","cwd","isCustomServer","reason","logErrorWithOriginalStack","err","end","stop","hasPage","pathname","normalizedPath","normalizePagePath","findPageFile","pageFile","_beforeCatchAllRender","params","pathParts","decodedPath","decodeURIComponent","DecodeError","hasPublicFile","Error","statusCode","renderError","servePublic","setupWebSocketHandler","server","_req","addedUpgradeListener","originalRequest","socket","basePath","head","assetPrefix","url","onHMR","handleUpgrade","runMiddleware","result","onWarning","waitUntil","MiddlewareNotFoundError","getProperError","request","response","runEdgeFunction","run","devReady","originalPathname","pathHasPrefix","removePathPrefix","fileExists","publicDir","PUBLIC_DIR_MIDDLEWARE_CONFLICT","originalResponse","__NEXT_PAGE","isError","internalErr","body","usedOriginalStack","stack","frames","parseStack","frame","find","lineNumber","moduleId","src","getErrorSource","compilation","COMPILER_NAMES","edgeServer","edgeServerStats","serverStats","source","getSourceById","sep","originalFrame","createOriginalStackFrame","line","column","modulePath","rootDirectory","errorMessage","originalCodeFrame","originalStackFrame","methodName","getCustomRoutes","_devCachedPreviewProps","previewModeId","crypto","randomBytes","toString","previewModeSigningKey","previewModeEncryptionKey","getPagesManifest","getAppPathsManifest","getMiddleware","getEdgeFunctions","getServerComponentManifest","getServerCSSManifest","hasMiddleware","ensureMiddleware","ensurePage","ensureEdgeFunction","fsRoutes","otherRoutes","unshift","p","serveStatic","DEV_CLIENT_PAGES_MANIFEST","setHeader","JSON","stringify","DEV_MIDDLEWARE_MANIFEST","location","generatePublicRoutes","getDynamicRoutes","_filterAmpDevelopmentScript","html","event","code","snippetChunks","split","snippet","substring","col","slice","indexOf","getStaticPaths","__getStaticPaths","configFileName","publicRuntimeConfig","serverRuntimeConfig","httpAgentOptions","locales","defaultLocale","i18n","loadStaticPaths","renderOpts","_isLikeServerless","staticPaths","withCoalescedInvoke","value","fallbackMode","ensureApiPage","findPageComponents","isAppDir","compilationErr","getCompilationError","WrappedBuildError","serverComponents","serverComponentManifest","serverCSSManifest","getFallbackErrorComponents","buildFallbackError","loadDefaultErrorComponents","setImmutableAssetCacheControl","info","promises","stat","isFile","errors","getCompilationErrors","isServeableUrl","untrustedFileUrl","decodedUntrustedFilePath","untrustedFilePath","pathResolve","constructor","options","ErrorDebug","ampSkipValidation","amp","skipValidation","ampValidator","validatorPath","validator","AmpHtmlValidator","getInstance","validateString","ampValidation","severity","existsSync","httpServer","isNextDevCommand","findPagesDir"],"mappings":"AAAA;;;;;;;;;;AAamB,IAAA,OAAQ,oCAAR,QAAQ,EAAA;AACZ,IAAA,GAAI,oCAAJ,IAAI,EAAA;AACI,IAAA,WAAgC,WAAhC,gCAAgC,CAAA;AACpC,IAAA,OAA4B,oCAA5B,4BAA4B,EAAA;AACyB,IAAA,KAAM,WAAN,MAAM,CAAA;AAC5D,IAAA,MAAO,oCAAP,OAAO,EAAA;AACH,IAAA,UAA8B,oCAA9B,8BAA8B,EAAA;AACtB,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AACH,IAAA,UAAqB,WAArB,qBAAqB,CAAA;AACzC,IAAA,WAAuB,WAAvB,uBAAuB,CAAA;AACrB,IAAA,aAA0B,WAA1B,0BAA0B,CAAA;AAC1B,IAAA,iBAA8B,oCAA9B,8BAA8B,EAAA;AACrB,IAAA,sBAAiC,WAAjC,iCAAiC,CAAA;AAClC,IAAA,qBAAkC,WAAlC,kCAAkC,CAAA;AAOhE,IAAA,WAA4B,WAA5B,4BAA4B,CAAA;AACO,IAAA,WAAgB,qCAAhB,gBAAgB,EAAA;AAC1B,IAAA,aAA6C,WAA7C,6CAA6C,CAAA;AAC3C,IAAA,kBAAgD,WAAhD,gDAAgD,CAAA;AAC/C,IAAA,mBAAkD,WAAlD,kDAAkD,CAAA;AAClE,IAAA,OAAW,oCAAX,WAAW,EAAA;AACD,IAAA,UAA0C,WAA1C,0CAA0C,CAAA;AACzC,IAAA,cAA+C,WAA/C,+CAA+C,CAAA;AAC5C,IAAA,iBAAkD,WAAlD,kDAAkD,CAAA;AACnD,IAAA,OAAwB,WAAxB,wBAAwB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,CAACe,gBAAgB;QAC/C,oCAAoC;QACpC,MAAM,EAAE7W,KAAK,EAAEP,QAAQ,CAAA,EAAES,MAAM,CAAA,EAAE,GAAG4W,CAAAA,GAAAA,aAAY,AAG/C,CAAA,aAH+C,CAC9C,IAAI,CAAC5Z,GAAG,EACR,IAAI,CAACrB,UAAU,CAACC,YAAY,CAACoE,MAAM,CACpC;QACD,IAAI,CAACT,QAAQ,GAAGA,QAAQ;QACxB,IAAI,CAACS,MAAM,GAAGA,MAAM;KACrB;CAgsCF;kBAvyCoB7E,SAAS"} \ No newline at end of file From 2e39d41a5aba2569ee389f404b2407eecfdc63f5 Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Mon, 5 Sep 2022 17:04:50 +0200 Subject: [PATCH 09/11] fix edge runtime --- packages/next/server/dev/next-dev-server.ts | 1 + packages/next/server/next-server.ts | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/next/server/dev/next-dev-server.ts b/packages/next/server/dev/next-dev-server.ts index 0c5c0e34b908..0e6ec9edb657 100644 --- a/packages/next/server/dev/next-dev-server.ts +++ b/packages/next/server/dev/next-dev-server.ts @@ -891,6 +891,7 @@ export default class DevServer extends Server { query: ParsedUrlQuery params: Params | undefined page: string + appPaths: string[] | null }) { try { return super.runEdgeFunction({ diff --git a/packages/next/server/next-server.ts b/packages/next/server/next-server.ts index fdf4b00834af..597d8670e167 100644 --- a/packages/next/server/next-server.ts +++ b/packages/next/server/next-server.ts @@ -750,6 +750,7 @@ export default class NextNodeServer extends BaseServer { query, params, page, + appPaths: null, }) if (handledAsEdgeFunction) { @@ -897,6 +898,7 @@ export default class NextNodeServer extends BaseServer { query: ctx.query, params: ctx.renderOpts.params, page, + appPaths, }) return null } @@ -2009,18 +2011,15 @@ export default class NextNodeServer extends BaseServer { query: ParsedUrlQuery params: Params | undefined page: string + appPaths: string[] | null onWarning?: (warning: Error) => void }): Promise { let middlewareInfo: ReturnType | undefined - let appPaths = this.getOriginalAppPaths(params.page) - - if (Array.isArray(appPaths)) { - // When it's an array, we need to pass all parallel routes to the loader. - params.page = appPaths[0] - // params.appPaths = appPaths - } - await this.ensureEdgeFunction({ page: params.page, appPaths }) + await this.ensureEdgeFunction({ + page: params.page, + appPaths: params.appPaths, + }) middlewareInfo = this.getEdgeFunctionInfo({ page: params.page, middleware: false, From a5ba7f5823e4b5f93d5edc44e4d0078c19d90f18 Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Mon, 5 Sep 2022 18:03:46 +0200 Subject: [PATCH 10/11] fix tests --- packages/next/server/next-server.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/next/server/next-server.ts b/packages/next/server/next-server.ts index be2c0f085082..d762c1a05388 100644 --- a/packages/next/server/next-server.ts +++ b/packages/next/server/next-server.ts @@ -893,9 +893,10 @@ export default class NextNodeServer extends BaseServer { const edgeFunctions = this.getEdgeFunctions() || [] if (edgeFunctions.length) { const appPaths = this.getOriginalAppPaths(ctx.pathname) - let page = ctx.pathname + const isAppPath = Array.isArray(appPaths) - if (Array.isArray(appPaths)) { + let page = ctx.pathname + if (isAppPath) { // When it's an array, we need to pass all parallel routes to the loader. page = appPaths[0] } @@ -909,7 +910,7 @@ export default class NextNodeServer extends BaseServer { params: ctx.renderOpts.params, page, appPaths, - isAppPath: Array.isArray(appPaths), + isAppPath, }) return null } @@ -2028,16 +2029,14 @@ export default class NextNodeServer extends BaseServer { page: string appPaths: string[] | null isAppPath: boolean - appPath?: string onWarning?: (warning: Error) => void }): Promise { let middlewareInfo: ReturnType | undefined - // If it's edge app route, use appPath to find the edge SSR page - const page = params.isAppPath ? params.appPath! : params.page + const page = params.page await this.ensureEdgeFunction({ page, appPaths: params.appPaths }) middlewareInfo = this.getEdgeFunctionInfo({ - page: page, + page, middleware: false, }) From b5da51458d8098c70071d34825fdd8d7740769f0 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Tue, 6 Sep 2022 09:21:45 -0700 Subject: [PATCH 11/11] update failing run-for-change checks --- .github/workflows/build_test_deploy.yml | 8 ++++---- .github/workflows/pull_request_stats.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index fe8dfad1dc11..fe28799b023e 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -51,7 +51,7 @@ jobs: run: sudo ethtool -K eth0 tx off rx off - name: Check non-docs only change - run: echo ::set-output name=DOCS_CHANGE::$(node scripts/run-for-change.js --not --type docs --exec echo 'nope') + run: echo "::set-output name=DOCS_CHANGE::$(node scripts/run-for-change.js --not --type docs --exec echo 'nope')" id: docs-change - run: echo ${{steps.docs-change.outputs.DOCS_CHANGE}} @@ -124,7 +124,7 @@ jobs: path: ./* key: ${{ github.sha }}-${{ github.run_number }} - - run: echo ::set-output name=SWC_CHANGE::$(node scripts/run-for-change.js --type next-swc --exec echo 'yup') + - run: echo "::set-output name=SWC_CHANGE::$(node scripts/run-for-change.js --type next-swc --exec echo 'yup')" id: swc-change - run: echo ${{ steps.swc-change.outputs.SWC_CHANGE }} @@ -1102,7 +1102,7 @@ jobs: with: fetch-depth: 25 - - run: echo ::set-output name=DOCS_CHANGE::$(node scripts/run-for-change.js --not --type docs --exec echo 'nope') + - run: echo "::set-output name=DOCS_CHANGE::$(node scripts/run-for-change.js --not --type docs --exec echo 'nope')" id: docs-change - name: Setup node @@ -1191,7 +1191,7 @@ jobs: with: fetch-depth: 25 - - run: echo ::set-output name=SWC_CHANGE::$(node scripts/run-for-change.js --type next-swc --exec echo 'yup') + - run: echo "::set-output name=SWC_CHANGE::$(node scripts/run-for-change.js --type next-swc --exec echo 'yup')" id: swc-change - run: echo ${{ steps.swc-change.outputs.SWC_CHANGE }} diff --git a/.github/workflows/pull_request_stats.yml b/.github/workflows/pull_request_stats.yml index 5a9dc25f116d..6a5abdc20436 100644 --- a/.github/workflows/pull_request_stats.yml +++ b/.github/workflows/pull_request_stats.yml @@ -24,7 +24,7 @@ jobs: fetch-depth: 25 - name: Check non-docs only change - run: echo ::set-output name=DOCS_CHANGE::$(node scripts/run-for-change.js --not --type docs --exec echo 'nope') + run: echo "::set-output name=DOCS_CHANGE::$(node scripts/run-for-change.js --not --type docs --exec echo 'nope')" id: docs-change - name: Setup node @@ -118,7 +118,7 @@ jobs: fetch-depth: 25 - name: Check non-docs only change - run: echo ::set-output name=DOCS_CHANGE::$(node scripts/run-for-change.js --not --type docs --exec echo 'nope') + run: echo "::set-output name=DOCS_CHANGE::$(node scripts/run-for-change.js --not --type docs --exec echo 'nope')" id: docs-change - uses: actions/download-artifact@v3