fix: escape () and [] in scan directory globs - #627
Conversation
|
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4063450d96
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ? dirs.flatMap(dir => normalizeScanDirs([dir], { | ||
| ...dirsScanOptions, | ||
| cwd: root, | ||
| })).map(dir => ({ ...dir, glob: escapeGlobPathChars(dir.glob) })) |
There was a problem hiding this comment.
Preserve user-supplied glob syntax when escaping paths
When dirs or dirsScanOptions.filePatterns intentionally contains parentheses or a character class (for example, dirs: ['src/[ab]'] or filePatterns: ['*.[jt]s']), this post-normalization replacement escapes that syntax along with the literal project-root portion. Both directory scanning and the precompiled HMR matchers then look for literal brackets/parentheses instead of the requested glob matches, so previously supported configurations stop discovering exports. Escape only the literal resolved path prefix while preserving the user-supplied glob expression.
Useful? React with 👍 / 👎.
4063450 to
2a0b3d6
Compare
Project paths like Code(Template) were treated as picomatch extglob groups, so dir scanning and HMR watchers matched nothing.
2a0b3d6 to
1982e87
Compare
Summary
()or[](e.g.Code(Template)) are treated as picomatch / tinyglobby syntax, sodirsscanning and Vite HMR watchers match nothing.normalizeScanDirsand scan the escaped globs directly.#419was closed without merge because the change needed to live next to glob resolution with an explanation;resolveGlobsExcludehas since moved intounimport, and feeding escaped paths back through it turns\into/.Fixes #416
Test plan
vitest run(44 tests)Code(Template)andCode[Template]scanuseSpecial; HMR matchers accept files underCode(Template)Made with Cursor