feat(deps): Sync loadPeer()#3465
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthrough
ChangesSynchronous loadPeer propagation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — loadPeer() is made synchronous by switching from await import() to createRequire-based require(), leveraging Node 22.12+ ESM-require support. This enables the typescript parameter on Integration's constructor to default to loadPeer("typescript"), removing the need for Integration.create().
- Sync
loadPeer()— replacesawait import()withcreateRequire(import.meta.url)+require(); the engine floor of^22.19.0ensuresrequire(ESM)is available. IntegrationParams.typescriptnow optional — defaults toloadPeer("typescript")with@defaultJSDoc.- Deprecate
Integration.create()— the static factory is marked@deprecatedwith a@todoto remove in the next major;compat-testupdated to usenew Integration()directly. - Remove
awaitfrom allloadPeer()call sites —createServer,createCookieParser,createUploadParsers, andIntegration.formatClientCodeall dropawait. - Restructure test peer mocks — move peer mocking from
express-mock.ts(per-modulevi.mock) to newpeers-mock.ts(mockloadPeeritself with a module-name switch).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@express-zod-api/src/peer-helpers.ts`:
- Around line 12-13: The function is returning mod[moduleExport] without
verifying it exists when moduleExport is not "default", allowing undefined
values to be returned instead of failing immediately. Add a check after
attempting to access mod[moduleExport] to verify the named export exists, and
throw an error if it is undefined. Only return the value if it is actually
present, ensuring the peer-loading failure is surfaced immediately rather than
returning an invalid undefined value.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 779dba11-9731-4111-bcc4-b36e0812b2d3
📒 Files selected for processing (11)
compat-test/int.spec.tsexpress-zod-api/src/integration.tsexpress-zod-api/src/peer-helpers.tsexpress-zod-api/src/server-helpers.tsexpress-zod-api/src/server.tsexpress-zod-api/tests/express-mock.tsexpress-zod-api/tests/integration.spec.tsexpress-zod-api/tests/peer-helpers.spec.tsexpress-zod-api/tests/peers-mock.tsexpress-zod-api/tests/server-helpers.spec.tsexpress-zod-api/tests/server.spec.ts
💤 Files with no reviewable changes (1)
- express-zod-api/tests/express-mock.ts
Thanks to #3465 This should simplify daily routines for beginners. ## Tradeoffs - Removed `Promise` from `ServerHook` type => `beforeRouting` and `afterRouting` become sync - No further async features to `createServer` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Updated code examples to show synchronous server initialization without `await` * **Refactor** * Server creation function is now fully synchronous; remove `await` when invoking it * Server lifecycle hooks execute synchronously during initialization <!-- end of auto-generated comment: release notes by coderabbit.ai -->

This is now possible because we dropped Node 20 in v28 ( #3242 ) and
require(ESM)is available since 22.12 without flags. So we can do dynamic module import without async.Could benefit in #3463
A semi-breaking change to
Integration::create()is postponed until next major.⌛ Mocking peers in tests requires a rework (in progress)
Summary by CodeRabbit
Refactor
IntegrationTypeScript configuration is optional; prefernew Integration(...)over the deprecatedIntegration.create().Tests
Documentation
v28.6.0changelog entry.