-
Notifications
You must be signed in to change notification settings - Fork 126
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
OpenNext V3 #402
OpenNext V3 #402
Conversation
moved files around so that it makes more sense deleted a bunch of useless files added todo to remind myself of what i still need to do
added a deletes options in open-next plugin
🦋 Changeset detectedLatest commit: 52641c1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 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 |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Nice! There's a lot to review and I'll likely miss a bunch. |
Yeah don't worry, worst case scenario we can still fix things later if needs be. |
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. I've only look at the code in isolation and not as the whole application, so please excuse me if my comments are irrelevant from missing context.
Regarding:
experimentalBundledNextServer
=> we should deprecate this for 14.2+. We should also draw the line for which version we're supporting since it'll be a headache to support all the potential diff that Vercel will introduce in 14.3+
e2e tests
=> We should get an ion
test app up before we officially introduce v3
git history
=> That's fine, squashing is also dangerous if a single line was missed.
cc: @fwang would be nice if you could deploy a test app and do a quick sanity check of the basic functionality.
}, | ||
experimentalBundledNextServer: true // This enables the bundled next server which is faster and reduce the size of the server | ||
}, | ||
pageSsr: { |
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.
Is this correct:
ssr
=> appDir
pageSsr
=> pagesDir
I'm wondering if people would easily understand/get 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.
Not necessarily, you can give whatever name you want here, and you can mix app and page dir as much as you want. The ssr
functions for example has a page/route3
route
You can also have as many different functions as you want
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.
oops had a dyslexic typo, should have been is this correct
, not this is correct
... updated comment.
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 know how to properly explain these things, but i think with some time and people asking questions about it, we'll figure a proper way to explain it.
//Page dir | ||
computeCopyFilesForPage("pages/_app"); | ||
computeCopyFilesForPage("pages/_document"); | ||
computeCopyFilesForPage("pages/_error"); |
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.
Do we need to copy the 404
and 500
custom error pages? Or is that already included.
ref: https://nextjs.org/docs/pages/building-your-application/routing/custom-error
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.
Nice catch,
Yes we do, for the created functions, we only copy the page in route
.
We should probably add this inside a try catch as they are usually static or SSG and in those cases, we might not have a nft.json
file
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.
We can also make computeCopyFilesForPage
async, then use await Promise.all([computeCopyFilesForPage...])
to run the fs
operations in parallel to speed up the build time.
Might be worth considering if the time save is significant.
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.
Yeah there is some room for improvement in terms of performance here. But computeCopyFilesForPage
doesn't actually copy anything, it just compute every file that is necessary for a given server function.
The copying is done later and that's probably where it would help us.
At the moment it is fast enough i'd say (A lot more than the actual next build
)
We could even improve the runtime performance if we do this properly.
https://github.com/sst/open-next/blob/dae9d98b0519c1ecb640b8c80d7fe0acca5b3886/packages/open-next/src/build/copyTracedFiles.ts#L189-L195
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 added the 404 and 500, they can be there if the user uses getStaticProps
in them.
As for the performance improvement, i think we should see later if it becomes an issue. Making everything async may cause some other trouble as we may be copying thousands of files at the same time
if (hasAppDir) { | ||
//App dir | ||
try { | ||
computeCopyFilesForPage("app/_not-found"); |
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.
is the not-found
convention prefixed with an underscore? I don't see a leading underscore in: https://nextjs.org/docs/app/api-reference/file-conventions/not-found
On the same note, do we need to handle error
? https://nextjs.org/docs/app/api-reference/file-conventions/error
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.
Yes same as the one above, we probably need to add it
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've checked and there is no separate error file generated as part of the bundle. Given that it's a client component, i think that it is bundled as one of the chunks and imported from some next built in component.
And the not-found
component is always compiled as _not-found
also fix an issue when both middleware and page try to set cookies OpenNextNodeResponse also implements ServerResponse
@khuezy I think i have to do a squash merge actually. |
That should be okay, nice work! SHIP IT |
Ok let's go, let's hope i didn't mess the e2e tests |
This PR is for OpenNext V3.
There is one remaining thing that may still need some changes it's the
experimentalBundledNextServer
options that is broken in Next 14.2 and it might be hard to make it work again. There is 2 way to handle this, we could just deprecate the options ( maintaining this could become an absolute nightmare), or we could keep it as is (it's experimental after all) and fix it for new versions when we get time.One other things is that the e2e tests uses a custom CDK implementation, we may want to move to Ion, or we could keep the cdk implementation as some sort of reference implementation. (this is probably something we can do later)
I know that this will be very hard to properly review such a big PR, feel free to ask if you need some information on anything either here or on discord.
Last things, i think we should not squash merge this PR, and we probably want to manually edit the changelog in the Version Packages PR as well.