[PR #52] [MERGED] fix: replace glob npm package with native node:fs/promises glob #273

Closed
opened 2026-05-06 12:38:54 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/52
Author: @torresgol10
Created: 2/25/2026
Status: Merged
Merged: 2/25/2026
Merged by: @southpolesteve

Base: mainHead: fix/native-glob-routing


📝 Commits (5)

  • e2850ba fix: replace glob npm package with native node:fs/promises glob
  • 66b17a2 fix: address review feedback on native glob migration
  • afd247c refactor: use glob pattern arrays instead of callbacks for exclude
  • 4b0515e Merge branch 'cloudflare:main' into fix/native-glob-routing
  • 3861a01 merge: resolve conflict keeping glob pattern exclude

📊 Changes

4 files changed (+20 additions, -169 deletions)

View changed files

📝 packages/vinext/package.json (+3 -1)
📝 packages/vinext/src/routing/app-router.ts (+5 -14)
📝 packages/vinext/src/routing/pages-router.ts (+12 -13)
📝 pnpm-lock.yaml (+0 -141)

📄 Description

Summary

Migrate pagesRouter, apiRouter, and appRouter from the third-party glob package to Node.js built-in glob from node:fs/promises (available since Node 22).

Changes

  • pages-router.ts: Use for await with native glob(). Replace ignore option with exclude callback for filtering api/ and _-prefixed files.
  • app-router.ts: Use for await with native glob(). Replace post-filtering of @-prefixed slot segments with exclude callback. Normalize pagePath/routePath output with .replaceAll("\\", "/") for cross-platform consistency.
  • package.json: Remove glob dependency (no longer needed).

Motivation

  • Removes a dependency: The glob npm package is no longer needed since Node.js 22+ provides native glob support.
  • Fixes Windows path handling: The third-party glob package returned paths with forward slashes on all platforms, which masked a bug where dynamic route segments (e.g., [slug]) were incorrectly parsed due to premature path separator normalization. The native glob returns OS-native separators, and normalization is now done only on the final output metadata.

Testing

All 50 routing tests pass (pnpm test -- tests/routing.test.ts).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/52 **Author:** [@torresgol10](https://github.com/torresgol10) **Created:** 2/25/2026 **Status:** ✅ Merged **Merged:** 2/25/2026 **Merged by:** [@southpolesteve](https://github.com/southpolesteve) **Base:** `main` ← **Head:** `fix/native-glob-routing` --- ### 📝 Commits (5) - [`e2850ba`](https://github.com/cloudflare/vinext/commit/e2850ba8d06019c90ee27143e5d6237d2b957347) fix: replace glob npm package with native node:fs/promises glob - [`66b17a2`](https://github.com/cloudflare/vinext/commit/66b17a2a65b8d89c25c308d9b4865b2396f5c462) fix: address review feedback on native glob migration - [`afd247c`](https://github.com/cloudflare/vinext/commit/afd247c196cfa5daee9b4e5a5b68fa9064ddaa77) refactor: use glob pattern arrays instead of callbacks for exclude - [`4b0515e`](https://github.com/cloudflare/vinext/commit/4b0515e2aa8a4584a0f332a51f31eec51b4c996a) Merge branch 'cloudflare:main' into fix/native-glob-routing - [`3861a01`](https://github.com/cloudflare/vinext/commit/3861a0120bbc08c00ce25c61205156e05bd0e9f1) merge: resolve conflict keeping glob pattern exclude ### 📊 Changes **4 files changed** (+20 additions, -169 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/package.json` (+3 -1) 📝 `packages/vinext/src/routing/app-router.ts` (+5 -14) 📝 `packages/vinext/src/routing/pages-router.ts` (+12 -13) 📝 `pnpm-lock.yaml` (+0 -141) </details> ### 📄 Description ## Summary Migrate `pagesRouter`, `apiRouter`, and `appRouter` from the third-party `glob` package to Node.js built-in `glob` from `node:fs/promises` (available since Node 22). ## Changes - **`pages-router.ts`**: Use `for await` with native `glob()`. Replace `ignore` option with `exclude` callback for filtering `api/` and `_`-prefixed files. - **`app-router.ts`**: Use `for await` with native `glob()`. Replace post-filtering of `@`-prefixed slot segments with `exclude` callback. Normalize `pagePath`/`routePath` output with `.replaceAll("\\", "/")` for cross-platform consistency. - **`package.json`**: Remove `glob` dependency (no longer needed). ## Motivation - **Removes a dependency**: The `glob` npm package is no longer needed since Node.js 22+ provides native glob support. - **Fixes Windows path handling**: The third-party `glob` package returned paths with forward slashes on all platforms, which masked a bug where dynamic route segments (e.g., `[slug]`) were incorrectly parsed due to premature path separator normalization. The native glob returns OS-native separators, and normalization is now done only on the final output metadata. ## Testing All 50 routing tests pass (`pnpm test -- tests/routing.test.ts`). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 12:38:54 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#273
No description provided.