Skip to content

test(shims): expect forward-slash shim ids in the next/error and subpath resolution fixtures#2265

Merged
james-elicx merged 1 commit into
cloudflare:mainfrom
shulaoda:06-23-test_shims_expect_forward-slash_shim_ids_in_the_next_error_and_subpath_resolution_fixtures
Jun 22, 2026
Merged

test(shims): expect forward-slash shim ids in the next/error and subpath resolution fixtures#2265
james-elicx merged 1 commit into
cloudflare:mainfrom
shulaoda:06-23-test_shims_expect_forward-slash_shim_ids_in_the_next_error_and_subpath_resolution_fixtures

Conversation

@shulaoda

Copy link
Copy Markdown
Contributor

What

Wrap the expected shim paths in the "resolves next/error to the react-server shim" and "strips JavaScript extensions and Vite queries from package subpaths" tests with normalizePathSeparators, so they compare against the forward-slash ids that vinext:config's resolveId returns on Windows.

Why

vinext:config's resolveId hook returns Vite-style module ids — forward slashes on every platform — because it resolves shims through _shimsDir, which is normalized at module load (and the font plugins' id.startsWith(_shimsDir) guards plus the module-graph canonicalize require that forward-slash form). The two fixtures built their expected values with raw path.resolve(import.meta.dirname, …), which yields backslashes on Windows, so the assertions failed there with Received: "E:/…/error.react-server.ts" vs Expected: "E:\…\error.react-server.ts". The source is correct; the fixtures were the only two resolveId tests in this file that did not normalize — the sibling app-rsc-handler and @vercel/og tests already wrap their expected values in normalizePathSeparators for exactly this reason. This is a fixture-only mismatch, not a production bug.

How

  • next/error test: clientShim and reactServerShim now wrap their path.resolve(...) in normalizePathSeparators(...).
  • subpath resolution test: expectedShim, expectedReactServerShim, and expectedOgShim now wrap their path.resolve(...) in normalizePathSeparators(...).
  • Added the same // resolveId returns Vite-style ids: forward slashes on every platform. comment the sibling tests carry, so the intent is documented once per block.
  • normalizePathSeparators was already imported in this file and is a no-op on POSIX, so the expected values are byte-identical there.

Testing

  • vp test run --project unit tests/shims.test.ts -t "resolves next/error to the react-server shim only in the RSC environment" — passes.
  • vp test run --project unit tests/shims.test.ts -t "strips JavaScript extensions and Vite queries from package subpaths" — passes.
  • vp test run --project unit tests/shims.test.ts — failures drop from 14 to 12; the remaining 12 are the separate navigation/locale cluster, unaffected by this change.
  • vp check tests/shims.test.ts — format, lint, and typecheck clean.

Classified test because only fixtures change: the source already returns the forward-slash id, and the production code path is untouched.

@pkg-pr-new

pkg-pr-new Bot commented Jun 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@vinext/cloudflare@2265
npm i https://pkg.pr.new/vinext@2265

commit: 08870e9

@github-actions

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared 08870e9 against base 826ae4c using alternating same-runner rounds. Next.js was unchanged and skipped.

1 improved · 0 regressed · 5 within ±1.5%

Scenario Framework Baseline Current Change
Client bundle size (gzip) vinext 117.1 KB 117.1 KB ⚫ +0.0%
Client entry size (gzip) vinext 112.5 KB 112.5 KB ⚫ +0.0%
Dev server cold start vinext 2.53 s 2.53 s ⚫ -0.3%
Production build time vinext 2.92 s 2.83 s 🟢 -3.2%
RSC entry closure size (gzip) vinext 91.2 KB 91.2 KB ⚫ +0.0%
Server bundle size (gzip) vinext 154.9 KB 154.9 KB ⚫ 0.0%

View detailed results and traces

🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head

@james-elicx james-elicx merged commit 14549e3 into cloudflare:main Jun 22, 2026
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants