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

build: Update swc_core to v0.86.40 and update turbopack #57904

Merged
merged 31 commits into from
Nov 7, 2023

Conversation

@kdy1 kdy1 self-assigned this Nov 1, 2023
@ijjk ijjk added created-by: Turbopack team PRs by the Turbopack team. type: next labels Nov 1, 2023
@kdy1
Copy link
Member Author

kdy1 commented Nov 1, 2023

I'm working to verify if node-fetch is fixed by inline: 2

@ijjk
Copy link
Member

ijjk commented Nov 1, 2023

Tests Passed

@ijjk
Copy link
Member

ijjk commented Nov 1, 2023

Stats from current PR

Default Build
General
vercel/next.js canary vercel/next.js kdy1/revert-mangler Change
buildDuration 10.7s 10.8s N/A
buildDurationCached 6s 6.6s ⚠️ +596ms
nodeModulesSize 175 MB 175 MB N/A
nextStartRea..uration (ms) 422ms 427ms N/A
Client Bundles (main, webpack)
vercel/next.js canary vercel/next.js kdy1/revert-mangler Change
199-HASH.js gzip 30.4 kB N/A N/A
3f784ff6-HASH.js gzip 53.2 kB N/A N/A
494.HASH.js gzip 182 B N/A N/A
framework-HASH.js gzip 45.5 kB 45.2 kB N/A
main-app-HASH.js gzip 254 B 239 B N/A
main-HASH.js gzip 33 kB 31.7 kB N/A
webpack-HASH.js gzip 1.76 kB 1.7 kB N/A
110.HASH.js gzip N/A 181 B N/A
3c4a14c2-HASH.js gzip N/A 53.2 kB N/A
513-HASH.js gzip N/A 29.3 kB N/A
Overall change 0 B 0 B
Legacy Client Bundles (polyfills)
vercel/next.js canary vercel/next.js kdy1/revert-mangler Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary vercel/next.js kdy1/revert-mangler Change
_app-HASH.js gzip 205 B 195 B N/A
_error-HASH.js gzip 182 B 181 B N/A
amp-HASH.js gzip 505 B 506 B N/A
css-HASH.js gzip 322 B 323 B N/A
dynamic-HASH.js gzip 2.59 kB 2.5 kB N/A
edge-ssr-HASH.js gzip 258 B 255 B N/A
head-HASH.js gzip 348 B 347 B N/A
hooks-HASH.js gzip 369 B 368 B N/A
image-HASH.js gzip 4.38 kB 4.3 kB N/A
index-HASH.js gzip 256 B 256 B
link-HASH.js gzip 2.71 kB 2.65 kB N/A
routerDirect..HASH.js gzip 318 B 311 B N/A
script-HASH.js gzip 384 B 383 B N/A
withRouter-HASH.js gzip 319 B 308 B N/A
1afbb74e6ecf..834.css gzip 106 B 106 B
Overall change 362 B 362 B
Client Build Manifests
vercel/next.js canary vercel/next.js kdy1/revert-mangler Change
_buildManifest.js gzip 483 B 484 B N/A
Overall change 0 B 0 B
Rendered Page Sizes
vercel/next.js canary vercel/next.js kdy1/revert-mangler Change
index.html gzip 529 B 526 B N/A
link.html gzip 542 B 540 B N/A
withRouter.html gzip 524 B 522 B N/A
Overall change 0 B 0 B
Edge SSR bundle Size
vercel/next.js canary vercel/next.js kdy1/revert-mangler Change
edge-ssr.js gzip 96.8 kB 92.1 kB N/A
page.js gzip 151 kB 144 kB N/A
Overall change 0 B 0 B
Middleware size
vercel/next.js canary vercel/next.js kdy1/revert-mangler Change
middleware-b..fest.js gzip 626 B 625 B N/A
middleware-r..fest.js gzip 148 B 151 B N/A
middleware.js gzip 24.8 kB 24.8 kB N/A
edge-runtime..pack.js gzip 1.92 kB 1.92 kB
Overall change 1.92 kB 1.92 kB
Next Runtimes
vercel/next.js canary vercel/next.js kdy1/revert-mangler Change
app-page-exp...dev.js gzip 165 kB 165 kB
app-page-exp..prod.js gzip 92.2 kB 92.2 kB
app-page-tur..prod.js gzip 93 kB 93 kB
app-page-tur..prod.js gzip 87.7 kB 87.7 kB
app-page.run...dev.js gzip 135 kB 135 kB
app-page.run..prod.js gzip 87 kB 87 kB
app-route-ex...dev.js gzip 23.5 kB 23.5 kB
app-route-ex..prod.js gzip 16.4 kB 16.4 kB
app-route-tu..prod.js gzip 16.4 kB 16.4 kB
app-route-tu..prod.js gzip 16 kB 16 kB
app-route.ru...dev.js gzip 22.9 kB 22.9 kB
app-route.ru..prod.js gzip 16 kB 16 kB
pages-api-tu..prod.js gzip 9.37 kB 9.37 kB
pages-api.ru...dev.js gzip 9.64 kB 9.64 kB
pages-api.ru..prod.js gzip 9.37 kB 9.37 kB
pages-turbo...prod.js gzip 21.5 kB 21.5 kB
pages.runtim...dev.js gzip 22.2 kB 22.2 kB
pages.runtim..prod.js gzip 21.5 kB 21.5 kB
server.runti..prod.js gzip 48.5 kB 48.5 kB
Overall change 913 kB 913 kB
Commit: 9a9b28f

@kdy1 kdy1 added the linear: turbopack Confirmed issue that is tracked by the Turbopack team. label Nov 1, 2023
kdy1 added 4 commits November 2, 2023 06:17

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
feedthejim
feedthejim previously approved these changes Nov 1, 2023
@kdy1
Copy link
Member Author

kdy1 commented Nov 1, 2023

We need to wait for swc-project/swc#8205 before merging this to prevent #55682 from occurring again

This reverts commit 3add9bf.
kdy1 added 2 commits November 2, 2023 08:26

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
kdy1 added a commit to swc-project/swc that referenced this pull request Nov 2, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
)

**Description:**

Note: Preserving native names is a hack, but it's used by `terser` and it's the only way to preserve the name of `class AbortSignal` while mangling without `keep_classnames: true`. We can special case `AbortSignal`, but let's just follow `terser`.


**Related issue:**

 - vercel/next.js#57904
kdy1 added a commit to swc-project/swc that referenced this pull request Nov 2, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
**Related issue:**

 - vercel/next.js#57904 (CI failed)
@kdy1
Copy link
Member Author

kdy1 commented Nov 7, 2023

I assumed the CI is flaky, but I found that the CI failure is a source map regression of the SWC minifier.

image

d05086a does not update swc_core so it's a regression of SWC from https://github.com/vercel/next.js/tree/83c18deafe4f133f74ef2b1e0512228098d48cba

@kdy1
Copy link
Member Author

kdy1 commented Nov 7, 2023

Range: swc-project/swc@83f77dd...b806f92

@kdy1
Copy link
Member Author

kdy1 commented Nov 7, 2023

investigation

It was not a regression. The test was wrong. It should not rely on the class name on production build.

@kdy1 kdy1 requested a review from wyattjoh as a code owner November 7, 2023 08:24
@@ -167,7 +167,7 @@ describe('Application Export Intent Output', () => {

it('should build and export', async () => {
const result = await nextBuild(appDir, [], { stderr: true })
expect(result.stderr).toMatch('A.getInitialProps()')
expect(result.stderr).toMatch('.getInitialProps()')
Copy link
Member Author

Choose a reason for hiding this comment

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

I found that #57085 added this, but this should fail on the production builds. We should not preserve class names for production (10% size regression if we do so).

Copy link
Member Author

Choose a reason for hiding this comment

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

Due to a regression I introduced before #57085 it was not detected, and this PR includes fixes for the regression.

Copy link
Member Author

Choose a reason for hiding this comment

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

cc @styfle

@kdy1 kdy1 marked this pull request as draft November 7, 2023 08:45
@kdy1 kdy1 marked this pull request as ready for review November 7, 2023 09:58
@sokra sokra marked this pull request as draft November 7, 2023 13:10
sokra
sokra previously approved these changes Nov 7, 2023
kodiakhq bot pushed a commit to vercel/turborepo that referenced this pull request Nov 7, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
### Description

This PR is required to apply
vercel/next.js#57904 in next.js

### Testing Instructions

Let's look at the CI of next.js
@kdy1 kdy1 marked this pull request as ready for review November 7, 2023 14:55
@kdy1 kdy1 requested a review from a team as a code owner November 7, 2023 14:56
@kdy1 kdy1 changed the title build: Update swc_core to v0.86.40 build: Update swc_core to v0.86.40 & turbopack Nov 7, 2023
@kdy1 kdy1 marked this pull request as draft November 7, 2023 14:57
@kdy1 kdy1 changed the title build: Update swc_core to v0.86.40 & turbopack build: Update swc_core to v0.86.40 and update turbopack Nov 7, 2023
@kdy1 kdy1 requested a review from sokra November 7, 2023 14:57

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@kdy1 kdy1 marked this pull request as ready for review November 7, 2023 14:57
@kodiakhq kodiakhq bot merged commit c370c17 into canary Nov 7, 2023
@kodiakhq kodiakhq bot deleted the kdy1/revert-mangler branch November 7, 2023 15:26
kdy1 added a commit to swc-project/swc that referenced this pull request Nov 16, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
**Description:**

Regarding vercel/next.js#55682, I made a mistake while investigating. I assumed it's `swcMinify`-only but it seems like `node-fetch` is fundamentally incompatible with our minification options.

I thought `node-fetch` works with terser, but it did not, and it **should not**. But as I thought `terser` works, I assumed that `terser` has a hack for `AbortSignal`. And that's how I fixed `swcMinify: true`. The correct fix is `keep_classnames: true` but it will result in +~10% bundle size bloat.
At first, I used the correct way (`keep_classnames: true`), but it resulted in the bundle size bloat, so I mimicked the hack of terser with vercel/next.js#57904.

While working on other minification issues, I found that there's no such hack in `terser` and I need to remove the hack in the SWC minifier.
The repro in vercel/next.js#55682 does not work with `swcMinify: false`, even with next@14. The problem of minifier and node-fetch was not exploited before `serverMinification: true`.


**Related issue:**

 - brix/crypto-js#415
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
created-by: Turbopack team PRs by the Turbopack team. linear: turbopack Confirmed issue that is tracked by the Turbopack team. locked type: next
Projects
None yet
5 participants