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: Workaround acorn bug/version issue by using SWC #65021

Merged
merged 3 commits into from Apr 26, 2024
Merged

Conversation

kdy1
Copy link
Member

@kdy1 kdy1 commented Apr 25, 2024

What?

Force transpile private properties using SWC to workaround acorn issue

Why?

#30174 (comment)

How?

Closes https://linear.app/vercel/issue/SWC-107

@kdy1 kdy1 self-assigned this Apr 25, 2024
@ijjk ijjk added created-by: Turbopack team PRs by the turbopack team type: next labels Apr 25, 2024
@ijjk
Copy link
Member

ijjk commented Apr 25, 2024

Failing test suites

Commit: b2c108e

TURBOPACK=1 pnpm test-start test/e2e/app-dir/app-external/app-external.test.ts (turbopack)

  • app dir - external dependency > should be able to opt-out 3rd party packages being bundled in server components
Expand output

● app dir - external dependency › should be able to opt-out 3rd party packages being bundled in server components

expect(received).toContain(expected) // indexOf

Expected substring: "opt-out-react-version: 18.2.0"
Received string:    "<!DOCTYPE html><html><head><meta charSet=\"utf-8\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/><link rel=\"preload\" as=\"script\" fetchPriority=\"low\" href=\"/_next/static/chunks/node_modules__pnpm_138ca9._.js\"/><script src=\"/_next/static/chunks/5dd92_next_dist_esm_build_templates_app-page_9eca43.js\" async=\"\"></script><script src=\"/_next/static/chunks/_3c977b._.js\" async=\"\"></script><script src=\"/_next/static/chunks/_ef26de._.js\" async=\"\"></script><meta name=\"next-size-adjust\"/></head><body><div>Server: index.default<br/>Server subpath: subpath.default<br/>Client: index.default<br/>Client subpath: subpath.default<br/><p id=\"optout-react-version\">opt-out-react-version: 18.3.0</p></div><script src=\"/_next/static/chunks/node_modules__pnpm_138ca9._.js\" async=\"\"></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,\"1:I[\\\"[project]/node_modules/.pnpm/file+..+next-repo-0a4f14113014d4bc82a59cab144d633c032e3760ebaaf1936091808c8dda2017+packages+n_rjniedzcv5jbsuwt5og7drqfju/node_modules/next/dist/client/components/app-router.js [app-client] (ecmascript)\\\",[\\\"static/chunks/_3c977b._.js\\\"],\\\"default\\\"]\\n3:I[\\\"[project]/app/react-server/optout/client.js [app-client] (ecmascript)\\\",[\\\"static/chunks/_3c977b._.js\\\",\\\"static/chunks/_ef26de._.js\\\"],\\\"default\\\"]\\n4:I[\\\"[project]/node_modules/.pnpm/file+..+next-repo-0a4f14113014d4bc82a59cab144d633c032e3760ebaaf1936091808c8dda2017+packages+n_rjniedzcv5jbsuwt5og7drqfju/node_modules/next/dist/client/components/layout-router.js [app-client] (ecmascript)\\\",[\\\"static/chunks/_3c977b._.js\\\"],\\\"default\\\"]\\n5:I[\\\"[project]/node_modules/.pnpm/file+..+next-repo-0a4f14113014d4bc82a59cab144d633c032e3760ebaaf1936091808c8dda2017+packages+n_rjniedzcv5jbsuwt5og7drqfju/node_modules/next/dist/client/components/render-from-template-context.js [app-client] (ecmascript)\\\",[\\\"static/chunks/_3c977b._.js\\\"],\\\"default\\\"]\\n7:I[\\\"[project]/node_modules/.pnpm/file+..+next-repo-0a4f14113014d4bc82a59cab144d633c032e3760ebaaf1936091808c8dda2017+packages+n_rjniedzcv5jbsuwt5og7drqfju/node_modules/next/dist/client/components/error-boundary.js [app-client] (ecmascript)\\\",[\\\"static/chunks/_3c977b._.js\\\"],\\\"default\\\"]\\n8:[]\\n\"])</script><script>self.__next_f.push([1,\"0:[[[\\\"$\\\",\\\"script\\\",\\\"script-0\\\",{\\\"src\\\":\\\"/_next/static/chunks/_3c977b._.js\\\",\\\"async\\\":true}]],[\\\"$\\\",\\\"$L1\\\",null,{\\\"buildId\\\":\\\"ugnZBHiE9AvoX6Y6TpVUF\\\",\\\"assetPrefix\\\":\\\"\\\",\\\"initialCanonicalUrl\\\":\\\"/react-server/optout\\\",\\\"initialTree\\\":[\\\"\\\",{\\\"children\\\":[\\\"react-server\\\",{\\\"children\\\":[\\\"optout\\\",{\\\"children\\\":[\\\"__PAGE__\\\",{}]}]}]},\\\"$undefined\\\",\\\"$undefined\\\",true],\\\"initialSeedData\\\":[\\\"\\\",{\\\"children\\\":[\\\"react-server\\\",{\\\"children\\\":[\\\"optout\\\",{\\\"children\\\":[\\\"__PAGE__\\\",{},[[\\\"$L2\\\",[\\\"$\\\",\\\"div\\\",null,{\\\"children\\\":[\\\"Server: index.default\\\",[\\\"$\\\",\\\"br\\\",null,{}],\\\"Server subpath: subpath.default\\\",[\\\"$\\\",\\\"br\\\",null,{}],[\\\"$\\\",\\\"$L3\\\",null,{}],[\\\"$\\\",\\\"p\\\",null,{\\\"id\\\":\\\"optout-react-version\\\",\\\"children\\\":\\\"opt-out-react-version: 18.3.0\\\"}]]}]],null],null]},[\\\"$\\\",\\\"$L4\\\",null,{\\\"parallelRouterKey\\\":\\\"children\\\",\\\"segmentPath\\\":[\\\"children\\\",\\\"react-server\\\",\\\"children\\\",\\\"optout\\\",\\\"children\\\"],\\\"error\\\":\\\"$undefined\\\",\\\"errorStyles\\\":\\\"$undefined\\\",\\\"errorScripts\\\":\\\"$undefined\\\",\\\"template\\\":[\\\"$\\\",\\\"$L5\\\",null,{}],\\\"templateStyles\\\":\\\"$undefined\\\",\\\"templateScripts\\\":\\\"$undefined\\\",\\\"notFound\\\":\\\"$undefined\\\",\\\"notFoundStyles\\\":\\\"$undefined\\\",\\\"styles\\\":[[\\\"$\\\",\\\"script\\\",\\\"script-0\\\",{\\\"src\\\":\\\"/_next/static/chunks/_ef26de._.js\\\",\\\"async\\\":true}]]}],null]},[\\\"$\\\",\\\"$L4\\\",null,{\\\"parallelRouterKey\\\":\\\"children\\\",\\\"segmentPath\\\":[\\\"children\\\",\\\"react-server\\\",\\\"children\\\"],\\\"error\\\":\\\"$undefined\\\",\\\"errorStyles\\\":\\\"$undefined\\\",\\\"errorScripts\\\":\\\"$undefined\\\",\\\"template\\\":[\\\"$\\\",\\\"$L5\\\",null,{}],\\\"templateStyles\\\":\\\"$undefined\\\",\\\"templateScripts\\\":\\\"$undefined\\\",\\\"notFound\\\":\\\"$undefined\\\",\\\"notFoundStyles\\\":\\\"$undefined\\\",\\\"styles\\\":null}],null]},[[\\\"$\\\",\\\"html\\\",null,{\\\"children\\\":[[\\\"$\\\",\\\"head\\\",null,{}],[\\\"$\\\",\\\"body\\\",null,{\\\"children\\\":[\\\"$\\\",\\\"$L4\\\",null,{\\\"parallelRouterKey\\\":\\\"children\\\",\\\"segmentPath\\\":[\\\"children\\\"],\\\"error\\\":\\\"$undefined\\\",\\\"errorStyles\\\":\\\"$undefined\\\",\\\"errorScripts\\\":\\\"$undefined\\\",\\\"template\\\":[\\\"$\\\",\\\"$L5\\\",null,{}],\\\"templateStyles\\\":\\\"$undefined\\\",\\\"templateScripts\\\":\\\"$undefined\\\",\\\"notFound\\\":[[\\\"$\\\",\\\"title\\\",null,{\\\"children\\\":\\\"404: This page could not be found.\\\"}],[\\\"$\\\",\\\"div\\\",null,{\\\"style\\\":{\\\"fontFamily\\\":\\\"system-ui,\\\\\\\"Segoe UI\\\\\\\",Roboto,Helvetica,Arial,sans-serif,\\\\\\\"Apple Color Emoji\\\\\\\",\\\\\\\"Segoe UI Emoji\\\\\\\"\\\",\\\"height\\\":\\\"100vh\\\",\\\"textAlign\\\":\\\"center\\\",\\\"display\\\":\\\"flex\\\",\\\"flexDirection\\\":\\\"column\\\",\\\"alignItems\\\":\\\"center\\\",\\\"justifyContent\\\":\\\"center\\\"},\\\"children\\\":[\\\"$\\\",\\\"div\\\",null,{\\\"children\\\":[[\\\"$\\\",\\\"style\\\",null,{\\\"dangerouslySetInnerHTML\\\":{\\\"__html\\\":\\\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\\\"}}],[\\\"$\\\",\\\"h1\\\",null,{\\\"className\\\":\\\"next-error-h1\\\",\\\"style\\\":{\\\"display\\\":\\\"inline-block\\\",\\\"margin\\\":\\\"0 20px 0 0\\\",\\\"padding\\\":\\\"0 23px 0 0\\\",\\\"fontSize\\\":24,\\\"fontWeight\\\":500,\\\"verticalAlign\\\":\\\"top\\\",\\\"lineHeight\\\":\\\"49px\\\"},\\\"children\\\":\\\"404\\\"}],[\\\"$\\\",\\\"div\\\",null,{\\\"style\\\":{\\\"display\\\":\\\"inline-block\\\"},\\\"children\\\":[\\\"$\\\",\\\"h2\\\",null,{\\\"style\\\":{\\\"fontSize\\\":14,\\\"fontWeight\\\":400,\\\"lineHeight\\\":\\\"49px\\\",\\\"margin\\\":0},\\\"children\\\":\\\"This page could not be found.\\\"}]}]]}]}]],\\\"notFoundStyles\\\":[],\\\"styles\\\":null}]}]]}],null],null],\\\"couldBeIntercepted\\\":false,\\\"initialHead\\\":[false,\\\"$L6\\\"],\\\"globalErrorComponent\\\":\\\"$7\\\",\\\"missingSlots\\\":\\\"$W8\\\"}]]\\n\"])</script><script>self.__next_f.push([1,\"6:[[\\\"$\\\",\\\"meta\\\",\\\"0\\\",{\\\"name\\\":\\\"viewport\\\",\\\"content\\\":\\\"width=device-width, initial-scale=1\\\"}],[\\\"$\\\",\\\"meta\\\",\\\"1\\\",{\\\"charSet\\\":\\\"utf-8\\\"}],[\\\"$\\\",\\\"meta\\\",\\\"2\\\",{\\\"name\\\":\\\"next-size-adjust\\\"}]]\\n2:null\\n\"])</script></body></html>"

  47 |       expect(result).toContain('Client: index.default')
  48 |       expect(result).toContain('Client subpath: subpath.default')
> 49 |       expect(result).toContain('opt-out-react-version: 18.2.0')
     |                      ^
  50 |     })
  51 |   })
  52 |

  at toContain (e2e/app-dir/app-external/app-external.test.ts:49:22)
  at Object.<anonymous> (e2e/app-dir/app-external/app-external.test.ts:43:5)

Read more about building and testing Next.js in contributing.md.

pnpm test-start test/production/graceful-shutdown/index.test.ts

  • Graceful Shutdown > production (standalone mode) > should not accept new requests during shutdown cleanup > when there is no activity
Expand output

● Graceful Shutdown › production (standalone mode) › should not accept new requests during shutdown cleanup › when there is no activity

expect(received).toBe(expected) // Object.is equality

Expected: 0
Received: null

  228 |         // App finally shuts down
  229 |         await appKilledPromise
> 230 |         expect(app.exitCode).toBe(0)
      |                              ^
  231 |       })
  232 |     })
  233 |   }

  at Object.toBe (production/graceful-shutdown/index.test.ts:230:30)

Read more about building and testing Next.js in contributing.md.

@kdy1 kdy1 marked this pull request as draft April 25, 2024 03:18
@ijjk
Copy link
Member

ijjk commented Apr 25, 2024

Stats from current PR

Default Build
General Overall increase ⚠️
vercel/next.js canary vercel/next.js kdy1/acorn-bugs Change
buildDuration 25.6s 23.8s N/A
buildDurationCached 16.3s 11.2s N/A
nodeModulesSize 359 MB 359 MB ⚠️ +1.65 kB
nextStartRea..uration (ms) 679ms 677ms N/A
Client Bundles (main, webpack)
vercel/next.js canary vercel/next.js kdy1/acorn-bugs Change
139-HASH.js gzip 31.8 kB 31.8 kB N/A
2478adb3-HASH.js gzip 53.5 kB 53.5 kB N/A
4967-HASH.js gzip 5.1 kB 5.1 kB
6701.HASH.js gzip 168 B 168 B
framework-HASH.js gzip 45.2 kB 45.2 kB
main-app-HASH.js gzip 229 B 225 B N/A
main-HASH.js gzip 31.6 kB 31.6 kB N/A
webpack-HASH.js gzip 1.65 kB 1.64 kB N/A
Overall change 50.4 kB 50.4 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary vercel/next.js kdy1/acorn-bugs 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/acorn-bugs Change
_app-HASH.js gzip 194 B 193 B N/A
_error-HASH.js gzip 192 B 192 B
amp-HASH.js gzip 511 B 512 B N/A
css-HASH.js gzip 343 B 342 B N/A
dynamic-HASH.js gzip 2.52 kB 2.52 kB N/A
edge-ssr-HASH.js gzip 266 B 265 B N/A
head-HASH.js gzip 365 B 362 B N/A
hooks-HASH.js gzip 391 B 390 B N/A
image-HASH.js gzip 4.32 kB 4.31 kB N/A
index-HASH.js gzip 268 B 268 B
link-HASH.js gzip 2.69 kB 2.69 kB N/A
routerDirect..HASH.js gzip 328 B 328 B
script-HASH.js gzip 393 B 395 B N/A
withRouter-HASH.js gzip 323 B 323 B
1afbb74e6ecf..834.css gzip 106 B 106 B
Overall change 1.22 kB 1.22 kB
Client Build Manifests
vercel/next.js canary vercel/next.js kdy1/acorn-bugs Change
_buildManifest.js gzip 481 B 483 B N/A
Overall change 0 B 0 B
Rendered Page Sizes
vercel/next.js canary vercel/next.js kdy1/acorn-bugs Change
index.html gzip 528 B 529 B N/A
link.html gzip 540 B 540 B
withRouter.html gzip 523 B 524 B N/A
Overall change 540 B 540 B
Edge SSR bundle Size
vercel/next.js canary vercel/next.js kdy1/acorn-bugs Change
edge-ssr.js gzip 108 kB 108 kB N/A
page.js gzip 3.05 kB 3.05 kB N/A
Overall change 0 B 0 B
Middleware size
vercel/next.js canary vercel/next.js kdy1/acorn-bugs Change
middleware-b..fest.js gzip 623 B 621 B N/A
middleware-r..fest.js gzip 155 B 154 B N/A
middleware.js gzip 27.9 kB 27.9 kB N/A
edge-runtime..pack.js gzip 839 B 839 B
Overall change 839 B 839 B
Next Runtimes
vercel/next.js canary vercel/next.js kdy1/acorn-bugs Change
app-page-exp...dev.js gzip 171 kB 171 kB
app-page-exp..prod.js gzip 98.4 kB 98.4 kB
app-page-tur..prod.js gzip 99.9 kB 99.9 kB
app-page-tur..prod.js gzip 94.2 kB 94.2 kB
app-page.run...dev.js gzip 157 kB 157 kB
app-page.run..prod.js gzip 93 kB 93 kB
app-route-ex...dev.js gzip 21.4 kB 21.4 kB
app-route-ex..prod.js gzip 15.2 kB 15.2 kB
app-route-tu..prod.js gzip 15.2 kB 15.2 kB
app-route-tu..prod.js gzip 14.9 kB 14.9 kB
app-route.ru...dev.js gzip 21.3 kB 21.3 kB
app-route.ru..prod.js gzip 14.9 kB 14.9 kB
pages-api-tu..prod.js gzip 9.55 kB 9.55 kB
pages-api.ru...dev.js gzip 9.82 kB 9.82 kB
pages-api.ru..prod.js gzip 9.55 kB 9.55 kB
pages-turbo...prod.js gzip 21.4 kB 21.4 kB
pages.runtim...dev.js gzip 22.1 kB 22.1 kB
pages.runtim..prod.js gzip 21.4 kB 21.4 kB
server.runti..prod.js gzip 65.3 kB 65.3 kB
Overall change 975 kB 975 kB
build cache
vercel/next.js canary vercel/next.js kdy1/acorn-bugs Change
0.pack gzip 1.61 MB 1.61 MB N/A
index.pack gzip 113 kB 112 kB N/A
Overall change 0 B 0 B
Diff details
Diff for main-HASH.js

Diff too large to display

Commit: b2c108e

@kdy1 kdy1 marked this pull request as ready for review April 25, 2024 05:18
@ijjk
Copy link
Member

ijjk commented Apr 26, 2024

Would be good to add a regression test a follow-up

@ijjk ijjk enabled auto-merge (squash) April 26, 2024 04:51
@ijjk ijjk merged commit abe9526 into canary Apr 26, 2024
80 checks passed
@ijjk ijjk deleted the kdy1/acorn-bugs branch April 26, 2024 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants