-
Notifications
You must be signed in to change notification settings - Fork 22
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
fix: patch @vercel/og usage to use the edge runtime version #283
Conversation
🦋 Changeset detectedLatest commit: 7478813 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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: |
Yep, I created #285 to track this |
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.
Awesome work, thanks!
kind: variable_declarator | ||
has: | ||
kind: identifier | ||
regex: ^fallbackFont$ |
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.
nit: maybe it would be safer to detect the fetch(font_name)
in case the variable name changes - but let's merge this, we can refine later if needed.
packages/cloudflare/src/cli/build/patches/investigated/patch-vercel-og-library.ts
Outdated
Show resolved
Hide resolved
packages/cloudflare/src/cli/build/patches/investigated/patch-vercel-og-library.ts
Outdated
Show resolved
Hide resolved
@@ -33,7 +33,8 @@ export async function bundleServer(buildOpts: BuildOptions): Promise<void> { | |||
console.log(`\x1b[35m⚙️ Bundling the OpenNext server...\n\x1b[0m`); | |||
|
|||
patches.patchWranglerDeps(buildOpts); | |||
patches.updateWebpackChunksFile(buildOpts); | |||
await patches.updateWebpackChunksFile(buildOpts); | |||
await patches.patchVercelOgLibrary(buildOpts); |
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.
It would be nice to be able to move the changes to updateWorkerBundledCode()
It would probably require adding externals to the ESBuild config.
With that we could parse()
(ast-grep) the code once and apply multiple edits.
(This again could be handled in a follow-up PR)
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.
I don't think we can do it there as this is patching a specific route's file whereas that function is patching handler.mjs, and the code for each of the routes doesn't appear to be bundled into the handler.mjs
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 code for each of the routes doesn't appear to be bundled into the handler.mjs
yet :)
As I mentioned, we should move patches that add dependencies (require
) from after the bundle to before/during the bundling.
I do have an ast-grep patch solving the route issue. I need to rebase and submit the PR.
PR is based off of #282 and should not be merged before that one.
This PR does the following:
index.node.js
toindex.edge.js
..bin
.node_modules
.Might be worth noting that the edge runtime version is only available in the node_modules location referenced by the traced files in .next/server, and not .next/standalone. So we need to use that output to get the edge file and work our way back up to node_modules, and bring that over the right place for the standalone build in our output.
Not sure if this approach is entirely what you had in mind.