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

Support installing binaries for multiple platforms #2898

Closed
jacobjove opened this issue Nov 27, 2021 · 6 comments
Closed

Support installing binaries for multiple platforms #2898

jacobjove opened this issue Nov 27, 2021 · 6 comments

Comments

@jacobjove
Copy link

Describe the feature

It would be great if SWC could optionally be installed for multiple platforms at the same time by specifying the binary targets (e.g., MacOS and Linux).

My use case: I have a NextJS application running in Docker. In dev environment, I use a volume for node_modules so that when I install a package in the project on my MacBook, the package is also added in the development container without me having to rebuild the container or run something like docker compose exec nextjs npm i <package>. This has worked well for me and is very convenient. However, currently, it does not work for SWC; if I run npm i -D @swc/cli @swc/core on my MacBook, it uses the binary for MacOS, so the Linux-based container does not get what it needs.

Here's an example of a similar feature that I use for Prisma:
https://www.prisma.io/docs/concepts/components/prisma-schema/generators#binary-targets

Babel plugin or link to the feature description

No response

Additional context

No response

@Brooooooklyn
Copy link
Member

Brooooooklyn commented Nov 30, 2021

@iacobfred you can just run npm install --ignore-platform to install all the platforms binary

Sorry, --ignore-platform is only worked for yarn

@nradulaski-godaddy
Copy link

Resolved it by adding it as optional dependency:

   "optionalDependencies": {
        "@swc/core-linux-x64-musl": "~1.2.143"
    }

@laytong
Copy link

laytong commented Jul 11, 2022

It looks like esbuild already supports this behaviour

i think by the way they generate their postinstall install.js file
https://github.com/evanw/esbuild/blob/79a35122062c8e99bf9ab62f03fbafa641139e15/scripts/esbuild.js

It would be great if we could fix this to support multiplatform zero installs with yarn berry

@laytong
Copy link

laytong commented Jul 11, 2022

update

Looks like it does work as long as you specify all of supportedArchitectures details in your .yarnrc.yml

not just say os

e.g.

supportedArchitectures:
  os:
    - darwin
    - linux
  cpu:
    - x64
  libc:
    - glibc

will install
@swc-core-darwin-x64-npm-1.2.210
@swc-core-linux-x64-gnu-npm

Initially hadn't specified glibc and the linux optional dep wouldn't install

It'd be great if this could support zero installs based on the supportedArchitectures

@kwonoj
Copy link
Member

kwonoj commented Jul 26, 2023

I'm inclined to leave this to upstream support : npm/rfcs#612

Techinincally instead of the way swc/core currently distributes binary (optionalDependencies) we could implement own download logics, but that's not an easy to get it right without error. As commented yarn have support, and if npm got an equivalent support this'll be resolved naturally.

@kwonoj kwonoj closed this as not planned Won't fix, can't repro, duplicate, stale Jul 26, 2023
@swc-bot
Copy link
Collaborator

swc-bot commented Aug 26, 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 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

7 participants