Repository navigation
Support Node.js 22.12 and newer and match globs with picomatch - #24
Merged
Merged
Conversation
Lower engines.node from >=26 to >=22.12 and type the Node.js APIs of the oldest supported version with @types/node 22.12.0. Development and the full check keep the version in .node-version. CI tests the latest Node.js 22, 24 and 26, and runs the tests and the packed CLI and library on Node.js 22.12.0. The CLI hides the one warning that path.matchesGlob prints on Node.js before 22.20 and 24.8, where it is still experimental.
path.matchesGlob is experimental before Node.js 22.20 and 24.8 and prints a warning there, from the library as well as the CLI. Match glob options and npm workspace patterns with picomatch 4.0.7 instead, and remove the CLI's warning filter. Glob options keep their syntax: case-sensitive matching, dot files skipped unless named, a backslash as a separator, literal parentheses and pipes outside extglobs, and a leading ! as part of the name. Workspace patterns now follow npm's own selection: exclusions apply regardless of order unless a later pattern that they match cancels them, and they also exclude dot folders. The oldest-node CI job now also checks that the packed library prints nothing on stderr when it uses glob options.
# Conflicts: # package-lock.json # package.json
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 changed
The package now supports Node.js 22.12 and newer instead of 26 and newer, and matches globs with picomatch instead of Node's
path.matchesGlob, so neither the CLI nor the library prints anExperimentalWarningon Node.js versions before 22.20 and 24.8.Node.js 22.12
engines.nodeis>=22.12, and@types/nodeis 22.12.0 (exact, like the other pins) so that type checking catches Node.js APIs newer than the oldest supported version..node-version(26.13.1) stays the development version, used by the fullnpm run checkjob and the release workflow.testjob for the latest Node.js 22, 24 and 26 (typecheck, build, tests) and anoldest-nodejob that builds and packs with the development version, then runs the test suite and the packed CLI and library on Node.js 22.12.0, failing if either writes anything to stderr. The library step now passes glob options, so it would catch the warning. ESLint 10 needs Node.js 22.13+, so lint stays in the development-version job. Thecijob now needs the new jobs; the ruleset's required check is unchanged.picomatch instead of
path.matchesGlobpicomatch4.0.7 is a new runtime dependency (MIT, no dependencies of its own), pinned exactly, with@types/picomatch4.0.3 as a dev dependency. Both are listed inTHIRD_PARTY.md. The CLI's filter for the experimental-glob warning is removed.--exclude,--test,--tooling,--production,--entry-globand the library'sexclude,scopesandentryGlobs) go through one matcher,src/globs.ts, that keeps their syntax:*and**skip dot files and folders unless the pattern names them, braces, extglobs and character classes work, a backslash separates segments like a slash,./..segments and repeated slashes are normalized, a leading!is part of the name, and parentheses,|and"are literal outside extglobs (picomatch would otherwise readapp/(marketing)/**as a regex group and miss Next.js route groups).--workspace-entries,workspaceEntries()) now select member folders the way npm does in@npmcli/map-workspaces: an odd number of leading!makes an exclusion, a later including pattern cancels earlier exclusions that match its text, other exclusions apply wherever they are listed, including patterns skip dot folders unless they name them, and exclusions also cover dot folders (npm'sglobignore list matches withdot: true). The previous last-match-wins reading differed from npm for patterns such as['!packages/b', 'packages/*']or['packages/**', '!packages/b/**'].minorchangeset,.changeset/picomatch-globs.md, lists the differences users can see: npm's workspace selection; case-sensitive matching on every platform (on macOS and Windows,path.matchesGlobignored case in segments with wildcards); a leading./now accepted by--excludeand the scope options; a pattern also matching a path spelled exactly like it anddir/**matchingdir; and picomatch's reading of!(…)extglobs. The Node.js changeset now only states the new minimum..changeset/config.jsonandCONTRIBUTING.mdarrive with #23; merge that first so these changesets are picked up. #23'sCONTRIBUTING.mdandAGENTS.mdsay that the TypeScript compiler is the only runtime dependency; after #23 is merged, this branch needs those lines updated to mention picomatch.Verification:
test/globs.test.tsandtest/entry-discovery.test.tscover dot files and folders,**, braces, extglobs, character classes, literal parentheses, backslashes, a leading!, empty patterns, scopes, entry globs, npm workspace exclusions, and an empty stderr from the library and the CLI. Against the previous implementation, they pass except for the intended changes: the workspace exclusions, the leading./and, on macOS, case sensitivity. On Node.js 22.12.0 the stderr test also fails there, on theExperimentalWarning.@npmcli/map-workspaces6.0.0 on 34 pattern lists. All match, except that npm on macOS ignores case.npm ci --ignore-scripts --no-audit,npm run check(58 tests),npm pack --dry-runandnpm audit(0 vulnerabilities) pass.oldest-nodesteps, run by hand on Node.js 22.12.0 against the packed tarball, report a complete scan with one direct call, and neither the CLI nor the library writes to stderr.Checklist
npm run checkpasses, and tests cover the change.docs/.npx changeset), or the change does not affect them.