Skip to content

test(glob-import): cover array patterns with sibling dirs sharing a prefix#22281

Merged
sapphi-red merged 1 commit into
mainfrom
04-21-test-glob-import-cover-array-patterns
Apr 23, 2026
Merged

test(glob-import): cover array patterns with sibling dirs sharing a prefix#22281
sapphi-red merged 1 commit into
mainfrom
04-21-test-glob-import-cover-array-patterns

Conversation

@shulaoda
Copy link
Copy Markdown
Member

Summary

  • Adds a playground test case covering import.meta.glob([...]) where the array entries target sibling directories whose names share a byte-level prefix but are distinct path segments (e.g. pattern1/ and pattern2/).
  • The fixture creates playground/glob-import/array-common-base/pattern{1,2}/*.js, wires up a new array-common-base-result block in index.html, and asserts the resolved modules in glob-import.spec.ts (runs in both serve and build modes).
  • Regression guard for vitejs/vite#22170, fixed upstream in rolldown/rolldown#9070.

Why

During vite build, array import.meta.glob patterns are handled by rolldown's native viteImportGlobPlugin. Its get_common_base used a byte-wise longest common prefix to decide where to start walkdir. For array entries like /array-common-base/pattern1/**/*.js and /array-common-base/pattern2/**/*.js, that produced /array-common-base/pattern — a path that cuts in the middle of a segment and points to no real directory. walkdir then found nothing and the bundled output was Object.assign({}). Dev (vite dev) took a different code path and worked fine, so the regression only surfaced in production builds.

rolldown/rolldown#9070 fixed get_common_base to always land on a path-segment boundary. This test pins that behavior on the Vite side so a future regression is caught by the playground e2e suite rather than by users.

@shulaoda shulaoda force-pushed the 04-21-test-glob-import-cover-array-patterns branch from 8ee73a1 to 6c1b939 Compare April 21, 2026 07:14
@shulaoda shulaoda requested a review from sapphi-red April 21, 2026 07:14
@shulaoda shulaoda marked this pull request as ready for review April 21, 2026 07:14
@sapphi-red sapphi-red added p1-chore Doesn't change code behavior (priority) test labels Apr 23, 2026
@sapphi-red sapphi-red merged commit adc9958 into main Apr 23, 2026
20 checks passed
@sapphi-red sapphi-red deleted the 04-21-test-glob-import-cover-array-patterns branch April 23, 2026 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p1-chore Doesn't change code behavior (priority) test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants