Fix: Use chokidar for consistent glob pattern matching in build mode #23
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.
Fixes #21
Problem
Build mode silently processes zero files when using extglob patterns like
(src|__tests__)insrcDir, while watch mode works correctly with the same pattern.Root Cause
The CLI used two different glob libraries with incompatible pattern support:
| Mode | Library |
(src|__tests__)interpretation ||------|---------|----------------------------------|
| Build |
globSyncfromglob| Literal string (finds nothing) || Watch |
chokidar(uses picomatch) | Extglob "OR" pattern (works) |This caused confusing behavior where
--watchwould find and process files, but running without--watchwould silently succeed with no output.Example
{ "srcDir": "./(src|__tests__)/**/*" }pgtyped-rescript -c config.json --watch→ finds files in bothsrc/and__tests__/pgtyped-rescript -c config.json→ finds 0 files, exits silentlySolution
Use chokidar for file matching in both modes. This ensures consistent glob pattern interpretation regardless of whether watch mode is enabled.
Changes
Replaced
globSyncwith chokidar-basedgetMatchedFilesinpackages/cli/src/index.tsgetMatchedFiles()function that uses chokidar withpersistent: falseglobpackage dependency for file matchingAdded comprehensive tests in
packages/cli/src/glob.rescript.test.ts(src|__tests__)syntax{src,__tests__}syntaxTest plan