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

@swc/core installing two distributions #1161

Closed
1 task done
privatenumber opened this issue Aug 16, 2023 · 3 comments
Closed
1 task done

@swc/core installing two distributions #1161

privatenumber opened this issue Aug 16, 2023 · 3 comments

Comments

@privatenumber
Copy link

privatenumber commented Aug 16, 2023

Describe the bug

When installing @swc/core it seems to install two distributions: @swc/core-linux-x64-musl and @swc/core-linux-x64-gnu, inflating the install size to 100MB+:
https://pkg-size.dev/@swc%2Fcore

I'm wondering if this is a limitation in the environment WebContainers mock, or in swc's postinstall script.

Link to the blitz that caused the error

https://pkg-size.dev/@swc%2Fcore

Sorry, I don't have a Stackblitz reproduction since I wasn't sure how to quickly measure the node_modules size but pkg-size.dev does a plain and simple npm install on WebContainers.

Steps to reproduce

See link

Expected behavior

Locally, when I install @swc/core, it's about 35MB.

Ideally it just installs one distribution.

Parity with Local

Screenshots

No response

Platform

No response

Additional context

privatenumber/pkg-size.dev#21

As a side, wondering how esbuild's postinstall is executed in WebContainers. It felt like there was some custom logic overwriting it to force install the WASM distribution but I wasn't sure. Seems two distributions are installed too: wasm & linux-x64

Is there something swc could do in their postinstall script to play nicely with WebContainers?

@privatenumber privatenumber changed the title @swc/core installing more than it needs to @swc/core installing two distributions Aug 16, 2023
@privatenumber
Copy link
Author

privatenumber commented Aug 16, 2023

Did some research. There's actually no bug here.

npm installs optionalDependencies based on this criteria. However, npm v9.4.2 (used by WebContainers) doesn't support looking at the libc property. Which led to installing distributions that match up until the libc property:

Currently, all package managers support libc:

However, WebContainers does not have npm v9.6.5 yet. Is there a ballpark timeline for when I can expect npm to be upgraded?

As a potential solution on my end, I could either swap npm to use pnpm/yarn. Or perform a post-installation step to remove any packages with libc !== 'gnu'.

@Nemikolh
Copy link
Member

Hey @privatenumber! Thanks a lot for investigating this. 😃 (Love the links in particular, super useful 🙏)

I can't give you a precise timeline yet but we will definitely upgrade npm to the latest version in the next couple of months or so. It might be coming sooner but we're focusing first on other things such as upgrading to node 18.

@privatenumber
Copy link
Author

Good to know! I'll implement something on my end then. Thanks!

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

No branches or pull requests

2 participants