-
Notifications
You must be signed in to change notification settings - Fork 23
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
make sure patchFindDir
works with Next.js 15 and add patching validation check
#184
Conversation
|
commit: |
`function findDir(dir, name) { | ||
if (dir.endsWith(".next/server")) { | ||
if (name === "app") { | ||
const patchedCode = code.replace( |
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.
Maybe add a comment here with the pre-15.1 code and 15.1 code
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.
are you sure? it feels a bit overkill to me here 😕
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 might help if we later need to convert the patch to AST but your call :)
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.
(and to be clear I meant fn signature, not the whole function)
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'd leave it as is if it's ok by you 🙂
but if you do prefer a comment, could you please add a code suggestion here and I'd be happy to just go with whatever you'd fine useful here 🙂
packages/cloudflare/src/cli/build/patches/to-investigate/patch-find-dir.ts
Outdated
Show resolved
Hide resolved
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.
Thanks Dario 🙏
Does this also resolve the warnings (eval(require)...
?)
Feel to to assign #28 to yourself and add it to the board :)
Maybe create an issue for
|
Also add patching validation check
Also add patching validation check
resolves #172
The
patchFindDir
function:opennextjs-cloudflare/packages/cloudflare/src/cli/build/patches/to-investigate/patch-find-dir.ts
Line 12 in acec1c3
Stopped working since a new
name
variable got introduced in the Next.js source code, causing the bundled code to rename the function'sname
parameter toname2
instead:I fixed this by updating the code replacement to also accept the variables with a numerical suffix. I also added a check to make sure that the patching is applied (if we already had the check in place that would have saved me lots of time here! 😭)
A few notes:
to-investigate
directory I guess that we assume that this is temporary, so maybe it's not worth investing time to update the code to use ASTs? (if it is I am more than happy to do so!)patchedCode !== code
check would have saved me lots of time here, we need to add it to all the patch functions to avoid wasting time again, I will do that in a followup PRpatchedCode !== code
check would be good enough for now