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

Update static check vars and fix types #10260

Merged
merged 2 commits into from Jan 24, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/next/build/index.ts
Expand Up @@ -53,6 +53,7 @@ import { generateBuildId } from './generate-build-id'
import { isWriteable } from './is-writeable'
import createSpinner from './spinner'
import {
isPageStatic,
collectPages,
getPageSizeInKb,
hasCustomAppGetInitialProps,
Expand Down Expand Up @@ -416,7 +417,8 @@ export default async function build(dir: string, conf = null): Promise<void> {
const staticCheckWorkers = new Worker(staticCheckWorker, {
numWorkers: config.experimental.cpus,
enableWorkerThreads: config.experimental.workerThreads,
})
}) as Worker & { isPageStatic: typeof isPageStatic }

staticCheckWorkers.getStdout().pipe(process.stdout)
staticCheckWorkers.getStderr().pipe(process.stderr)

Expand Down Expand Up @@ -481,7 +483,7 @@ export default async function build(dir: string, conf = null): Promise<void> {

if (nonReservedPage) {
try {
let result: any = await (staticCheckWorkers as any).isPageStatic(
let result = await staticCheckWorkers.isPageStatic(
page,
serverBundle,
runtimeEnvConfig
Expand All @@ -492,15 +494,15 @@ export default async function build(dir: string, conf = null): Promise<void> {
hybridAmpPages.add(page)
}

if (result.prerender) {
if (result.hasStaticProps) {
ssgPages.add(page)
isSsg = true

if (result.prerenderRoutes) {
additionalSsgPaths.set(page, result.prerenderRoutes)
ssgPageRoutes = result.prerenderRoutes
}
} else if (result.static && customAppGetInitialProps === false) {
} else if (result.isStatic && customAppGetInitialProps === false) {
staticPages.add(page)
isStatic = true
}
Expand Down
8 changes: 4 additions & 4 deletions packages/next/build/utils.ts
Expand Up @@ -479,9 +479,9 @@ export async function isPageStatic(
serverBundle: string,
runtimeEnvConfig: any
): Promise<{
static?: boolean
prerender?: boolean
isStatic?: boolean
isHybridAmp?: boolean
hasStaticProps?: boolean
prerenderRoutes?: string[] | undefined
}> {
try {
Expand Down Expand Up @@ -593,10 +593,10 @@ export async function isPageStatic(

const config = mod.config || {}
return {
static: !hasStaticProps && !hasGetInitialProps,
isStatic: !hasStaticProps && !hasGetInitialProps,
isHybridAmp: config.amp === 'hybrid',
prerenderRoutes: prerenderPaths,
prerender: hasStaticProps,
hasStaticProps,
}
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') return {}
Expand Down