fix(typegen): normalize %5F to _ before private folder check in dev bundler#93725
Open
sleitor wants to merge 1 commit intovercel:canaryfrom
Open
fix(typegen): normalize %5F to _ before private folder check in dev bundler#93725sleitor wants to merge 1 commit intovercel:canaryfrom
sleitor wants to merge 1 commit intovercel:canaryfrom
Conversation
…der check
Turbopack URL-encodes '_' as '%5F' in directory names when reporting
file paths to the dev bundler. The existing check:
if (normalizedPageName.includes('/_')) continue
was correctly excluding private folders (directories starting with '_')
in webpack dev mode (where file paths use literal underscores), but
failed in Turbopack mode because '/%5Ffoo'.includes('/_') is false.
This caused two bugs when using Turbopack dev mode:
1. Private folder layouts (e.g. app/_foo/layout.tsx) leaked into the
dev typegen LayoutRoutes as '/%5Ffoo' instead of being excluded.
2. The encoded route '/%5Ffoo' was incompatible with production types
(which exclude '_'-prefixed directories via ignorePartFilter), causing
TypeScript errors like:
Type '"/%5Ffoo"' is not assignable to type 'LayoutRoutes'
Fix: normalize '%5F' to '_' in normalizedPageName before the private
folder check, matching the production build's ignorePartFilter behavior.
Fixes vercel#93700
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When Turbopack is used in dev mode, it URL-encodes
_as%5Fin directory names when reporting file paths to the dev bundler. The private folder exclusion check:works correctly in webpack dev mode (literal
_in paths), but fails in Turbopack mode because'/%5Ffoo'.includes('/_')isfalse.Root Cause
In
setup-dev-bundler.ts, when collecting app routes and layouts for the typegen manifest, Turbopack-encoded paths like/%5Ffoo/layoutbypass the private folder filter. This causes:_-prefixed directories leak into dev types — e.g.app/_foo/layout.tsxappears in dev.next/dev/types/routes.d.tsas"/%5Ffoo"inLayoutRoutesignorePartFilter: (part) => part.startsWith('_')incollectAppFiles, so.next/types/routes.d.tsdoes NOT have"/%5Ffoo"or"/_foo". The dev validator imports both files and fails with:Fix
Normalize
%5F→_innormalizedPageNamebefore the private folder check, matching the production build's behavior.The same
%5F→_normalization pattern is already used at line 682 for app route/page collection in the same function, and inroute-discovery.tsfor the production build.Testing
includes('/_')private folder filternormalizedPageNameused for the private folder check and the layout route string — the internal bundler identifiers (inappPaths) are unaffected, as they're normalized separately at line 682Fixes #93700