cosmo icon indicating copy to clipboard operation
cosmo copied to clipboard

feat: standalone binary distributions for `wgc`

Open samjcombs opened this issue 1 year ago • 1 comments

Motivation and Context

In enterprise settings, installing a cli via npm globally isnt always possible. Potential blockers include:

  • complete lack of familiarity with npm ecosystem (android, ios app teams, service teams, etc)
  • conflicts with existing node ecosystem (perhaps teams are forced to use node14 or otherwise have conflicting dependencies)

Generally it is industry standard to offer cli tools in standalone binaries.

Details

Implementation is using vercel/pkg to produce the binaries.

While there are a few options for modern node binary distribution (deno, bun, node-22), pkg allows for easy export of cross-platform node16 binaries without fundamentally altering the runtime.

NOTICE: pkg is deprecated as of early 2024 as the maintainer couldnt keep up with the ecosystem. Case in point, pkg offers no support for es6 modules.

Luckily, there is a workaround.

The workaround involves using rollup to bundle the output into a single .cjs file.

Rollup doesn't seem to support top-level await so I made IIFEs out of of the two top-level awaits in the in the package.

TODO

  • [ ] Update stub URLS in install scripts with real release locations
  • [ ] Develop github workflow to build binaries in CI/CD pipeline
  • [ ] Tests or benchmark included
  • [ ] Documentation is changed or added on https://app.gitbook.com/
  • [ ] PR title must follow conventional-commit-standard

samjcombs avatar May 16 '24 13:05 samjcombs

One of my outstanding questions with the native Node SEA approach was cross platform executable support. Also, last time I checked it was still a preview feature, but since Node-22 is available as current as of 2 weeks ago and it looks like it supports cross platform executable generation, using native SEA approach would be the ideal path.

The above pkg method could be used as a stopgap until wgc is tested/upgraded to support node-22.

samjcombs avatar May 16 '24 21:05 samjcombs

This PR was marked stale due to lack of activity. It will be closed in 14 days.

github-actions[bot] avatar May 31 '24 05:05 github-actions[bot]

Closed as inactive. Feel free to reopen if this PR is still being worked on.

github-actions[bot] avatar Jun 15 '24 05:06 github-actions[bot]