Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Upgrade to next 13 #1726

Merged
merged 7 commits into from
Jun 26, 2023
Merged

Upgrade to next 13 #1726

merged 7 commits into from
Jun 26, 2023

Conversation

federicobadini
Copy link
Contributor

@federicobadini federicobadini commented May 30, 2023

closes #1595

This pull request includes the following updates:

Next Image

The next/future/image is now the default image component as per Next.js 13 documentation. Some props were removed which required changes to both usages of the next/image component and derived components like ResponsiveImage. A few style fixes were needed due to markup differences.

Next Links

The new link component doesn't require a nested anchor tag anymore. Whenever possible, the new behavior was adopted. The legacyBehaviour prop is available and has been used to reduce the number of changes in this PR for components that could've needed more intricate style/markup refactoring.

Next Script

Scripts marked as beforeInteractive were moved to _document.tsx as suggested in Next.js documentation.

Next Transpile Modules

Next.js now has its own transpile option, so the next-transpile-modules package is no longer needed. For more information, check here.

Sentry Edge Config

A Sentry edge config was added to address warnings about missing Sentry config files and to prepare for experiments with edge middlewares.

SSR Failure for Next Router

A workaround was added to prevent SSR failure in Next.js 13. Refer to these discussions for more information: issue #5650 and issue #5475.

MSW Issue

The MSW mocking utility is not fully compatible with Next 13, as discussed here. Since MSW will likely be replaced by other mocking strategies, problematic tests have been temporarily skipped.
The reasons we suggest prioritizing an upgrade over exploring new testing mechanisms are that Next.js 13 introduces a significant change with server components.
Delaying the adoption of this paradigm might be disadvantageous. During these weeks, several core aspects are being discussed, such as translations management, performance improvement, and A/B testing—all of which could benefit from the enhanced functionality offered by the new framework.
For additional details see here

Minor Updates

  • A missing hook dependency was added to InstantSearchProvider.tsx.

QA

  1. Visit Vercel preview
  2. Verify functionality across the various page types
  3. Take into account that several playwright test were skipped since MSW is not yet compatible with Next.js 13 - so there might be a few more scenarios to verify manually.

@vercel
Copy link

vercel bot commented May 30, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-commerce ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 26, 2023 6:28pm
react-commerce-prod ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 26, 2023 6:28pm

@github-actions
Copy link
Contributor

github-actions bot commented May 30, 2023

📦 Next.js Bundle Analysis for @ifixit/commerce-frontend

This analysis was generated by the Next.js Bundle Analysis action. 🤖

🎉 Global Bundle Size Decreased

Page Size (compressed)
global 356.56 KB (🟢 -2.33 KB)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Eight Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/Parts 56.55 KB (🟢 -1.45 KB) 413.1 KB
/Parts/[...deviceHandleItemType] 56.57 KB (🟢 -1.45 KB) 413.12 KB
/Shop/[handle] 56.55 KB (🟢 -1.45 KB) 413.11 KB
/Tools 56.55 KB (🟢 -1.45 KB) 413.1 KB
/Tools/[handle] 56.55 KB (🟢 -1.45 KB) 413.11 KB
/Vulcan/[wikiname] 31.46 KB (🟢 -843 B) 388.02 KB
/[...slug] 24.98 KB (🟢 -725 B) 381.54 KB
/products/[handle] 58.3 KB (🟢 -1.73 KB) 414.86 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

@batbattur
Copy link
Contributor

@federicobadini we merged #1755 to unblock the failing tests.

masonmcelvain
masonmcelvain previously approved these changes Jun 15, 2023
Copy link
Contributor

@masonmcelvain masonmcelvain left a comment

Choose a reason for hiding this comment

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

CR ✌🏻 Thanks for taking this on!

frontend/components/sections/QuoteSection.tsx Show resolved Hide resolved
frontend/sentry.edge.config.ts Show resolved Hide resolved
@k0rvusk0r4x k0rvusk0r4x added the QAing Under QA team review label Jun 15, 2023
@k0rvusk0r4x
Copy link

Everything appears to be working as before.

QA 😺

@k0rvusk0r4x k0rvusk0r4x removed the QAing Under QA team review label Jun 15, 2023
@@ -56,7 +56,7 @@ test.describe('Product Variant Tests', () => {
).not.toBeVisible();
});

test('Switch Variants and Add To Cart', async ({
Copy link
Member

Choose a reason for hiding this comment

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

Is this meant to still be in here? This seems to skip the test that ensures variant switching and add-to-cart remain working.

Copy link
Member

Choose a reason for hiding this comment

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

I see the pull description now. While I understand the motivation, I'm not sure I'm comfortable deploying a major change to our platform and also disabling our most important tests. Is there someplace we need to go badly enough that we feel it's worth the risk of driving without our seatbelts?

Copy link
Contributor Author

@federicobadini federicobadini Jun 16, 2023

Choose a reason for hiding this comment

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

Here are some of the reasons for upgrading we discussed in the past weeks:

Next.js 13 introduced app routing
This is a significant change compared to the page routing that was widely used in earlier versions of Next.js. The introduction of app routing has several consequences:

  • It enables React Server Components, which provide a new way to improve performance - especially do reduce bundle related metrics.
  • It opens up new opportunities for libraries to adapt and work in this new paradigm. For instance, we are evaluating how to localize content, and choosing a library that works well with this paradigm is crucial to avoid losing the benefits that React Server Components bring.

Overwriting headers and cookies in middlewares
Next.js 13 should also allow us to overwrite headers (and possibly cookies) in middlewares. This feature might be interesting for A/B testing.

MSW in monorepo
I had a chat with @ardelato in which he informed me that MSW is most likely not going to be included in the upcoming monorepo. As a result, those tests need to be restructured anyway.

Skipped test impact up to now
According to answers collected on slack, those tests seems not to have caught that many problems up to now (see here). I cannot be sure that every dev viewed this slack message though

To be clear, removing tests is not something that I like too, and I feel why you are in doubt.
However not going for an update also means tha we lose the opportunities above at least for some time.

Copy link
Contributor

Choose a reason for hiding this comment

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

Building upon what @federicobadini has mentioned, @iFixit/qae has discussed the future of MSW in the monorepo and are leaning towards removing it. The original motive for integrating MSW was to mock server-side requests for fetching specific product types. Nonetheless, in the monorepo we can make use of our PHP testing extensions to set up these products in the test DB, thereby negating the necessity of MSW.

To address the lack of test coverage, we are working on expanding a script that would help populate the database for manual QA. https://github.com/iFixit/ifixit/issues/48312

@danielbeardsley
Copy link
Member

danielbeardsley commented Jun 15, 2023

There aren't any commit messages here, so it's hard to understand the purpose behind some of the changes. Can you explain some of the patterns? Like usage of style=... instead of attributeProps for instance.

dev_block 👍 on us being sure this is time-critical enough to warrant disabling all our tests.

Neither the issue nor the pull give a justification for this being time critical.

federicobadini and others added 2 commits June 16, 2023 16:30
Co-authored-by: Mason McElvain <52104630+masonmcelvain@users.noreply.github.com>
@federicobadini
Copy link
Contributor Author

I squashed the commits in order to avoid cluttering the PR with temporary changes that were made to get tests working or resolve compilation errors, which might have been confusing for the reviewers. In the future, if you prefer having the whole set of commits, I can certainly leave them 😊

Regarding the usage of style=... instead of proper props, the reason is that some of those props were removed in Next.js v13, such as layout or objectFit. You can find more information in the Version History section of the Next.js documentation here.

@danielbeardsley
Copy link
Member

temporary changes that were made to get tests working or resolve compilation errors, which might have been confusing for the reviewers. In the future, if you prefer having the whole set of commits, I can certainly leave them

I understand, back and forth changes or experimentation in commit history usually aren't important and often do lead to confusion, so squashing some of that makes sense. That said, having no commit messages, no pull description, and no issue description for a major version upgrade of the platform that also disables all the tests is way outside the norms.

I'm not doubting that there are good reasons to plow ahead anyway, but I think it's a good idea to document the motivations and justifications in the issue or the pull request. Acknowledging that costs and risks were evaluated, and then recording the resulting decision is prudent and good practice and leaves a paper-trail to examine later.

I vote for filling out the pull description with some of the information from your explanatory comment above.

@federicobadini
Copy link
Contributor Author

I have updated the PR description with many details describing what this PR is doing and why we are proposing to give precedence to this wrt waiting to solve MSW/test related issues 🙂

Copy link
Member

@danielbeardsley danielbeardsley left a comment

Choose a reason for hiding this comment

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

CR 👍

Good work!

@ACPK
Copy link

ACPK commented Jun 26, 2023

Is there any progress on accepting this PR?

@danielbeardsley
Copy link
Member

un_dev_block 👍 I'm OK with going forward on this. Still needs QA though.

@k0rvusk0r4x k0rvusk0r4x added the QAing Under QA team review label Jun 26, 2023
Conflicts:
  frontend/templates/product-list/sections/ProductListChildrenSection.tsx
  - Master remove the usage of NextLink here, so we don't need to set
    `legacyBehavior`
Copy link
Member

@danielbeardsley danielbeardsley left a comment

Choose a reason for hiding this comment

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

CR 👍

@k0rvusk0r4x
Copy link

Continues to work as expected.

QA 😺

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade to Next 13
8 participants