Unverified Commit 948f736f authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

chore: rename middleware ssr loader and flight manifest to edge related (#38042)

middleware-ssr-loader -> edge-ssr-loader
middleware-flight-manifest -> flight-manifest
parent dbfd594e
import type { ClientPagesLoaderOptions } from './webpack/loaders/next-client-pages-loader' import type { ClientPagesLoaderOptions } from './webpack/loaders/next-client-pages-loader'
import type { MiddlewareLoaderOptions } from './webpack/loaders/next-middleware-loader' import type { MiddlewareLoaderOptions } from './webpack/loaders/next-middleware-loader'
import type { MiddlewareSSRLoaderQuery } from './webpack/loaders/next-middleware-ssr-loader' import type { EdgeSSRLoaderQuery } from './webpack/loaders/next-edge-ssr-loader'
import type { NextConfigComplete } from '../server/config-shared' import type { NextConfigComplete } from '../server/config-shared'
import type { PageRuntime } from '../server/config-shared' import type { PageRuntime } from '../server/config-shared'
import type { ServerlessLoaderQuery } from './webpack/loaders/next-serverless-loader' import type { ServerlessLoaderQuery } from './webpack/loaders/next-serverless-loader'
...@@ -184,7 +184,7 @@ export function getEdgeServerEntry(opts: { ...@@ -184,7 +184,7 @@ export function getEdgeServerEntry(opts: {
return `next-edge-function-loader?${stringify(loaderParams)}!` return `next-edge-function-loader?${stringify(loaderParams)}!`
} }
const loaderParams: MiddlewareSSRLoaderQuery = { const loaderParams: EdgeSSRLoaderQuery = {
absolute500Path: opts.pages['/500'] || '', absolute500Path: opts.pages['/500'] || '',
absoluteAppPath: opts.pages['/_app'], absoluteAppPath: opts.pages['/_app'],
absoluteDocumentPath: opts.pages['/_document'], absoluteDocumentPath: opts.pages['/_document'],
...@@ -201,7 +201,7 @@ export function getEdgeServerEntry(opts: { ...@@ -201,7 +201,7 @@ export function getEdgeServerEntry(opts: {
} }
return { return {
import: `next-middleware-ssr-loader?${stringify(loaderParams)}!`, import: `next-edge-ssr-loader?${stringify(loaderParams)}!`,
layer: opts.isServerComponent ? 'sc_server' : undefined, layer: opts.isServerComponent ? 'sc_server' : undefined,
} }
} }
......
...@@ -45,7 +45,7 @@ import { ...@@ -45,7 +45,7 @@ import {
PAGES_MANIFEST, PAGES_MANIFEST,
PHASE_PRODUCTION_BUILD, PHASE_PRODUCTION_BUILD,
PRERENDER_MANIFEST, PRERENDER_MANIFEST,
MIDDLEWARE_FLIGHT_MANIFEST, FLIGHT_MANIFEST,
REACT_LOADABLE_MANIFEST, REACT_LOADABLE_MANIFEST,
ROUTES_MANIFEST, ROUTES_MANIFEST,
SERVERLESS_DIRECTORY, SERVERLESS_DIRECTORY,
...@@ -674,14 +674,8 @@ export default async function build( ...@@ -674,14 +674,8 @@ export default async function build(
path.join(SERVER_DIRECTORY, MIDDLEWARE_MANIFEST), path.join(SERVER_DIRECTORY, MIDDLEWARE_MANIFEST),
...(hasServerComponents ...(hasServerComponents
? [ ? [
path.join( path.join(SERVER_DIRECTORY, FLIGHT_MANIFEST + '.js'),
SERVER_DIRECTORY, path.join(SERVER_DIRECTORY, FLIGHT_MANIFEST + '.json'),
MIDDLEWARE_FLIGHT_MANIFEST + '.js'
),
path.join(
SERVER_DIRECTORY,
MIDDLEWARE_FLIGHT_MANIFEST + '.json'
),
] ]
: []), : []),
REACT_LOADABLE_MANIFEST, REACT_LOADABLE_MANIFEST,
......
...@@ -1224,7 +1224,7 @@ export default async function getBaseWebpackConfig( ...@@ -1224,7 +1224,7 @@ export default async function getBaseWebpackConfig(
'noop-loader', 'noop-loader',
'next-middleware-loader', 'next-middleware-loader',
'next-edge-function-loader', 'next-edge-function-loader',
'next-middleware-ssr-loader', 'next-edge-ssr-loader',
'next-middleware-wasm-loader', 'next-middleware-wasm-loader',
'next-app-loader', 'next-app-loader',
].reduce((alias, loader) => { ].reduce((alias, loader) => {
......
import { getModuleBuildInfo } from '../get-module-build-info' import { getModuleBuildInfo } from '../get-module-build-info'
import { stringifyRequest } from '../../stringify-request' import { stringifyRequest } from '../../stringify-request'
export type MiddlewareSSRLoaderQuery = { export type EdgeSSRLoaderQuery = {
absolute500Path: string absolute500Path: string
absoluteAppPath: string absoluteAppPath: string
absoluteDocumentPath: string absoluteDocumentPath: string
...@@ -14,7 +14,7 @@ export type MiddlewareSSRLoaderQuery = { ...@@ -14,7 +14,7 @@ export type MiddlewareSSRLoaderQuery = {
stringifiedConfig: string stringifiedConfig: string
} }
export default async function middlewareSSRLoader(this: any) { export default async function edgeSSRLoader(this: any) {
const { const {
dev, dev,
page, page,
...@@ -48,7 +48,7 @@ export default async function middlewareSSRLoader(this: any) { ...@@ -48,7 +48,7 @@ export default async function middlewareSSRLoader(this: any) {
const transformed = ` const transformed = `
import { adapter } from 'next/dist/server/web/adapter' import { adapter } from 'next/dist/server/web/adapter'
import { getRender } from 'next/dist/build/webpack/loaders/next-middleware-ssr-loader/render' import { getRender } from 'next/dist/build/webpack/loaders/next-edge-ssr-loader/render'
import Document from ${stringifiedDocumentPath} import Document from ${stringifiedDocumentPath}
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
*/ */
import { webpack, sources } from 'next/dist/compiled/webpack/webpack' import { webpack, sources } from 'next/dist/compiled/webpack/webpack'
import { MIDDLEWARE_FLIGHT_MANIFEST } from '../../../shared/lib/constants' import { FLIGHT_MANIFEST } from '../../../shared/lib/constants'
import { clientComponentRegex } from '../loaders/utils' import { clientComponentRegex } from '../loaders/utils'
import { relative } from 'path' import { relative } from 'path'
...@@ -173,7 +173,7 @@ export class FlightManifestPlugin { ...@@ -173,7 +173,7 @@ export class FlightManifestPlugin {
}) })
}) })
const file = 'server/' + MIDDLEWARE_FLIGHT_MANIFEST const file = 'server/' + FLIGHT_MANIFEST
const json = JSON.stringify(manifest) const json = JSON.stringify(manifest)
assets[file + '.js'] = new sources.RawSource('self.__RSC_MANIFEST=' + json) assets[file + '.js'] = new sources.RawSource('self.__RSC_MANIFEST=' + json)
......
...@@ -8,7 +8,7 @@ import { ...@@ -8,7 +8,7 @@ import {
EDGE_RUNTIME_WEBPACK, EDGE_RUNTIME_WEBPACK,
EDGE_UNSUPPORTED_NODE_APIS, EDGE_UNSUPPORTED_NODE_APIS,
MIDDLEWARE_BUILD_MANIFEST, MIDDLEWARE_BUILD_MANIFEST,
MIDDLEWARE_FLIGHT_MANIFEST, FLIGHT_MANIFEST,
MIDDLEWARE_MANIFEST, MIDDLEWARE_MANIFEST,
MIDDLEWARE_REACT_LOADABLE_MANIFEST, MIDDLEWARE_REACT_LOADABLE_MANIFEST,
NEXT_CLIENT_SSR_ENTRY_SUFFIX, NEXT_CLIENT_SSR_ENTRY_SUFFIX,
...@@ -531,7 +531,7 @@ function getEntryFiles(entryFiles: string[], meta: EntryMetadata) { ...@@ -531,7 +531,7 @@ function getEntryFiles(entryFiles: string[], meta: EntryMetadata) {
const files: string[] = [] const files: string[] = []
if (meta.edgeSSR) { if (meta.edgeSSR) {
if (meta.edgeSSR.isServerComponent) { if (meta.edgeSSR.isServerComponent) {
files.push(`server/${MIDDLEWARE_FLIGHT_MANIFEST}.js`) files.push(`server/${FLIGHT_MANIFEST}.js`)
files.push( files.push(
...entryFiles ...entryFiles
.filter( .filter(
......
...@@ -12,7 +12,7 @@ import type { ...@@ -12,7 +12,7 @@ import type {
import { import {
BUILD_MANIFEST, BUILD_MANIFEST,
REACT_LOADABLE_MANIFEST, REACT_LOADABLE_MANIFEST,
MIDDLEWARE_FLIGHT_MANIFEST, FLIGHT_MANIFEST,
NEXT_CLIENT_SSR_ENTRY_SUFFIX, NEXT_CLIENT_SSR_ENTRY_SUFFIX,
} from '../shared/lib/constants' } from '../shared/lib/constants'
import { join } from 'path' import { join } from 'path'
...@@ -118,7 +118,7 @@ export async function loadComponents( ...@@ -118,7 +118,7 @@ export async function loadComponents(
require(join(distDir, BUILD_MANIFEST)), require(join(distDir, BUILD_MANIFEST)),
require(join(distDir, REACT_LOADABLE_MANIFEST)), require(join(distDir, REACT_LOADABLE_MANIFEST)),
hasServerComponents hasServerComponents
? require(join(distDir, 'server', MIDDLEWARE_FLIGHT_MANIFEST + '.json')) ? require(join(distDir, 'server', FLIGHT_MANIFEST + '.json'))
: null, : null,
]) ])
......
...@@ -35,7 +35,7 @@ import { ...@@ -35,7 +35,7 @@ import {
CLIENT_STATIC_FILES_RUNTIME, CLIENT_STATIC_FILES_RUNTIME,
PRERENDER_MANIFEST, PRERENDER_MANIFEST,
ROUTES_MANIFEST, ROUTES_MANIFEST,
MIDDLEWARE_FLIGHT_MANIFEST, FLIGHT_MANIFEST,
CLIENT_PUBLIC_FILES_PATH, CLIENT_PUBLIC_FILES_PATH,
APP_PATHS_MANIFEST, APP_PATHS_MANIFEST,
} from '../shared/lib/constants' } from '../shared/lib/constants'
...@@ -747,11 +747,7 @@ export default class NextNodeServer extends BaseServer { ...@@ -747,11 +747,7 @@ export default class NextNodeServer extends BaseServer {
protected getServerComponentManifest() { protected getServerComponentManifest() {
if (!this.nextConfig.experimental.serverComponents) return undefined if (!this.nextConfig.experimental.serverComponents) return undefined
return require(join( return require(join(this.distDir, 'server', FLIGHT_MANIFEST + '.json'))
this.distDir,
'server',
MIDDLEWARE_FLIGHT_MANIFEST + '.json'
))
} }
protected getCacheFilesystem(): CacheFs { protected getCacheFilesystem(): CacheFs {
......
...@@ -36,8 +36,8 @@ export const MODERN_BROWSERSLIST_TARGET = [ ...@@ -36,8 +36,8 @@ export const MODERN_BROWSERSLIST_TARGET = [
export const NEXT_BUILTIN_DOCUMENT = '__NEXT_BUILTIN_DOCUMENT__' export const NEXT_BUILTIN_DOCUMENT = '__NEXT_BUILTIN_DOCUMENT__'
export const NEXT_CLIENT_SSR_ENTRY_SUFFIX = '.__sc_client__' export const NEXT_CLIENT_SSR_ENTRY_SUFFIX = '.__sc_client__'
// server/middleware-flight-manifest.js // server/flight-manifest.js
export const MIDDLEWARE_FLIGHT_MANIFEST = 'middleware-flight-manifest' export const FLIGHT_MANIFEST = 'flight-manifest'
// server/middleware-build-manifest.js // server/middleware-build-manifest.js
export const MIDDLEWARE_BUILD_MANIFEST = 'middleware-build-manifest' export const MIDDLEWARE_BUILD_MANIFEST = 'middleware-build-manifest'
// server/middleware-react-loadable-manifest.js // server/middleware-react-loadable-manifest.js
......
...@@ -82,14 +82,14 @@ const edgeRuntimeBasicSuite = { ...@@ -82,14 +82,14 @@ const edgeRuntimeBasicSuite = {
expect(context.stderr).toContain(rscWarning) expect(context.stderr).toContain(rscWarning)
}) })
it('should generate middleware SSR manifests for edge runtime', async () => { it('should generate edge SSR manifests for edge runtime', async () => {
const distServerDir = join(distDir, 'server') const distServerDir = join(distDir, 'server')
const files = [ const files = [
'edge-runtime-webpack.js', 'edge-runtime-webpack.js',
'middleware-build-manifest.js', 'middleware-build-manifest.js',
'middleware-flight-manifest.js',
'middleware-flight-manifest.json',
'middleware-manifest.json', 'middleware-manifest.json',
'flight-manifest.js',
'flight-manifest.json',
] ]
const requiredServerFiles = ( const requiredServerFiles = (
...@@ -125,7 +125,7 @@ const nodejsRuntimeBasicSuite = { ...@@ -125,7 +125,7 @@ const nodejsRuntimeBasicSuite = {
rsc(context, options) rsc(context, options)
if (env === 'prod') { if (env === 'prod') {
it('should generate middleware SSR manifests for Node.js', async () => { it('should generate edge SSR manifests for Node.js', async () => {
const distServerDir = join(distDir, 'server') const distServerDir = join(distDir, 'server')
const requiredServerFiles = ( const requiredServerFiles = (
...@@ -134,8 +134,8 @@ const nodejsRuntimeBasicSuite = { ...@@ -134,8 +134,8 @@ const nodejsRuntimeBasicSuite = {
const files = [ const files = [
'middleware-build-manifest.js', 'middleware-build-manifest.js',
'middleware-flight-manifest.json',
'middleware-manifest.json', 'middleware-manifest.json',
'flight-manifest.json',
] ]
files.forEach((file) => { files.forEach((file) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment