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

Set swcMinify To False #1846

Merged
merged 1 commit into from
Aug 8, 2023
Merged

Set swcMinify To False #1846

merged 1 commit into from
Aug 8, 2023

Conversation

danielcliu-ifixit
Copy link
Member

Overview

We've had some errors show up on sentry like this since we updated next.js. Based on a github issue comment on the next js repo, turning swcMinify to false may stop these errors. You can read more about swc here and here but basically next js started using it to compile and it could be causing this error. Because next.js just changed the default from false to true and now this is changing it back, im not too worried about potential problems with this change, outside of slower build times and the like. Nevertheless, we should keep an eye on sentry when this deploys.

QA

Make sure the vercel preview seems fine.

Connects: #1808

@vercel
Copy link

vercel bot commented Jul 24, 2023

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

Name Status Preview Updated (UTC)
react-commerce ✅ Ready (Inspect) Visit Preview Jul 24, 2023 10:50pm
react-commerce-prod ✅ Ready (Inspect) Visit Preview Jul 24, 2023 10:50pm

@github-actions
Copy link
Contributor

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

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

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 353.98 KB (🟡 +2.36 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!

One Page Changed Size

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

Page Size (compressed) First Load
/products/[handle] 58.75 KB (🟡 +541 B) 412.73 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.

@danielbeardsley
Copy link
Member

Does this mean it will use whatever minifier it used to before using swc by default?

The bundle size is only slightly bigger, so this seems fine.

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 👍

@danielcliu-ifixit
Copy link
Member Author

Does this mean it will use whatever minifier it used to before using swc by default?

based on this it seems like it falls back to terser, which im assuming it was using before next 13 by default.

@federicobadini
Copy link
Contributor

federicobadini commented Jul 25, 2023

Before merging this I think we should consider upgrading Next.js to the latest version.
As far as it can be seen in the changelog, Swc is being updated continously.

I'd just try to bump Next to the latest version before switching off the new default.

@federicobadini
Copy link
Contributor

deploy_block 🛑 on the previous comment.

@jordycosta
Copy link
Member

QA 🟢

The Vercel preview appears fine 👍

@danielcliu-ifixit
Copy link
Member Author

un_deploy_block ✌️ we tried the upgrade and the error didn't go away

@danielcliu-ifixit danielcliu-ifixit merged commit e0d0983 into main Aug 8, 2023
15 checks passed
@danielcliu-ifixit danielcliu-ifixit deleted the turn-swcMinify-off branch August 8, 2023 22:17
jarstelfox added a commit that referenced this pull request Nov 27, 2023
This small change took some digging.

1) We decided to try setting this to false in hopes of fixing two issues

#1797
#1846

The first issue was fixed (1797) while the second issue was not (1846).

2) Next 14 fails to build with terser enabled.

This is because terser doesn't support node some out the new tsx used by Next 14.
The error is:

../pages/_document.js from Terser
Unexpected token: punc ({) [../pages/_document.js:675,10]

My best guess from some googling is this is due to the class static keyword:
terser/terser#1160

However, this is fixed simply by using the SWC minifier (default) instead of terser.

3) Now with Next 14 the docs claim we shouldn't need terser anymore: https://nextjs.org/docs/architecture/nextjs-compiler
In fact, Terser will not be supported in Next 15 slated for release next year.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants