Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jun 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/next/build/entries.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ClientPagesLoaderOptions } from './webpack/loaders/next-client-pages-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 { PageRuntime } from '../server/config-shared'
import type { ServerlessLoaderQuery } from './webpack/loaders/next-serverless-loader'
Expand Down Expand Up @@ -184,7 +184,7 @@ export function getEdgeServerEntry(opts: {
return `next-edge-function-loader?${stringify(loaderParams)}!`
}

const loaderParams: MiddlewareSSRLoaderQuery = {
const loaderParams: EdgeSSRLoaderQuery = {
absolute500Path: opts.pages['/500'] || '',
absoluteAppPath: opts.pages['/_app'],
absoluteDocumentPath: opts.pages['/_document'],
Expand All @@ -201,7 +201,7 @@ export function getEdgeServerEntry(opts: {
}

return {
import: `next-middleware-ssr-loader?${stringify(loaderParams)}!`,
import: `next-edge-ssr-loader?${stringify(loaderParams)}!`,
layer: opts.isServerComponent ? 'sc_server' : undefined,
}
}
Expand Down
12 changes: 3 additions & 9 deletions packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
PAGES_MANIFEST,
PHASE_PRODUCTION_BUILD,
PRERENDER_MANIFEST,
MIDDLEWARE_FLIGHT_MANIFEST,
FLIGHT_MANIFEST,
REACT_LOADABLE_MANIFEST,
ROUTES_MANIFEST,
SERVERLESS_DIRECTORY,
Expand Down Expand Up @@ -674,14 +674,8 @@ export default async function build(
path.join(SERVER_DIRECTORY, MIDDLEWARE_MANIFEST),
...(hasServerComponents
? [
path.join(
SERVER_DIRECTORY,
MIDDLEWARE_FLIGHT_MANIFEST + '.js'
),
path.join(
SERVER_DIRECTORY,
MIDDLEWARE_FLIGHT_MANIFEST + '.json'
),
path.join(SERVER_DIRECTORY, FLIGHT_MANIFEST + '.js'),
path.join(SERVER_DIRECTORY, FLIGHT_MANIFEST + '.json'),
]
: []),
REACT_LOADABLE_MANIFEST,
Expand Down
2 changes: 1 addition & 1 deletion packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ export default async function getBaseWebpackConfig(
'noop-loader',
'next-middleware-loader',
'next-edge-function-loader',
'next-middleware-ssr-loader',
'next-edge-ssr-loader',
'next-middleware-wasm-loader',
'next-app-loader',
].reduce((alias, loader) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getModuleBuildInfo } from '../get-module-build-info'
import { stringifyRequest } from '../../stringify-request'

export type MiddlewareSSRLoaderQuery = {
export type EdgeSSRLoaderQuery = {
absolute500Path: string
absoluteAppPath: string
absoluteDocumentPath: string
Expand All @@ -14,7 +14,7 @@ export type MiddlewareSSRLoaderQuery = {
stringifiedConfig: string
}

export default async function middlewareSSRLoader(this: any) {
export default async function edgeSSRLoader(this: any) {
const {
dev,
page,
Expand Down Expand Up @@ -48,7 +48,7 @@ export default async function middlewareSSRLoader(this: any) {

const transformed = `
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}

Expand Down
4 changes: 2 additions & 2 deletions packages/next/build/webpack/plugins/flight-manifest-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

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 { relative } from 'path'

Expand Down Expand Up @@ -173,7 +173,7 @@ export class FlightManifestPlugin {
})
})

const file = 'server/' + MIDDLEWARE_FLIGHT_MANIFEST
const file = 'server/' + FLIGHT_MANIFEST
const json = JSON.stringify(manifest)

assets[file + '.js'] = new sources.RawSource('self.__RSC_MANIFEST=' + json)
Expand Down
4 changes: 2 additions & 2 deletions packages/next/build/webpack/plugins/middleware-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
EDGE_RUNTIME_WEBPACK,
EDGE_UNSUPPORTED_NODE_APIS,
MIDDLEWARE_BUILD_MANIFEST,
MIDDLEWARE_FLIGHT_MANIFEST,
FLIGHT_MANIFEST,
MIDDLEWARE_MANIFEST,
MIDDLEWARE_REACT_LOADABLE_MANIFEST,
NEXT_CLIENT_SSR_ENTRY_SUFFIX,
Expand Down Expand Up @@ -531,7 +531,7 @@ function getEntryFiles(entryFiles: string[], meta: EntryMetadata) {
const files: string[] = []
if (meta.edgeSSR) {
if (meta.edgeSSR.isServerComponent) {
files.push(`server/${MIDDLEWARE_FLIGHT_MANIFEST}.js`)
files.push(`server/${FLIGHT_MANIFEST}.js`)
files.push(
...entryFiles
.filter(
Expand Down
4 changes: 2 additions & 2 deletions packages/next/server/load-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
import {
BUILD_MANIFEST,
REACT_LOADABLE_MANIFEST,
MIDDLEWARE_FLIGHT_MANIFEST,
FLIGHT_MANIFEST,
NEXT_CLIENT_SSR_ENTRY_SUFFIX,
} from '../shared/lib/constants'
import { join } from 'path'
Expand Down Expand Up @@ -118,7 +118,7 @@ export async function loadComponents(
require(join(distDir, BUILD_MANIFEST)),
require(join(distDir, REACT_LOADABLE_MANIFEST)),
hasServerComponents
? require(join(distDir, 'server', MIDDLEWARE_FLIGHT_MANIFEST + '.json'))
? require(join(distDir, 'server', FLIGHT_MANIFEST + '.json'))
: null,
])

Expand Down
8 changes: 2 additions & 6 deletions packages/next/server/next-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
CLIENT_STATIC_FILES_RUNTIME,
PRERENDER_MANIFEST,
ROUTES_MANIFEST,
MIDDLEWARE_FLIGHT_MANIFEST,
FLIGHT_MANIFEST,
CLIENT_PUBLIC_FILES_PATH,
APP_PATHS_MANIFEST,
} from '../shared/lib/constants'
Expand Down Expand Up @@ -747,11 +747,7 @@ export default class NextNodeServer extends BaseServer {

protected getServerComponentManifest() {
if (!this.nextConfig.experimental.serverComponents) return undefined
return require(join(
this.distDir,
'server',
MIDDLEWARE_FLIGHT_MANIFEST + '.json'
))
return require(join(this.distDir, 'server', FLIGHT_MANIFEST + '.json'))
}

protected getCacheFilesystem(): CacheFs {
Expand Down
4 changes: 2 additions & 2 deletions packages/next/shared/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export const MODERN_BROWSERSLIST_TARGET = [
export const NEXT_BUILTIN_DOCUMENT = '__NEXT_BUILTIN_DOCUMENT__'
export const NEXT_CLIENT_SSR_ENTRY_SUFFIX = '.__sc_client__'

// server/middleware-flight-manifest.js
export const MIDDLEWARE_FLIGHT_MANIFEST = 'middleware-flight-manifest'
// server/flight-manifest.js
export const FLIGHT_MANIFEST = 'flight-manifest'
// server/middleware-build-manifest.js
export const MIDDLEWARE_BUILD_MANIFEST = 'middleware-build-manifest'
// server/middleware-react-loadable-manifest.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ const edgeRuntimeBasicSuite = {
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 files = [
'edge-runtime-webpack.js',
'middleware-build-manifest.js',
'middleware-flight-manifest.js',
'middleware-flight-manifest.json',
'middleware-manifest.json',
'flight-manifest.js',
'flight-manifest.json',
]

const requiredServerFiles = (
Expand Down Expand Up @@ -125,7 +125,7 @@ const nodejsRuntimeBasicSuite = {
rsc(context, options)

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 requiredServerFiles = (
Expand All @@ -134,8 +134,8 @@ const nodejsRuntimeBasicSuite = {

const files = [
'middleware-build-manifest.js',
'middleware-flight-manifest.json',
'middleware-manifest.json',
'flight-manifest.json',
]

files.forEach((file) => {
Expand Down