Skip to content

Fix edge functions bundle path #926

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

Merged
merged 4 commits into from
Aug 3, 2025
Merged

Conversation

psyrenpark
Copy link
Contributor

Summary

This PR includes two main improvements to the OpenNext edge functions handling:

  1. Fix edge functions bundle path: Corrects the bundle path from .open-next/functions to .open-next/server-functions to match the actual build output location.

  2. Add additionalInject option support: Introduces a new additionalInject option for injecting custom code directly into the esbuild banner section.

Changes

  • Fix: Updated edge functions bundle path in generateOutput.ts to use the correct server-functions directory
  • Feature: Added additionalInject option support in createEdgeBundle.ts
  • Documentation: Added comprehensive JSDoc documentation for the new additionalInject option with usage guidelines and caution notes

Breaking Changes

None. These changes are backward compatible.

Notes

  • The additionalInject option should be used with caution as it directly injects code into the esbuild banner section
  • The bundle path fix ensures edge functions are correctly located during deployment

Testing

  • Verified edge functions bundle path matches build output
  • Tested additionalInject option functionality
  • Confirmed backward compatibility

Update bundle path from .open-next/functions to .open-next/server-functions 
to match the actual build output location for edge functions
Add additionalInject: fnOptions.additionalInject for injecting code 
directly into the banner section during esbuild. Use with caution.
Improve JSDoc comment to clarify usage for esbuild banner injection 
and add caution note for safe usage
Copy link

changeset-bot bot commented Jul 15, 2025

🦋 Changeset detected

Latest commit: fba7bab

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 Jul 21, 2025

Open in StackBlitz

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

commit: fba7bab

* Used when code needs to be directly injected into the banner section during esbuild. Should be used with caution.
* @default undefined
*/
additionalInject?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the additionalInject option here make that much sense. it would only work for edge bundle.
An option here should work everywhere, not just in edge runtime

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.

I took the liberty to update the PR.
Regarding the additionalInject that I removed, if you still need this i'd rather have another PR. And i don't think it should be done this way

@conico974 conico974 changed the title Fix edge functions bundle path and add additionalInject option support Fix edge functions bundle path Aug 3, 2025
@conico974 conico974 merged commit 075cc96 into opennextjs:main Aug 3, 2025
3 checks passed
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