Skip to content

Large bundle size as of NextJS 13.0.2 due to Prisma + 2x @swc/core (musl + gnu) #42641

Closed
@erawk

Description

@erawk

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

This is from a Vercel build. I've added the output below:


> my-app@0.1.2 next:info
--
11:16:16.723 | > next info
11:16:16.723 |  
11:16:17.698 |  
11:16:17.699 | Operating System:
11:16:17.699 | Platform: linux
11:16:17.699 | Arch: x64
11:16:17.699 | Version: #1 SMP Thu Sep 29 01:01:23 UTC 2022
11:16:17.699 | Binaries:
11:16:17.699 | Node: 14.20.0
11:16:17.699 | npm: 8.11.0
11:16:17.699 | Yarn: 1.22.17
11:16:17.699 | pnpm: 6.35.0
11:16:17.700 | Relevant packages:
11:16:17.700 | next: 13.0.3-canary.1
11:16:17.700 | eslint-config-next: 13.0.2
11:16:17.700 | react: 18.2.0
11:16:17.700 | react-dom: 18.2.0

All serverless functions suffer this. Here's an example:

Warning: Max serverless function size of 50 MB compressed or 250 MB uncompressed reached
--
11:16:47.301 | Serverless Function's page: 404.js
11:16:47.307 | Large Dependencies                     Uncompressed size  Compressed size
11:16:47.308 | node_modules/.prisma/client                      44.9 MB          15.6 MB
11:16:47.308 | node_modules/@swc/core-linux-x64-gnu             43.1 MB          14.4 MB
11:16:47.308 | node_modules/@swc/core-linux-x64-musl            42.7 MB          14.3 MB
11:16:47.308 | node_modules/next/dist                            8.2 MB          2.19 MB
11:16:47.308 | node_modules/webpack/lib                          3.3 MB           848 kB
11:16:47.308 | node_modules/react-dom/cjs                       1.72 MB           414 kB
11:16:47.308 | node_modules/@prisma/client                      1.23 MB           267 kB
11:16:47.308 | node_modules/terser/dist                          959 kB           183 kB
11:16:47.308 | node_modules/libphonenumber-js/build              355 kB           118 kB
11:16:47.309 | node_modules/libphonenumber-js/es6                326 kB           108 kB
11:16:47.309 | .next/server/chunks                               469 kB           108 kB
11:16:47.309 | node_modules/webpack/schemas                      559 kB          87.8 kB

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

Our NextJS on Vercel no longer are deployable as of NextJS 13.0.2 due to exceeding the max payload size of Serverless functions.

Here's an example of the basic 404 page (which does not do any Prisma-related queries):

Warning: Max serverless function size of 50 MB compressed or 250 MB uncompressed reached
--
11:16:47.301 | Serverless Function's page: 404.js
11:16:47.307 | Large Dependencies                     Uncompressed size  Compressed size
11:16:47.308 | node_modules/.prisma/client                      44.9 MB          15.6 MB
11:16:47.308 | node_modules/@swc/core-linux-x64-gnu             43.1 MB          14.4 MB
11:16:47.308 | node_modules/@swc/core-linux-x64-musl            42.7 MB          14.3 MB
11:16:47.308 | node_modules/next/dist                            8.2 MB          2.19 MB
11:16:47.308 | node_modules/webpack/lib                          3.3 MB           848 kB
11:16:47.308 | node_modules/react-dom/cjs                       1.72 MB           414 kB
11:16:47.308 | node_modules/@prisma/client                      1.23 MB           267 kB
11:16:47.308 | node_modules/terser/dist                          959 kB           183 kB
11:16:47.308 | node_modules/libphonenumber-js/build              355 kB           118 kB
11:16:47.309 | node_modules/libphonenumber-js/es6                326 kB           108 kB
11:16:47.309 | .next/server/chunks                               469 kB           108 kB
11:16:47.309 | node_modules/webpack/schemas                      559 kB          87.8 kB

Why are two versions of SWC core being included? I think that's the main culprit.

Here is an open ticket in the SWC project that highlights how both gnu and musl libraries are included. Is there anything we can do to pick a single one for Vercel builds?

I noticed in the 13.02 release notes that Prisma being added to externals list. Could this be a side effect as well?

Expected Behavior

Serverless functions do not include both gnu and musl and do not exceed the threshold for deployment on Vercel.

NextJS version 13.0.1 succeeds.

Link to reproduction

https://github.com/erawk/next-app-bug-report-serverless-functions-payload-size

To Reproduce

  1. Create a new NextJS app
  2. Add in Prisma with a basic schema
  3. Build a serverless function page
  4. Observe both Prisma, @swc/core for both musl and gnu included

Screen Shot 2022-11-08 at 12 29 27

NEXT-1356

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pages RouterRelated to Pages Router.SWCRelated to minification/transpilation in Next.js.linear: nextConfirmed issue that is tracked by the Next.js team.locked

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions