Skip to content

[next] skip building pages router entries when not present#13704

Merged
huozhi merged 7 commits intomainfrom
skip-unrelated-pages-router-build
Aug 18, 2025
Merged

[next] skip building pages router entries when not present#13704
huozhi merged 7 commits intomainfrom
skip-unrelated-pages-router-build

Conversation

@huozhi
Copy link
Member

@huozhi huozhi commented Aug 11, 2025

This PR is a dependency of the Next.js PR (vercel/next.js#82444). Since we're not output Pages Router entries when only only App Router presents in that PR, we need to skip the Pages internal entries /_app, /_document and /_error building in next builder.

Currently next builder always emit the internal entries. For backword compatiability, we need to always try to emit the entries for the new Next.js with that change, and for previous versions we still emit Pages Router internal entries.
When we stop emitting the internal entries, lambdas[page] will be undefined, then reading lambdas[page].fsPath and the rest gona be broken on those internal entries. So we add optional check for accessing state of each page.

So we filterout the non-existed internalPages by lambdaPages which is the actual output from next.js, hence the rest logic will be safe. It's creating lambdas based on what nextjs actually emitted.

Verification with Next.js

Manually tested with the 2 deployment failing from nextjs side, it works well.

Using a custom build with this change and test on Next.js with test-deploy jobs:
https://github.com/vercel/next.js/actions/runs/16992428463/job/48176499037?pr=82444

@changeset-bot
Copy link

changeset-bot bot commented Aug 11, 2025

🦋 Changeset detected

Latest commit: b857d29

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@vercel/next Patch
vercel Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@huozhi huozhi changed the title skip building entries when the the file doesnt exist wip: skip building pages router entries when not present Aug 11, 2025
@huozhi huozhi changed the title wip: skip building pages router entries when not present [next] skip building pages router entries when not present Aug 11, 2025
@huozhi huozhi force-pushed the skip-unrelated-pages-router-build branch from 61fda46 to 5cf044b Compare August 11, 2025 14:02
@huozhi huozhi force-pushed the skip-unrelated-pages-router-build branch from df15816 to a1edc82 Compare August 11, 2025 21:23
@huozhi huozhi changed the base branch from main to huozhi/t-flaky-tests August 11, 2025 21:23
@huozhi huozhi marked this pull request as ready for review August 11, 2025 21:31
@huozhi huozhi requested review from a team, ijjk, timneutkens and ztanner as code owners August 11, 2025 21:31
@huozhi huozhi requested a review from onsclom August 11, 2025 21:31
Base automatically changed from huozhi/t-flaky-tests to main August 11, 2025 21:34
@huozhi huozhi force-pushed the skip-unrelated-pages-router-build branch from a1edc82 to 1592238 Compare August 11, 2025 21:35
@huozhi huozhi enabled auto-merge (squash) August 18, 2025 14:15
@huozhi huozhi merged commit fcf7791 into main Aug 18, 2025
178 checks passed
@huozhi huozhi deleted the skip-unrelated-pages-router-build branch August 18, 2025 14:16
ijjk pushed a commit that referenced this pull request Aug 18, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## vercel@46.0.2

### Patch Changes

- feat(cli): add SSO re-authorization support to --future
([#13771](#13771))

- Return the correct exit code in the Vercel command
([#13780](#13780))

- Updated dependencies
\[[`fcf7791f1dae2967c09c09b78aedf00be5d25303`](fcf7791),
[`b9e399c69ebeb71d9150e8aa994294b0c2be8c9f`](b9e399c)]:
    -   @vercel/next@4.11.3

## @vercel/next@4.11.3

### Patch Changes

- Handle building for app router without internal pages entries
([#13704](#13704))

- Add action metadata routes
([#13775](#13775))

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants