Repository navigation
fix(resolution): workspace globs reach nested members, and a negated glob leaves members out - #2638
Merged
Merged
Conversation
…glob leaves members out
pnpm's `packages/**/*` (folo) and npm's `libs/**/*` (bitwarden) list
member packages at any depth, `packages/plugin-*` and `apps/*/web` name
them by part of a folder name or by a folder below the wildcard, and a
negated glob (`!**/example`, `!examples/with-nx`) leaves some out. The
workspace loader listed only the folders directly under the text before
the first `*` and took a negation for a folder name, so folo's
`@follow/utils`, two levels under `packages/`, was no member and every
import of it counted as an outside package's.
Globs now match folder by folder: `*`, `?` and `{a,b}` within a name,
`**` across folders, breadth-first so a member nearer the root keeps a
name a deeper copy also declares. A wildcard never enters a dot-folder,
`node_modules` or `bower_components`, and a `**` skips `test` and `tests`
folders as pnpm's default ignores do; a folder the glob names literally
is always entered. What a negated glob matches is no member.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
src/resolution/workspace-packages.ts→expandWorkspaceGlobread only the folders directly under the text before a glob's first*, and took a negated glob for a folder name. On main (53ad0d4):packages/**/*(folo) and npm'slibs/**/*(bitwarden) list members at any depth. folo's@follow/utilsispackages/internal/utils, two levels down, so it was no member.isExternalImport('@follow/utils/lru-cache', …)returned true, and 2,411@follow/*imports counted as outside packages'.packages/plugin-*listed a folder calledpackages/plugin-, andapps/*/webstopped atapps/*.!**/example, react-native's!private/helloworldand refine's!examples/with-nxleft those packages members.No issue reported this; it turned up while validating #2637. There, folo's
offsetCache.get/measurementsCache.getstayed unlinked after a sync: their class comes from@follow/utils/lru-cache, which counted as an outside import, so the failed calls were never parked under the module.Fix
Globs match folder by folder, like a small glob engine:
*,?and{a,b}within a name, and**across folders.node_modulesorbower_components. A**also skipstestandtestsfolders, as pnpm's default ignores do: their fixture packages aren't members, and their names (react,lodash) would make imports of the real package the project's.e2e/tests/*still works).tools/**includestoolsitself, as npm and pnpm matchtools/**/package.json.The first line of
expandWorkspaceGlobis unchanged. #2009 edits exactly that line, so whichever lands second resolves a one-line conflict.Overlap with open PRs: #2535 (workspace
exports/mainentries, #2502) and #2461 (file:dependencies, #2456) also edit this file, in the header comment and other functions. Whichever lands second gets a small conflict in the header's bullet list.With #2535, folo's
@follow/*imports would also resolve to theirsrc/files. This PR only makes them members: their files sit undersrc/behindexports, which directory-based subpath resolution doesn't reach.Validation
Fresh-index A/B vs main
Byte-identical nodes, edges and files in all 10 repos:
packages/**/*+!**/example@follow/utils,@follow/components, …)@follow/*bindings move to a module key (callsget39,set34, …; imports 19); nothing elselibs/**/*libs/tools/export-vault-core, …)!private/helloworldintegration-tests/**/*So the newly found members change no fresh edge here:
tsconfig.base.jsonpaths, which resolve before the workspace step.src/behindexports; see fix(resolution): a workspace package import resolves to its package.json entry (#2502) #2535.Sync vs a fresh index (folo)
Every 7th file is held out, emptied, or deleted and then restored. Each arm's synced graph is compared with its own fresh index; numbers are differing dump lines.
offsetCache.get,measurementsCache.getThose are the two folo residues #2637 left. Their class comes from
@follow/utils/lru-cache, which is now a project module, so the failed calls wait undermodule:lru-cache. Every other residue bucket is identical on both arms. The drop scenario's delete-step sync fails withFOREIGN KEY constraint failedon both arms; that is #2565, fixed in the open #2574.Tests
__tests__/workspace-nested-globs.test.tshas 7 tests; 5 fail on main 53ad0d4 (run in a detached worktree):packages/**/*;libs/**/*, withtools/**countingtoolsitself;packages/plugin-*and{apps,sites}/*/web;import { fmt as format } from '@acme/utils'links to the nested member'sfmt.The 2 that pass on main guard the new walk:
**walk'stest/fixtures/reactare no members, whilee2e/tests/*is;Mutations:
test/testsskip under**, the fixtures guard fails.Full suite (Windows) on this branch: 593 files passed (6 skipped), 7,262 tests passed, 0 failed (82 skipped).
The branch merges cleanly with #2639 (TS array-annotated receivers).
🤖 Generated with Claude Code