Skip to content

ci(scripts): teach verify-exports to expand subpath wildcard patterns - #4042

Merged
nynexman4464 merged 1 commit into
mainfrom
nynexman4464/fix/verify-exports-wildcard
Jul 17, 2026
Merged

nynexman4464 merged 1 commit into
mainfrom
nynexman4464/fix/verify-exports-wildcard

Conversation

@nynexman4464

Copy link
Copy Markdown
Contributor

What

scripts/verify-exports.mjs calls existsSync on the literal string of each exports value. When that value is a subpath wildcard like "./locales/*.json": "./locales/*.json" (standard Node exports syntax for shipping a directory of assets), the literal *.json file obviously doesn't exist and the check fails.

Extend the checker to handle single-* subpath wildcards:

  • Detect a wildcard export (one * in both key and value).
  • List the value's target directory, count files whose name matches prefix + <capture> + suffix.
  • Require at least one match; require every match to resolve inside pkgDir (paths that escape via .. are rejected).

Multi-star patterns fall through to the literal existsSync check, 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

  • No shell, no execSync, no regex from user input. Just readdirSync + string startsWith/endsWith.
  • Only single-* patterns are honored (spec-compliant).
  • Empty captures rejected (filename must be longer than prefix + suffix combined).
  • Every match's absolute path is checked against pkgDir via path.relative(...).startsWith('..') — an exports value 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:

  • Valid wildcard with matching files → passes
  • Missing directory → fails
  • Directory exists but no matching files → fails
  • Multi-star pattern → fails (spec-compliant)
  • Value escapes via ../../outside → rejected by containment check
  • Filename-prefix wildcards (messages-*.json) → passes

@nynexman4464

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).
@vercel

vercel Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview, Comment Jul 17, 2026 5:11pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 17, 2026
github-actions Bot added a commit that referenced this pull request Jul 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.6KB 0B

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

This branch was successfully deployed

1 active deployment
Preview — 07804026 Deployed Jul 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant