-
Notifications
You must be signed in to change notification settings - Fork 169
perf: drop babel
to reduce the server bundle size
#891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: cf9d806 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
Coverage Report
File Coverage
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes the Babel dependency (~4 MB) by emptying unused server methods and dropping the error-inspect
extension.
- Adds a new
patchDropBabel
patch to clearrunMiddleware
andrunEdgeFunction
bodies and remove the error-inspect import - Exposes the patch in the patches index and registers it in the server bundle builder
- Adds unit tests for the new patch and updates the release changeset
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
packages/tests-unit/tests/build/patch/patches/dropBabel.test.ts | Adds tests for the empty-body and error-inspect removal rules |
packages/open-next/src/build/patch/patches/index.ts | Exports the new patchDropBabel in the patches index |
packages/open-next/src/build/patch/patches/dropBabel.ts | Implements the AST rules to drop Babel-related code |
packages/open-next/src/build/createServerBundle.ts | Registers patchDropBabel among the applied code patches |
.changeset/new-wombats-crash.md | Declares the performance change for the @opennextjs/aws package |
escape: false, | ||
}, | ||
), | ||
contentFilter: /runMiddleware\(/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second patch’s contentFilter
still matches runMiddleware(
; it should match runEdgeFunction(
so the edge function body is emptied correctly.
contentFilter: /runMiddleware\(/, | |
contentFilter: /runEdgeFunction\(/, |
Copilot uses AI. Check for mistakes.
}, | ||
), | ||
contentFilter: /error-inspect/, | ||
patchCode: async ({ code }) => patchCode(code, "errorInspectRule"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing the rule name as a string prevents the actual errorInspectRule
from being applied. Use the variable errorInspectRule
instead of the literal string.
patchCode: async ({ code }) => patchCode(code, "errorInspectRule"), | |
patchCode: async ({ code }) => patchCode(code, errorInspectRule), |
Copilot uses AI. Check for mistakes.
@@ -0,0 +1,5 @@ | |||
--- | |||
"@opennextjs/aws": patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changeset only lists @opennextjs/aws
but the patchDropBabel
changes live in the Open Next package; the affected package should be included here so the release picks up your updates.
"@opennextjs/aws": patch | |
"@opennextjs/aws": patch | |
"open-next": patch |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks
Supersedes opennextjs/opennextjs-cloudflare#702
Drop the babel dep to save ~4MB on the bundle size.
Details:
NextServer#runMiddleware
NextServer#runEdgeFunction
node-environment-extensions/error-inspect
Tested with the cloudflare adapter