test(e2e): add loadBundle CJS runner coverage#7486
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new focused server e2e case to validate environments.node.loadBundle() behavior intended for CommonJS bundles, including dynamic import() execution and bundle caching.
Changes:
- Introduce a new
load-bundle-cjsserver e2e case with a/checkroute that loads and executes a node bundle vialoadBundle(). - Add a CJS server entry that uses dynamic
import('node:path')and checks runtime globals (queueMicrotask). - Add an e2e test asserting the
/checkresponse and that the loaded bundle is cached (top-level log occurs once).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| e2e/cases/server/load-bundle-cjs/src/index.server.cjs | New CJS server entry used as the node environment bundle for loadBundle() execution. |
| e2e/cases/server/load-bundle-cjs/src/index.js | Minimal web entry for the case. |
| e2e/cases/server/load-bundle-cjs/rsbuild.config.ts | Adds dev-only middleware that calls server.environments.node.loadBundle('index') and returns payload from the loaded bundle. |
| e2e/cases/server/load-bundle-cjs/index.test.ts | Verifies response correctness and bundle caching via log count. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e4805a916a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Code Review
This pull request introduces a new E2E test case to verify the loading of CommonJS bundles with runtime globals in a server environment. However, the review feedback identifies a significant issue where the test does not actually exercise the CommonJS runner as intended; the underlying BasicRunnerFactory is currently hardcoded to always return the EsmRunner, meaning the factory logic needs to be updated to select the appropriate runner based on the file extension.
Summary
environments.node.loadBundle()on a CommonJS bundleimport()and access runner-provided globals likequeueMicrotask/checkresponse and the existing bundle cache behaviorRelated Links