fix(netlify): support lambda event requests and cjs cache exports#8439
Draft
azinod wants to merge 1 commit intoweb-infra-dev:mainfrom
Draft
fix(netlify): support lambda event requests and cjs cache exports#8439azinod wants to merge 1 commit intoweb-infra-dev:mainfrom
azinod wants to merge 1 commit intoweb-infra-dev:mainfrom
Conversation
Made-with: Cursor
✅ Deploy Preview for modernjs-byted ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
This PR fixes two follow-up Netlify runtime regressions we hit while validating the Netlify deploy path after the bootstrap filename fix from #8379:
1.
The first problem was that server-side CommonJS output could end up doing
require('@modern-js/runtime/cache'), but the./cachesubpath only exported an ESM target. In a real Netlify function this caused startup to fail with:To fix that, this PR adds a CommonJS-compatible
node.requireexport for@modern-js/runtime/cacheand points the default export at the CJS build.2.
The second problem was in the Netlify request adapter. The generated Netlify handler was forwarding the Lambda-style Netlify event directly into
server.handle(...), but Hono expects a real FetchRequestwith aurl. In production this caused:To fix that, this PR teaches
@modern-js/prod-server/netlifyto:RequestRequestRequesttoserver.handle(...)Responseback into a Netlify-compatible function responseTogether these changes make the generated Netlify function artifact work in the downstream app we used for verification, both locally and in actual Netlify branch deploys.
Related Links
MODERNJS_DEPLOY=netlify npx modern deployChecklist
pnpm run change.Validation
pnpm --filter @modern-js/runtime buildpnpm --filter @modern-js/prod-server buildrequire.resolve('@modern-js/runtime/cache')resolves todist/cjs/cache/index.jsin the generated Netlify function bundle@modern-js/prod-server/dist/cjs/netlify.jscontains the Netlify event ->Requestadapter logic in the downstream app's.netlify/functionsoutputpocanddevelop