Skip to content
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: update next to 13.3.0 & ensure compatibility #2056

Merged
merged 35 commits into from Apr 27, 2023
Merged

Conversation

LekoArts
Copy link
Contributor

@LekoArts LekoArts commented Apr 20, 2023

Summary

Updates Next.js next dependency to 13.3.0

Things done in this PR:

  • RSC now uses text/x-component, see Use text/x-component for RSC response vercel/next.js#45808
  • demos/default change of tsconfig.json and next-end.d.ts happened automatically when running the site
  • next now seems to include @vercel/og so the esbuild config had to make this part external so that Node/WASM deps are not loaded
  • Next 13 doesn't have target in its config anymore, so we use server as default now, if people still use Next 12 with the runtime and define target: serverless it'll work. We just flipped the default. Previously this worked because Next defined server itself as the default
  • Add checkIsOnDemandRevalidate replacement as checkIsManualRevalidate was renamed to this
  • Skip a test as it won't be able to pass
  • mockRequest was reworked to createRequestResponseMocks
  • Remove app-dir/head test as it was removed in Next: Remove head.js vercel/next.js#47507
  • Move a test into app-dir/app-edge
  • Remove two CSS tests as they were removed in Fix CSS not being bundled in app dir vercel/next.js#45787
  • The regex for locales in middleware matchers changed

Fixes https://github.com/netlify/pod-ecosystem-frameworks/issues/438
Fixes https://github.com/netlify/pod-ecosystem-frameworks/issues/432

@netlify
Copy link

netlify bot commented Apr 20, 2023

Deploy Preview for netlify-plugin-nextjs-export-demo ready!

Name Link
🔨 Latest commit fed7e3f
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/644a28a6f7aa3f0008647e37
😎 Deploy Preview https://deploy-preview-2056--netlify-plugin-nextjs-export-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Apr 20, 2023

Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!

Name Link
🔨 Latest commit fed7e3f
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-nx-monorepo-demo/deploys/644a28a607891d00084cfbeb
😎 Deploy Preview https://deploy-preview-2056--netlify-plugin-nextjs-nx-monorepo-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Apr 20, 2023

Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!

Name Link
🔨 Latest commit fed7e3f
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-static-root-demo/deploys/644a28a651d5d00008178baa
😎 Deploy Preview https://deploy-preview-2056--netlify-plugin-nextjs-static-root-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Apr 20, 2023

Deploy Preview for next-plugin-edge-middleware ready!

Name Link
🔨 Latest commit fed7e3f
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/644a28a6541c8300089d69ed
😎 Deploy Preview https://deploy-preview-2056--next-plugin-edge-middleware.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Apr 20, 2023

Deploy Preview for next-plugin-canary ready!

Name Link
🔨 Latest commit fed7e3f
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/644a28a651d5d00008178baf
😎 Deploy Preview https://deploy-preview-2056--next-plugin-canary.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Apr 20, 2023

Deploy Preview for next-i18next-demo ready!

Name Link
🔨 Latest commit fed7e3f
🔍 Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/644a28a65495e70008bfa6a5
😎 Deploy Preview https://deploy-preview-2056--next-i18next-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Apr 20, 2023

Deploy Preview for nextjs-plugin-custom-routes-demo ready!

Name Link
🔨 Latest commit fed7e3f
🔍 Latest deploy log https://app.netlify.com/sites/nextjs-plugin-custom-routes-demo/deploys/644a28a6e59f6c00072dad28
😎 Deploy Preview https://deploy-preview-2056--nextjs-plugin-custom-routes-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Apr 20, 2023

Deploy Preview for netlify-plugin-nextjs-demo ready!

Name Link
🔨 Latest commit fed7e3f
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/644a28a64acbf30008993d00
😎 Deploy Preview https://deploy-preview-2056--netlify-plugin-nextjs-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions bot added the type: chore work needed to keep the product and development running smoothly label Apr 20, 2023
@netlify
Copy link

netlify bot commented Apr 20, 2023

Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!

Name Link
🔨 Latest commit fed7e3f
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/644a28a611c83b00077503af
😎 Deploy Preview https://deploy-preview-2056--netlify-plugin-nextjs-next-auth-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@LekoArts LekoArts self-assigned this Apr 20, 2023
@orinokai
Copy link
Contributor

let's not merge this yet, i don't think the snapshot update was right as it should be failing here

@LekoArts
Copy link
Contributor Author

LekoArts commented Apr 24, 2023

@orinokai How do you come to that conclusion? The .nft.json files contain those paths

@LekoArts LekoArts changed the title chore: update next to 13.3.0 fix: update next to 13.3.0 & ensure compatibility Apr 25, 2023
@github-actions github-actions bot added the type: bug code to address defects in shipped code label Apr 25, 2023
@@ -25,7 +25,7 @@ describe('appDir', () => {
},
followRedirect: false,
}).then((response) => {
expect(response.headers).to.have.property('content-type', 'application/octet-stream')
expect(response.headers).to.have.property('content-type', 'text/x-component')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Next.js changed their content-type so this change is expected

@@ -31,6 +31,7 @@ const buildMiddlewareFile = async (entryPoints: Array<string>, base: string) =>
format: 'esm',
target: 'esnext',
absWorkingDir: base,
external: ['next/dist/compiled/@vercel/og'],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this change the compilation of the middleware would fail as @vercel/og contains Node/WASM stuff

const LOCALIZED_REGEX_PREFIX_13_1 = '(?:\\/(_next\\/data\\/[^/]{1,}))?(?:\\/([^/.]{1,}))'
const OPTIONAL_REGEX_PREFIX_13_1 = '(?:\\/(_next\\/data\\/[^/]{1,}))?(?:\\/([^/.]{1,}))?'

const LOCALIZED_REGEX_PREFIX_13_3 = '(?:\\/(_next\\/data\\/[^/]{1,}))?(?:\\/((?!_next\\/)[^/.]{1,}))'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

They changed the regex pattern for middleware matchers when using locales

@@ -37,7 +37,7 @@ export const getResolverForDependencies = ({
// This file is purely to allow nft to know about these pages.
exports.resolvePages = () => {
try {
${pageFiles.join('\n ')}
${pageFiles.sort().join('\n ')}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed for stable output in tests

// it('should skip next deploy for now', () => {})
// return
//}
if ((global as any).isNextDeploy) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Next is also doing this in their tests

@@ -2,4 +2,4 @@ export default function Page() {
return <p>pages-edge-ssr</p>
}

export const config = { runtime: 'edge' }
export const runtime = 'experimental-edge'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Next is also doing this in their tests

})
if(!((global as any).isNextStart && process.env.CUSTOM_CACHE_HANDLER)) {
// TODO: This seems to be a bug in Next.js, try to re-enable it later
it.skip('should navigate to static path correctly', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This failed due to some incorrect logic in their RSC implementation. So I skipped it for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

was completely removed so they also removed their tests

expect(html).toContain('<link href="/test1.js" rel="preload" as="script"/>')
expect(html).toContain('<link href="/test2.js" rel="preload" as="script"/>')
expect(html).toContain('<link href="/test3.js" rel="preload" as="script"/>')
expect(html).toContain('<link rel="preload" as="script" href="/test1.js"/>')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Order on things seems to have changed

@@ -396,7 +396,7 @@ describe('app dir - rsc basics', () => {

const requiredServerFiles = (await fs.readJSON(path.join(distDir, 'required-server-files.json'))).files

const files = ['middleware-build-manifest.js', 'middleware-manifest.json', 'flight-manifest.json']
const files = ['middleware-build-manifest.js', 'middleware-manifest.json', 'client-reference-manifest.json']
Copy link
Contributor Author

Choose a reason for hiding this comment

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

They renamed this file

@@ -105,7 +105,7 @@ describe('checkZipSize', () => {
})
})

describe("getProblematicUserRewrites", () => {
describeCwdTmpDir("getProblematicUserRewrites", () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix for an older PR of mine, it discovered this while running the test locally

it('extracts dependencies that exist', async () => {
// TODO: `dependencies` references files inside the <root>/node_modules directory which isn't accessible in moveNextDist
// So this whole test needs to be reworked as it can't be fixed
it.skip('extracts dependencies that exist', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the demo page is part of the npm workspace, it references files inside the root node_modules folder.
When we copy/move this demo page to a tmp dir for this test, it tries to reach into that node_modules folder that doesn't exist.

@@ -71,7 +71,8 @@ describe('the netlify next server', () => {
const netlifyNextServer = new NetlifyNextServer({ conf: {} }, { ...mockTokenConfig })
const requestHandler = netlifyNextServer.getRequestHandler()

const { req: mockReq, res: mockRes } = mockRequest('/getStaticProps/with-revalidate/', {}, 'GET')
const { req: mockReq, res: mockRes } = createRequestResponseMocks({ url: '/getStaticProps/with-revalidate/' })
Copy link
Contributor Author

Choose a reason for hiding this comment

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

mockRequest was replaced by createRequestResponseMocks

@LekoArts LekoArts marked this pull request as ready for review April 26, 2023 08:28
@LekoArts LekoArts requested a review from a team April 26, 2023 08:28
@kodiakhq kodiakhq bot merged commit 75ed977 into main Apr 27, 2023
95 of 97 checks passed
@kodiakhq kodiakhq bot deleted the update-next-13.3.0 branch April 27, 2023 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge type: bug code to address defects in shipped code type: chore work needed to keep the product and development running smoothly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants