Unverified Commit a1cc1eaf authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Remove unused return values from getPageStaticInfo (#97661)

Some cleanup, this was never used:
- `config` from `getStaticInfoIncludingLayouts`
- `getServerSideProps` and `getStaticProps` from pages router
parent a11f82c5
...@@ -77,31 +77,26 @@ export type ProxyConfig = { ...@@ -77,31 +77,26 @@ export type ProxyConfig = {
unstable_allowDynamic?: string[] unstable_allowDynamic?: string[]
} }
export interface AppPageStaticInfo { export interface SharedPageStaticInfo {
type: PAGE_TYPES.APP
ssg?: boolean
ssr?: boolean
rsc?: RSCModuleType rsc?: RSCModuleType
generateStaticParams?: boolean
generateSitemaps?: boolean generateSitemaps?: boolean
generateImageMetadata?: boolean generateImageMetadata?: boolean
middleware?: ProxyConfig middleware?: ProxyConfig
maxDuration: number | undefined
hadUnsupportedValue: boolean
}
export interface AppPageStaticInfo extends SharedPageStaticInfo {
type: PAGE_TYPES.APP
ssg?: boolean
ssr?: boolean
config: Omit<AppSegmentConfig, 'runtime' | 'maxDuration'> | undefined config: Omit<AppSegmentConfig, 'runtime' | 'maxDuration'> | undefined
runtime: AppSegmentConfig['runtime'] | undefined runtime: AppSegmentConfig['runtime'] | undefined
preferredRegion: AppSegmentConfig['preferredRegion'] | undefined preferredRegion: AppSegmentConfig['preferredRegion'] | undefined
maxDuration: number | undefined
hadUnsupportedValue: boolean
} }
export interface PagesPageStaticInfo { export interface PagesPageStaticInfo extends SharedPageStaticInfo {
type: PAGE_TYPES.PAGES type: PAGE_TYPES.PAGES
getStaticProps?: boolean
getServerSideProps?: boolean
rsc?: RSCModuleType
generateStaticParams?: boolean
generateSitemaps?: boolean
generateImageMetadata?: boolean
middleware?: ProxyConfig
config: config:
| (Omit<PagesSegmentConfig, 'runtime' | 'config' | 'maxDuration'> & { | (Omit<PagesSegmentConfig, 'runtime' | 'config' | 'maxDuration'> & {
config?: Omit<PagesSegmentConfigConfig, 'runtime' | 'maxDuration'> config?: Omit<PagesSegmentConfigConfig, 'runtime' | 'maxDuration'>
...@@ -109,8 +104,6 @@ export interface PagesPageStaticInfo { ...@@ -109,8 +104,6 @@ export interface PagesPageStaticInfo {
| undefined | undefined
runtime: PagesSegmentConfig['runtime'] | undefined runtime: PagesSegmentConfig['runtime'] | undefined
preferredRegion: PagesSegmentConfigConfig['regions'] | undefined preferredRegion: PagesSegmentConfigConfig['regions'] | undefined
maxDuration: number | undefined
hadUnsupportedValue: boolean
} }
export type PageStaticInfo = AppPageStaticInfo | PagesPageStaticInfo export type PageStaticInfo = AppPageStaticInfo | PagesPageStaticInfo
...@@ -755,7 +748,6 @@ export async function getAppPageStaticInfo({ ...@@ -755,7 +748,6 @@ export async function getAppPageStaticInfo({
rsc, rsc,
generateImageMetadata, generateImageMetadata,
generateSitemaps, generateSitemaps,
generateStaticParams,
config, config,
middleware: parseMiddlewareConfig(page, exportedConfig.config, nextConfig), middleware: parseMiddlewareConfig(page, exportedConfig.config, nextConfig),
runtime: config.runtime, runtime: config.runtime,
...@@ -791,11 +783,7 @@ export async function getPagesPageStaticInfo({ ...@@ -791,11 +783,7 @@ export async function getPagesPageStaticInfo({
isDev, isDev,
}) })
const { getServerSideProps, getStaticProps, exports } = checkExports( const { exports } = checkExports(ast, PagesSegmentConfigSchemaKeys, page)
ast,
PagesSegmentConfigSchemaKeys,
page
)
const { type: rsc } = getRSCModuleInformation(content, true) const { type: rsc } = getRSCModuleInformation(content, true)
...@@ -870,8 +858,6 @@ export async function getPagesPageStaticInfo({ ...@@ -870,8 +858,6 @@ export async function getPagesPageStaticInfo({
return { return {
type: PAGE_TYPES.PAGES, type: PAGE_TYPES.PAGES,
getStaticProps,
getServerSideProps,
rsc, rsc,
config, config,
middleware: parseMiddlewareConfig(page, exportedConfig.config, nextConfig), middleware: parseMiddlewareConfig(page, exportedConfig.config, nextConfig),
......
...@@ -4,11 +4,7 @@ import type { EdgeSSRLoaderQuery } from './webpack/loaders/next-edge-ssr-loader' ...@@ -4,11 +4,7 @@ import type { EdgeSSRLoaderQuery } from './webpack/loaders/next-edge-ssr-loader'
import type { EdgeAppRouteLoaderQuery } from './webpack/loaders/next-edge-app-route-loader' import type { EdgeAppRouteLoaderQuery } from './webpack/loaders/next-edge-app-route-loader'
import type { NextConfigComplete } from '../server/config-shared' import type { NextConfigComplete } from '../server/config-shared'
import type { webpack } from 'next/dist/compiled/webpack/webpack' import type { webpack } from 'next/dist/compiled/webpack/webpack'
import type { import type { ProxyConfig, ProxyMatcher } from './analysis/get-page-static-info'
ProxyConfig,
ProxyMatcher,
PageStaticInfo,
} from './analysis/get-page-static-info'
import type { LoadedEnvFiles } from '@next/env' import type { LoadedEnvFiles } from '@next/env'
import type { AppLoaderOptions } from './webpack/loaders/next-app-loader' import type { AppLoaderOptions } from './webpack/loaders/next-app-loader'
...@@ -478,7 +474,7 @@ export async function createEntrypoints( ...@@ -478,7 +474,7 @@ export async function createEntrypoints(
(absolutePagePath.startsWith(APP_DIR_ALIAS) || (absolutePagePath.startsWith(APP_DIR_ALIAS) ||
absolutePagePath.startsWith(appDir)) absolutePagePath.startsWith(appDir))
const staticInfo: PageStaticInfo = await getStaticInfoIncludingLayouts({ const staticInfo = await getStaticInfoIncludingLayouts({
isInsideAppDir, isInsideAppDir,
pageExtensions, pageExtensions,
pageFilePath, pageFilePath,
......
...@@ -31,7 +31,7 @@ export async function getStaticInfoIncludingLayouts({ ...@@ -31,7 +31,7 @@ export async function getStaticInfoIncludingLayouts({
config: NextConfigComplete config: NextConfigComplete
isDev: boolean isDev: boolean
page: string page: string
}): Promise<PageStaticInfo> { }): Promise<Omit<PageStaticInfo, 'config'>> {
// TODO: sync types for pages: PAGE_TYPES, ROUTER_TYPE, 'app' | 'pages', etc. // TODO: sync types for pages: PAGE_TYPES, ROUTER_TYPE, 'app' | 'pages', etc.
const pageType = isInsideAppDir ? PAGE_TYPES.APP : PAGE_TYPES.PAGES const pageType = isInsideAppDir ? PAGE_TYPES.APP : PAGE_TYPES.PAGES
...@@ -90,7 +90,6 @@ export async function getStaticInfoIncludingLayouts({ ...@@ -90,7 +90,6 @@ export async function getStaticInfoIncludingLayouts({
return { return {
...pageStaticInfo, ...pageStaticInfo,
config,
runtime: config.runtime, runtime: config.runtime,
preferredRegion: config.preferredRegion, preferredRegion: config.preferredRegion,
maxDuration: config.maxDuration, maxDuration: config.maxDuration,
......
...@@ -14,31 +14,25 @@ describe('parse page static info', () => { ...@@ -14,31 +14,25 @@ describe('parse page static info', () => {
await installBindings() await installBindings()
}) })
it('should parse nodejs runtime correctly', async () => { it('should parse nodejs runtime correctly', async () => {
const { runtime, getServerSideProps, getStaticProps } = const { runtime } = await getPagesPageStaticInfo({
await getPagesPageStaticInfo({ page: 'nodejs-ssr',
page: 'nodejs-ssr', pageFilePath: join(fixtureDir, 'page-runtime/nodejs-ssr.js'),
pageFilePath: join(fixtureDir, 'page-runtime/nodejs-ssr.js'), nextConfig: createNextConfig(),
nextConfig: createNextConfig(), pageType: PAGE_TYPES.PAGES,
pageType: PAGE_TYPES.PAGES, isDev: false,
isDev: false, })
})
expect(runtime).toBe('nodejs') expect(runtime).toBe('nodejs')
expect(getServerSideProps).toBe(true)
expect(getStaticProps).toBe(false)
}) })
it('should parse static runtime correctly', async () => { it('should parse static runtime correctly', async () => {
const { runtime, getServerSideProps, getStaticProps } = const { runtime } = await getPagesPageStaticInfo({
await getPagesPageStaticInfo({ page: 'nodejs',
page: 'nodejs', pageFilePath: join(fixtureDir, 'page-runtime/nodejs.js'),
pageFilePath: join(fixtureDir, 'page-runtime/nodejs.js'), nextConfig: createNextConfig(),
nextConfig: createNextConfig(), pageType: PAGE_TYPES.PAGES,
pageType: PAGE_TYPES.PAGES, isDev: false,
isDev: false, })
})
expect(runtime).toBe('nodejs') expect(runtime).toBe('nodejs')
expect(getServerSideProps).toBe(false)
expect(getStaticProps).toBe(false)
}) })
it('should parse edge runtime correctly', async () => { it('should parse edge runtime correctly', async () => {
...@@ -62,18 +56,4 @@ describe('parse page static info', () => { ...@@ -62,18 +56,4 @@ describe('parse page static info', () => {
}) })
expect(runtime).toBe(undefined) expect(runtime).toBe(undefined)
}) })
it('should parse ssr info with variable exported gSSP correctly', async () => {
const { getServerSideProps, getStaticProps } = await getPagesPageStaticInfo(
{
page: 'ssr-variable-gssp',
pageFilePath: join(fixtureDir, 'page-runtime/ssr-variable-gssp.js'),
nextConfig: createNextConfig(),
pageType: PAGE_TYPES.PAGES,
isDev: false,
}
)
expect(getStaticProps).toBe(false)
expect(getServerSideProps).toBe(true)
})
}) })
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