Skip to content

Suggestion: separate packages for prebuilt binaries. #6133

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

Closed
cometkim opened this issue Apr 11, 2023 · 4 comments · Fixed by #7395
Closed

Suggestion: separate packages for prebuilt binaries. #6133

cometkim opened this issue Apr 11, 2023 · 4 comments · Fixed by #7395
Labels
stale Old issues that went stale

Comments

@cometkim
Copy link
Member

The rescript package provides prebuilt binaries for major platforms.

Not relying on the postinstall hook is good, but it significantly increases package installation time. An additional 20-30MB of bandwidth per platform is required for it.

Installing binaries for not matched platforms is obviously unnecessary work, so users can skip close to 100MB of downloading by omitting 4 out of 5 supported platforms.

Thankfully Yarn & pnpm support feature for this (I'm not sure npm also does). They can skip installation if the os and cpu entries specified in the package.json do not match (and this behavior can be customized)

Packages using prebuilt bins like esbuild provide it separately in the form of @esbuild/{os}-{cpu} for this purpose.

So @esbuild/linux-x64's package.json:

{
  "name": "@esbuild/linux-x64",
  "version": "0.17.16",
  "description": "The Linux 64-bit binary for esbuild, a JavaScript bundler.",
  "repository": "https://github.com/evanw/esbuild",
  "license": "MIT",
  "preferUnplugged": true,
  "engines": {
    "node": ">=12"
  },
  "os": [
    "linux"
  ],
  "cpu": [
    "x64"
  ]
}

And esbuild's:

  "optionalDependencies": {
    "@esbuild/android-arm": "0.17.16",
    "@esbuild/android-arm64": "0.17.16",
    "@esbuild/android-x64": "0.17.16",
    "@esbuild/darwin-arm64": "0.17.16",
    "@esbuild/darwin-x64": "0.17.16",
    "@esbuild/freebsd-arm64": "0.17.16",
    "@esbuild/freebsd-x64": "0.17.16",
    "@esbuild/linux-arm": "0.17.16",
    "@esbuild/linux-arm64": "0.17.16",
    "@esbuild/linux-ia32": "0.17.16",
    "@esbuild/linux-loong64": "0.17.16",
    "@esbuild/linux-mips64el": "0.17.16",
    "@esbuild/linux-ppc64": "0.17.16",
    "@esbuild/linux-riscv64": "0.17.16",
    "@esbuild/linux-s390x": "0.17.16",
    "@esbuild/linux-x64": "0.17.16",
    "@esbuild/netbsd-x64": "0.17.16",
    "@esbuild/openbsd-x64": "0.17.16",
    "@esbuild/sunos-x64": "0.17.16",
    "@esbuild/win32-arm64": "0.17.16",
    "@esbuild/win32-ia32": "0.17.16",
    "@esbuild/win32-x64": "0.17.16"
  },

It is specified as optionalDependencies because it can be omitted depending on the environment.

As the result, when I run yarn add esbuild on my env, I can see yarn only install @esbuild/linux-x64 additionally

➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 3s 250ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ esbuild@npm:0.17.16 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ @esbuild/linux-x64@npm:0.17.16 can't be found in the cache and will be fetched from the remote registry
➤ YN0000: └ Completed in 2s 577ms

The downside of this approach is that it makes the release workflow more complex.

@cristianoc
Copy link
Collaborator

CC @cknitt

@cknitt
Copy link
Member

cknitt commented Apr 12, 2023

@cometkim Interesting, did not know about this. Thanks for the suggestion!

(Note that even though ReScript 11 has prebuilt binaries for more platforms than ReScript 10.1, the package size is still a lot smaller - 29.2 MB vs. 47.1 MB.)

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Old issues that went stale label Sep 14, 2024
@cometkim
Copy link
Member Author

cometkim commented Sep 19, 2024

Closing this as it duplicates #6183

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Old issues that went stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants