Skip to content

Commit ff6828c

Browse files
committed
fix: file-router matcher with dot parent
1 parent 57d6658 commit ff6828c

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

  • packages/react-server/lib/plugins/file-router

packages/react-server/lib/plugins/file-router/plugin.mjs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,26 @@ function mergeOrApply(a, b = {}) {
8585
}
8686

8787
function match(files, includes, excludes) {
88-
return micromatch(files, [
89-
...(includes ?? ["**/*"]),
90-
...(excludes ?? []).map((pattern) => `!${pattern}`),
91-
]);
88+
return micromatch(
89+
files,
90+
[
91+
...(includes ?? ["**/*"]),
92+
...(excludes ?? []).map((pattern) => `!${pattern}`),
93+
],
94+
// dot:true so absolute paths whose ancestors include dot-prefixed
95+
// segments still classify correctly. This helper feeds isPage /
96+
// isLayout / isMiddleware / isApi / isResource via isTypeOf, which
97+
// run on the absolute `src` produced by the chokidar add handler
98+
// (`join(cwd, root, rawSrc)`). When a CLI ships its own pages and
99+
// is launched via `npx` — where the package lives under
100+
// `~/.npm/_npx/<hash>/...` — every classification would silently
101+
// return false (manifest reports `0 pages`) because micromatch
102+
// defaults to `dot:false` and rejects any path whose *ancestors*
103+
// contain a dot-prefixed segment, not just the basename. Same
104+
// trap as the fast-glob `dot:true` we already pass below for the
105+
// initial-files scan; both layers must opt in.
106+
{ dot: true }
107+
);
92108
}
93109

94110
function source(files, rootDir, root) {

0 commit comments

Comments
 (0)