Skip to content

Refine filesystem output types#94514

Draft
timneutkens wants to merge 1 commit into
codex/remove-route-matcher-stackfrom
codex/refine-fs-output-types
Draft

Refine filesystem output types#94514
timneutkens wants to merge 1 commit into
codex/remove-route-matcher-stackfrom
codex/refine-fs-output-types

Conversation

@timneutkens
Copy link
Copy Markdown
Contributor

@timneutkens timneutkens commented Jun 6, 2026

What?

Convert FsOutput into a string-discriminated union so each filesystem output exposes only the fields valid for its type.

This PR is stacked on #94157.

Why?

The previous optional-field shape allowed invalid combinations and required downstream optional checks even when a route or filesystem path must exist. Narrower variants make those invariants explicit and expose invalid construction paths during type checking.

How?

  • Define distinct page, app, static-file, image, and development virtual output variants.
  • Require route metadata for page and app outputs and filesystem serving fields for static outputs.
  • Use a separate page/app ensure input carrying the request path.
  • Narrow outputs by type in route resolution and router dispatch before accessing specialized fields.
  • Forward image requests explicitly and assert that development virtual items are consumed by the development bundler.

Verification

  • pnpm --filter=next types
  • pnpm --filter=next build
  • NEXT_TEST_PREFER_OFFLINE=1 pnpm test-dev-turbo test/e2e/dynamic-routing/dynamic-routing.test.ts test/e2e/middleware-general/test/index.test.ts -t "should resolve dynamic route href for page added later|should only contain middleware route in dev middleware manifest"
  • NEXT_TEST_PREFER_OFFLINE=1 pnpm test-dev-webpack test/e2e/dynamic-routing/dynamic-routing.test.ts test/e2e/middleware-general/test/index.test.ts -t "should resolve dynamic route href for page added later|should only contain middleware route in dev middleware manifest"
  • Manually verified App Router, Pages Router, public files, _next/static, image optimization, static metadata, development virtual manifests, and 404 handling under Turbopack and webpack.
  • npx eslint --config eslint.config.mjs packages/next/src/server/lib/router-server.ts packages/next/src/server/lib/router-utils/filesystem.ts packages/next/src/server/lib/router-utils/resolve-routes.ts packages/next/src/server/lib/router-utils/setup-dev-bundler.ts
  • git diff --check

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

Failing CI jobs

Commit: b5c6320 | About building and testing Next.js

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

Stats cancelled

Commit: b5c6320
View workflow run

@timneutkens timneutkens changed the title codex/refine fs output types Refine filesystem output types Jun 6, 2026
@timneutkens timneutkens force-pushed the codex/remove-route-matcher-stack branch from 8a7391d to 6797e1e Compare June 8, 2026 08:42
@timneutkens timneutkens force-pushed the codex/refine-fs-output-types branch from 2d68f4c to b5c6320 Compare June 8, 2026 08:42
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.

1 participant