Repository navigation
ci(scripts): teach verify-exports to expand subpath wildcard patterns - #4042
Merged
Merged
Conversation
Node's exports field supports subpath wildcards (one `*` in both key and value), which packages use to publish a directory of assets (e.g. locale JSON, per-icon SVGs). The previous check called existsSync on the literal string containing the `*`, which always failed. Extend the checker to expand the pattern: list the value's directory, require at least one file to match prefix+suffix. Matches that resolve outside pkgDir via `..` are rejected — package.json cannot reach beyond its own root. Only single-`*` patterns are honored, matching Node's spec. Two or more stars fall through to the literal existsSync check (which fails, same as Node's real resolver rejecting them).
nynexman4464
requested review from
cixzhang,
ejhammond and
imdreamrunner
as code owners
July 17, 2026 17:08
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
This was referenced Jul 21, 2026
This branch was successfully deployed
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
scripts/verify-exports.mjscallsexistsSyncon the literal string of eachexportsvalue. When that value is a subpath wildcard like"./locales/*.json": "./locales/*.json"(standard Nodeexportssyntax for shipping a directory of assets), the literal*.jsonfile obviously doesn't exist and the check fails.Extend the checker to handle single-
*subpath wildcards:*in both key and value).prefix + <capture> + suffix.pkgDir(paths that escape via..are rejected).Multi-star patterns fall through to the literal
existsSynccheck, which fails — matching Node's own resolver, which rejects them too.Why now
The i18n stack (#3765 and up) is the first internal use of a subpath wildcard, for
./locales/*.json. Landing this fix separately keeps that stack focused on i18n and lets the tooling change get its own review.Prior art
Same pattern used by comparable component libraries:
@adobe/react-spectrum—"./i18n/*"@mantine/core—"./styles/*"@shopify/polaris-icons—"./dist/svg/*.svg"None of them enumerate per-file. The Node spec supports this directly.
Safety
execSync, no regex from user input. JustreaddirSync+ stringstartsWith/endsWith.*patterns are honored (spec-compliant).pkgDirviapath.relative(...).startsWith('..')— anexportsvalue like"./foo/*": "../../*"cannot silently escape the package root.Testing
Run
pnpm check— the existing suite passes (this branch has no i18n changes; wildcard behavior is exercised once the i18n stack lands on top).Manually verified against a synthetic test fixture covering:
../../outside→ rejected by containment checkmessages-*.json) → passes@nynexman4464