Skip to content

Commit

Permalink
Only generate modern version in modern mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Mar 2, 2020
1 parent 363928b commit 1c15762
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,11 @@ export default async function build(dir: string, conf = null): Promise<void> {
JSON.stringify(prerenderManifest),
'utf8'
)
await generateClientSsgManifest(prerenderManifest, { distDir, buildId })
await generateClientSsgManifest(prerenderManifest, {
distDir,
buildId,
isModern: !!config.experimental.modern,
})
} else {
const prerenderManifest: PrerenderManifest = {
version: 2,
Expand Down Expand Up @@ -969,7 +973,11 @@ export default async function build(dir: string, conf = null): Promise<void> {

function generateClientSsgManifest(
prerenderManifest: PrerenderManifest,
{ buildId, distDir }: { buildId: string; distDir: string }
{
buildId,
distDir,
isModern,
}: { buildId: string; distDir: string; isModern: boolean }
) {
const ssgPages: Set<string> = new Set<string>([
...Object.keys(prerenderManifest.routes),
Expand All @@ -978,8 +986,10 @@ function generateClientSsgManifest(

const clientSsgManifestPaths = [
'_ssgManifest.js',
'_ssgManifest.module.js',
].map(f => path.join(`${CLIENT_STATIC_FILES_PATH}/${buildId}`, f))
isModern && '_ssgManifest.module.js',
]
.filter(Boolean)
.map(f => path.join(`${CLIENT_STATIC_FILES_PATH}/${buildId}`, f as string))
const clientSsgManifestContent = `self.__SSG_MANIFEST=${devalue(
ssgPages
)};self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB()`
Expand Down

0 comments on commit 1c15762

Please sign in to comment.