Skip to content

Conversation

vicb
Copy link
Contributor

@vicb vicb commented Jun 5, 2025

Supersedes opennextjs/opennextjs-cloudflare#702

Drop the babel dep to save ~4MB on the bundle size.

Details:

  • Empty NextServer#runMiddleware
  • Empty NextServer#runEdgeFunction
  • Drop node-environment-extensions/error-inspect

Tested with the cloudflare adapter

Copy link

changeset-bot bot commented Jun 5, 2025

🦋 Changeset detected

Latest commit: cf9d806

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@opennextjs/aws Patch
app-pages-router Patch
app-router Patch

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

Copy link

pkg-pr-new bot commented Jun 5, 2025

Open in StackBlitz

pnpm add https://pkg.pr.new/@opennextjs/aws@891

commit: cf9d806

Copy link
Contributor

github-actions bot commented Jun 5, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 26.99% 2620 / 9706
🔵 Statements 26.99% 2620 / 9706
🔵 Functions 53.1% 137 / 258
🔵 Branches 73.3% 615 / 839
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/open-next/src/build/createServerBundle.ts 0% 0% 0% 0% 1-390
packages/open-next/src/build/patch/patches/dropBabel.ts 96.07% 100% 25% 96.07% 27, 41
packages/open-next/src/build/patch/patches/index.ts 0% 0% 0% 0% 1
Generated in workflow #1297 for commit cf9d806 by the Vitest Coverage Report Action

@vicb vicb requested review from conico974 and Copilot June 5, 2025 07:55
Copy link

@Copilot Copilot AI left a 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 clear runMiddleware and runEdgeFunction 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\(/,
Copy link
Preview

Copilot AI Jun 5, 2025

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.

Suggested change
contentFilter: /runMiddleware\(/,
contentFilter: /runEdgeFunction\(/,

Copilot uses AI. Check for mistakes.

},
),
contentFilter: /error-inspect/,
patchCode: async ({ code }) => patchCode(code, "errorInspectRule"),
Copy link
Preview

Copilot AI Jun 5, 2025

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.

Suggested change
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
Copy link
Preview

Copilot AI Jun 5, 2025

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.

Suggested change
"@opennextjs/aws": patch
"@opennextjs/aws": patch
"open-next": patch

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@conico974 conico974 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks

@conico974 conico974 merged commit de687b2 into main Jun 5, 2025
3 checks passed
@conico974 conico974 deleted the vicb/babel branch June 5, 2025 08:36
@github-actions github-actions bot mentioned this pull request Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants