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

[functions-config-manifest] use correct extra config for pages router #54786

Merged
merged 9 commits into from
Sep 5, 2023
11 changes: 6 additions & 5 deletions packages/next/src/build/analysis/get-page-static-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type { RSCMeta } from '../webpack/loaders/get-module-build-info'

// TODO: migrate preferredRegion here
// Don't forget to update the next-types-plugin file as well
const AUTHORIZED_EXTRA_PROPS = ['maxDuration']
const AUTHORIZED_EXTRA_APP_ROUTER_PROPS = ['maxDuration']

export interface MiddlewareConfig {
matchers?: MiddlewareMatcher[]
Expand Down Expand Up @@ -510,12 +510,11 @@ export async function getPageStaticInfo(params: {
}

let extraConfig: Record<string, any> | undefined
extraConfig = {}
ecklf marked this conversation as resolved.
Show resolved Hide resolved

if (extraProperties) {
extraConfig = {}

if (extraProperties && pageType === 'app') {
for (const prop of extraProperties) {
if (!AUTHORIZED_EXTRA_PROPS.includes(prop)) continue
if (!AUTHORIZED_EXTRA_APP_ROUTER_PROPS.includes(prop)) continue
try {
extraConfig[prop] = extractExportedConstValue(swcAST, prop)
} catch (e) {
Expand All @@ -524,6 +523,8 @@ export async function getPageStaticInfo(params: {
}
}
}
} else if (pageType === 'pages') {
extraConfig = { ...config }
ecklf marked this conversation as resolved.
Show resolved Hide resolved
}

if (pageType === 'app') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ export default function Page({ data }) {
;<p>hello {data}</p>
}

export const maxDuration = 3
export const config = {
maxDuration: 3,
}

export async function getServerSideProps() {
return { props: { data: 'world' } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ export default function Page() {
;<p>hello world</p>
}

export const maxDuration = 2
export const config = {
maxDuration: 2,
}