Conversation
…ration CLI - Fix isColocatedFile() misclassifying route entry files as colocated - Fix route ID generation for route.tsx folder routes - Fix snapshot normalization for route segment - Add rewriteTypesRouteSpecifier() for +types/route imports - Add stripTsExtension() for index.ts extension imports - Add route source path exclusion in collectColocatedMappings Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- isColocatedFile: route entries inside + folders are not colocated - import-rewriter: +types/route specifier rewriting, /index.ts stripping - normalizers: route segment collapsed to parent in snapshot comparison - CLI: folder route migration, +types/route rewriting, snapshot equivalence Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ab2ea15557
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (segment.endsWith('+')) return true | ||
| if (segment.startsWith('(') && segment.endsWith(')')) return true | ||
| if (segment.startsWith('__')) return true | ||
| if (segment.startsWith('_')) return true |
There was a problem hiding this comment.
Treat pathless folder helpers as colocated files
Marking every leading-underscore directory as a route segment causes direct helper files under pathless folder routes (for example demo+/_settings/schema.ts) to be classified as route modules instead of colocated files. In this commit, isColocatedFile() now returns false for that pattern, so scanRouteModules() will include those .ts/.tsx files as routes and the migration will emit extra route entries rather than moving them into +-prefixed colocated paths.
Useful? React with 👍 / 👎.
| if (segment === 'route' && result.length > 0) { | ||
| continue |
There was a problem hiding this comment.
Keep literal "route" segments during snapshot normalization
The new segment === 'route' skip removes any non-root route path segment, not just folder-entry markers, so valid routes containing a literal route segment are collapsed in normalized snapshots. Because normalizeSnapshotRouteFilePath() feeds the CLI snapshot diff (src/migration/cli/diff.ts), this can incorrectly report before/after route trees as equivalent and hide real migration mismatches.
Useful? React with 👍 / 👎.
Summary
Fixes #14
The migration CLI (
npx migrate-auto-routes) fails when the source project uses the remix-flat-routes folder route pattern (route.tsxinside sub-folders of+-suffixed directories). Route files are misclassified as colocated files and placed under+-prefixed folders, making them invisible to the router.This PR fixes 5 interrelated bugs:
isColocatedFile()misclassifies folder route entries (e.g.demo+/about/route.tsx) as colocatedscanRouteModules()generates incorrect route IDs with extra/routesegmentnormalizeSnapshotRouteFilePath()doesn't normalizeroutesegments in snapshot comparison+types/routeimport specifiers are not rewritten whenroute.tsxbecomes a flat file/index.tsextension in imports is not stripped after migrationChanges
src/migration/fs-helpers.ts— FixisColocatedFile()to recognize folder route entriessrc/migration/route-scanner.ts— Fix route ID generation forroute.tsxfilessrc/migration/normalizers.ts— Addroutesegment skip in snapshot normalizationsrc/migration/import-rewriter.ts— AddrewriteTypesRouteSpecifier()andstripTsExtension()src/migration/migrate.ts— Add route source path exclusion filter incollectColocatedMappingsTest plan
isColocatedFilewith folder route patterns+types/routespecifier rewriting/index.tsextension strippingroutesegment snapshot normalization🤖 Generated with Claude Code