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

Both gnu and musl core distributions installed for Ubuntu Linux #3652

Closed
JoshuaKGoldberg opened this issue Feb 20, 2022 · 7 comments
Closed
Labels

Comments

@JoshuaKGoldberg
Copy link

JoshuaKGoldberg commented Feb 20, 2022

Describe the bug

After npm i @swc/jest in a project, there are two core distributions available in node_modules:

$ du -sh node_modules/@swc/*
444K    node_modules/@swc/core
74M     node_modules/@swc/core-linux-x64-gnu
78M     node_modules/@swc/core-linux-x64-musl
24K     node_modules/@swc/jest

Input code

npm i @swc/jest

Config

n/a

Playground link

No response

Expected behavior

Both of these are >70M in size. Ideally only one would be installed at a time.

Actual behavior

Both packages have the same system dependencies listed in their package.json files:

{
  // ...
  "os": [
    "linux"
  ],
  "cpu": [
    "x64"
  ],
  // ...
}

...and so both get installed on Linux x64 systems.

Version

1.2.143

Additional context

I'm not familiar enough with npm/node OS & CPU identifiers to know whether a more granular description could be used. If there is, I would love to send a PR to fix this. 😄

If not, it might be the case that npm/rfcs#519 blocks a real resolution?

Context: typescript-eslint/tslint-to-eslint-config#1367. WSL 2.0 in an Ubuntu drive.

@kdy1 kdy1 added this to the v1.2.144 milestone Feb 21, 2022
@kdy1
Copy link
Member

kdy1 commented Feb 21, 2022

cc @Brooooooklyn Is there a way to fix this?

@Brooooooklyn
Copy link
Member

As mentioned above, we need to wait npm/rfcs#519 landed to fix this issue.
There is a workaround that may reduce the install size: vercel/next.js#32850

@erawk
Copy link

erawk commented Nov 10, 2022

Hey @kdy1 @Brooooooklyn - this is causing some NexJS deployment issues on Vercel, as reported in this issue

  1. Vercel uses Linux x64, so both @swc/core-linux-x64-(gnu|musl) folders are added
  2. In 13.0.2+ of NextJS, Prisma is added as an external and thus included in builds
  3. The combined weight of Prisma + 2x @swc/core exceeds the 50MB limit

Here's a screenshot from Vercel build log:

image

My current super hacky fix with gnarly consequences:

Add a postbuild.sh script that runs to zero-out the unnecessary musl version:

# Make the large files zero bytes for the `musl` SWC
echo "Nuking unnecessary @swc/core files in node_modules/@swc/core-linux-x64-musl"
DISK_USAGE_MUSL_BEFORE=`du -h node_modules/@swc/core-linux-x64-musl/*`
echo "${DISK_USAGE_MUSL_BEFORE}"
echo '' > node_modules/@swc/core-linux-x64-musl/swc
echo '' > node_modules/@swc/core-linux-x64-musl/swc.linux-x64-musl.node
DISK_USAGE_MUSL_AFTER=`du -h node_modules/@swc/core-linux-x64-musl/*`
echo "${DISK_USAGE_MUSL_AFTER}"

This gets us under the threshold but opens us up to failure if indeed musl is needed.

Are there any alternatives you suggest? Anything else downstream we can do to avoid this double inclusion?

@kylemh
Copy link

kylemh commented Dec 6, 2022

Screenshot 2022-12-07 at 12 08 23 AM

I'm really confused why all of the distributions are being included.

@kdy1
Copy link
Member

kdy1 commented Dec 7, 2022

This is not a bug of swc

@kdy1 kdy1 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 7, 2022
@kdy1 kdy1 reopened this Dec 7, 2022
@kwonoj
Copy link
Member

kwonoj commented Jul 24, 2023

npm/rfcs#438 (comment)

Latest npm claims this issue is fixed, so closing. In any case this is techinically pkg mgr issue.

@kwonoj kwonoj closed this as completed Jul 24, 2023
@swc-bot
Copy link
Collaborator

swc-bot commented Aug 24, 2023

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

7 participants