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

Ensure SERVER_REFERENCE_MANIFEST is included in output files #46420

Merged
merged 2 commits into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import {
MIDDLEWARE_REACT_LOADABLE_MANIFEST,
TURBO_TRACE_DEFAULT_MEMORY_LIMIT,
TRACE_OUTPUT_VERSION,
SERVER_REFERENCE_MANIFEST,
} from '../shared/lib/constants'
import { getSortedRoutes, isDynamicRoute } from '../shared/lib/router/utils'
import { __ApiPreviewProps } from '../server/api-utils'
Expand Down Expand Up @@ -970,6 +971,14 @@ export default async function build(
SERVER_DIRECTORY,
FLIGHT_SERVER_CSS_MANIFEST + '.json'
),
path.join(
SERVER_DIRECTORY,
SERVER_REFERENCE_MANIFEST + '.js'
),
path.join(
SERVER_DIRECTORY,
SERVER_REFERENCE_MANIFEST + '.json'
),
]
: []),
REACT_LOADABLE_MANIFEST,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export default async function edgeSSRLoader(this: any) {
const reactLoadableManifest = self.__REACT_LOADABLE_MANIFEST
const rscManifest = self.__RSC_MANIFEST
const rscCssManifest = self.__RSC_CSS_MANIFEST
const rscServerManifest = self.__RSC_SERVER_MANIFEST
const subresourceIntegrityManifest = ${
sriEnabled ? 'self.__SUBRESOURCE_INTEGRITY_MANIFEST' : 'undefined'
}
Expand All @@ -150,6 +151,7 @@ export default async function edgeSSRLoader(this: any) {
reactLoadableManifest,
serverComponentManifest: ${isServerComponent} ? rscManifest : null,
serverCSSManifest: ${isServerComponent} ? rscCssManifest : null,
serverActionsManifest: ${isServerComponent} ? rscServerManifest : null,
subresourceIntegrityManifest,
config: ${stringifiedConfig},
buildId: ${JSON.stringify(buildId)},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function getRender({
serverComponentManifest,
subresourceIntegrityManifest,
serverCSSManifest,
serverActionsManifest,
config,
buildId,
fontLoaderManifest,
Expand All @@ -48,6 +49,7 @@ export function getRender({
subresourceIntegrityManifest?: Record<string, string>
serverComponentManifest: any
serverCSSManifest: any
serverActionsManifest: any
appServerMod: any
config: NextConfigComplete
buildId: string
Expand Down Expand Up @@ -79,6 +81,7 @@ export function getRender({
disableOptimizedLoading: true,
serverComponentManifest,
serverCSSManifest,
serverActionsManifest,
},
appRenderToHTML,
pagesRenderToHTML,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,9 @@ export class FlightClientEntryPlugin {
}

const json = JSON.stringify(serverActions, null, this.dev ? 2 : undefined)
assets[SERVER_REFERENCE_MANIFEST + '.js'] = new sources.RawSource(
'self.__RSC_SERVER_MANIFEST=' + json
) as unknown as webpack.sources.RawSource
assets[SERVER_REFERENCE_MANIFEST + '.json'] = new sources.RawSource(
json
) as unknown as webpack.sources.RawSource
Expand Down
2 changes: 2 additions & 0 deletions packages/next/src/build/webpack/plugins/middleware-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
FLIGHT_SERVER_CSS_MANIFEST,
SUBRESOURCE_INTEGRITY_MANIFEST,
FONT_LOADER_MANIFEST,
SERVER_REFERENCE_MANIFEST,
} from '../../../shared/lib/constants'
import {
getPageStaticInfo,
Expand Down Expand Up @@ -99,6 +100,7 @@ function getEntryFiles(
const files: string[] = []
if (meta.edgeSSR) {
if (meta.edgeSSR.isServerComponent) {
files.push(`server/${SERVER_REFERENCE_MANIFEST}.js`)
files.push(`server/${CLIENT_REFERENCE_MANIFEST}.js`)
files.push(`server/${FLIGHT_SERVER_CSS_MANIFEST}.js`)
if (opts.sriEnabled) {
Expand Down
9 changes: 8 additions & 1 deletion packages/next/src/export/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
PHASE_EXPORT,
PRERENDER_MANIFEST,
SERVER_DIRECTORY,
SERVER_REFERENCE_MANIFEST,
} from '../shared/lib/constants'
import loadConfig from '../server/config'
import { ExportPathMap, NextConfigComplete } from '../server/config-shared'
Expand Down Expand Up @@ -443,14 +444,20 @@ export default async function exportApp(
renderOpts.serverComponentManifest = require(join(
distDir,
SERVER_DIRECTORY,
`${CLIENT_REFERENCE_MANIFEST}.json`
CLIENT_REFERENCE_MANIFEST + '.json'
)) as PagesManifest
// @ts-expect-error untyped
renderOpts.serverCSSManifest = require(join(
distDir,
SERVER_DIRECTORY,
FLIGHT_SERVER_CSS_MANIFEST + '.json'
)) as PagesManifest
// @ts-expect-error untyped
renderOpts.serverActionsManifest = require(join(
distDir,
SERVER_DIRECTORY,
SERVER_REFERENCE_MANIFEST + '.json'
)) as PagesManifest
}

// only add missing 404 page when `buildExport` is false
Expand Down
1 change: 1 addition & 0 deletions packages/next/src/server/base-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
isBot?: boolean
serverComponentManifest?: any
serverCSSManifest?: any
serverActionsManifest?: any
fontLoaderManifest?: FontLoaderManifest
renderServerComponentData?: boolean
serverComponentProps?: any
Expand Down