[PR #570] [MERGED] refactor: migrate ssrLoadModule to moduleRunner.import #678

Closed
opened 2026-05-06 13:09:29 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/570
Author: @james-elicx
Created: 3/16/2026
Status: Merged
Merged: 3/17/2026
Merged by: @james-elicx

Base: mainHead: opencode/gentle-squid


📝 Commits (2)

  • 315dabd refactor: migrate ssrLoadModule to moduleRunner.import
  • 0ad4a4f refactor: address bonk review comments

📊 Changes

7 files changed (+125 additions, -97 deletions)

View changed files

📝 packages/vinext/src/index.ts (+8 -1)
📝 packages/vinext/src/server/api-handler.ts (+6 -6)
📝 packages/vinext/src/server/dev-server.ts (+36 -30)
📝 packages/vinext/src/server/instrumentation.ts (+15 -0)
📝 packages/vinext/src/shims/ALS-ARCHITECTURE.md (+4 -4)
📝 tests/api-handler.test.ts (+13 -15)
📝 tests/pages-router.test.ts (+43 -41)

📄 Description

Summary

  • Replaces all server.ssrLoadModule() calls in dev-server.ts and api-handler.ts with runner.import() via the ModuleImporter interface, following the Vite Module Runner migration guide
  • Removes ssrFixStacktrace / ssrRewriteStacktrace calls — these are not needed when using Module Runner APIs
  • Updates call sites in index.ts to pass the existing getPagesRunner() lazy factory as the new runner argument

Files changed

File Change
packages/vinext/src/server/dev-server.ts All 18 ssrLoadModule calls → runner.import(), ssrFixStacktrace removed, runner: ModuleImporter added to createSSRHandler and renderErrorPage signatures
packages/vinext/src/server/api-handler.ts server: ViteDevServerrunner: ModuleImporter, ssrLoadModulerunner.import(), ssrFixStacktrace removed
packages/vinext/src/index.ts Updated two call sites to pass getPagesRunner() as the runner
tests/api-handler.test.ts MockServer type + mockServer() helper replaced with ModuleImporter-shaped mock; removed stale ssrFixStacktrace assertion
tests/pages-router.test.ts createSSRHandler call updated to pass a runner derived from the existing mock logic

Testing

  • All 40 api-handler unit tests pass
  • pnpm run check is clean (2 pre-existing benchmark errors unrelated to this change)

🔄 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/570 **Author:** [@james-elicx](https://github.com/james-elicx) **Created:** 3/16/2026 **Status:** ✅ Merged **Merged:** 3/17/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `opencode/gentle-squid` --- ### 📝 Commits (2) - [`315dabd`](https://github.com/cloudflare/vinext/commit/315dabde905492a0ad4c182a81085669ee236d6f) refactor: migrate ssrLoadModule to moduleRunner.import - [`0ad4a4f`](https://github.com/cloudflare/vinext/commit/0ad4a4fe5f51691e5024c1256c154d88f62e89dc) refactor: address bonk review comments ### 📊 Changes **7 files changed** (+125 additions, -97 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/index.ts` (+8 -1) 📝 `packages/vinext/src/server/api-handler.ts` (+6 -6) 📝 `packages/vinext/src/server/dev-server.ts` (+36 -30) 📝 `packages/vinext/src/server/instrumentation.ts` (+15 -0) 📝 `packages/vinext/src/shims/ALS-ARCHITECTURE.md` (+4 -4) 📝 `tests/api-handler.test.ts` (+13 -15) 📝 `tests/pages-router.test.ts` (+43 -41) </details> ### 📄 Description ## Summary - Replaces all `server.ssrLoadModule()` calls in `dev-server.ts` and `api-handler.ts` with `runner.import()` via the `ModuleImporter` interface, following the [Vite Module Runner migration guide](https://vite.dev/changes/ssr-using-modulerunner) - Removes `ssrFixStacktrace` / `ssrRewriteStacktrace` calls — these are not needed when using Module Runner APIs - Updates call sites in `index.ts` to pass the existing `getPagesRunner()` lazy factory as the new `runner` argument ## Files changed | File | Change | |------|--------| | `packages/vinext/src/server/dev-server.ts` | All 18 `ssrLoadModule` calls → `runner.import()`, `ssrFixStacktrace` removed, `runner: ModuleImporter` added to `createSSRHandler` and `renderErrorPage` signatures | | `packages/vinext/src/server/api-handler.ts` | `server: ViteDevServer` → `runner: ModuleImporter`, `ssrLoadModule` → `runner.import()`, `ssrFixStacktrace` removed | | `packages/vinext/src/index.ts` | Updated two call sites to pass `getPagesRunner()` as the runner | | `tests/api-handler.test.ts` | `MockServer` type + `mockServer()` helper replaced with `ModuleImporter`-shaped mock; removed stale `ssrFixStacktrace` assertion | | `tests/pages-router.test.ts` | `createSSRHandler` call updated to pass a `runner` derived from the existing mock logic | ## Testing - All 40 `api-handler` unit tests pass - `pnpm run check` is clean (2 pre-existing benchmark errors unrelated to this change) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:09:29 +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#678
No description provided.