Skip to content

feat: on-demand binary download fallback for npm distribution#92

Merged
rhuanbarreto merged 2 commits into
mainfrom
feat/npm-binary-fallback-download
Mar 20, 2026
Merged

feat: on-demand binary download fallback for npm distribution#92
rhuanbarreto merged 2 commits into
mainfrom
feat/npm-binary-fallback-download

Conversation

@rhuanbarreto

Copy link
Copy Markdown
Contributor

Summary

  • When the platform-specific optional dependency is not installed (e.g. --no-optional, --ignore-scripts, strict lockfiles, CI quirks), the bin shim now downloads the correct binary from the npm registry on first run
  • Adds a three-layer resilience strategy for npm binary resolution:
    1. optionalDependencies — normal path via require.resolve()
    2. postinstall script — best-effort pre-warm that triggers the download during install (skipped silently if blocked)
    3. On-demand download in bin/archgate.cjs — ultimate fallback that fetches the platform tarball from registry.npmjs.org using only Node.js built-ins (https, zlib)
  • Based on the approach documented at https://sentry.engineering/blog/publishing-binaries-on-npm

Test plan

  • Install with npm install archgate — verify optional dep path works as before
  • Install with npm install --no-optional archgate — verify postinstall downloads binary
  • Install with npm install --ignore-scripts --no-optional archgate — verify first archgate --version triggers on-demand download
  • Verify download output goes to stderr and doesn't interfere with piped commands
  • Test on all three platforms (macOS arm64, Linux x64, Windows x64)

When the platform-specific optional dependency is not installed (e.g.
--no-optional, --ignore-scripts, strict lockfiles), the bin shim now
downloads the correct binary from the npm registry on first run.

Three-layer resilience:
1. optionalDependencies (normal path)
2. postinstall script (best-effort pre-warm)
3. On-demand download in bin/archgate.cjs (ultimate fallback)
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Mar 20, 2026

Copy link
Copy Markdown

Deploying archgate-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: 02f87ad
Status: ✅  Deploy successful!
Preview URL: https://762da0e8.archgate-cli.pages.dev
Branch Preview URL: https://feat-npm-binary-fallback-dow.archgate-cli.pages.dev

View logs

@rhuanbarreto rhuanbarreto force-pushed the feat/npm-binary-fallback-download branch from 234b8b6 to 77a2472 Compare March 20, 2026 14:28
The oniguruma WASM engine crashes with "call_indirect to a null table
entry" when Astro builds under Bun on Cloudflare Pages. Switch
expressive-code to the pure-JS regex engine which doesn't require WASM.
@rhuanbarreto rhuanbarreto merged commit c5512db into main Mar 20, 2026
9 checks passed
@rhuanbarreto rhuanbarreto deleted the feat/npm-binary-fallback-download branch March 20, 2026 14:40
@github-actions github-actions Bot mentioned this pull request Mar 20, 2026
rhuanbarreto added a commit that referenced this pull request Mar 20, 2026
* feat: on-demand binary download fallback for npm distribution

When the platform-specific optional dependency is not installed (e.g.
--no-optional, --ignore-scripts, strict lockfiles), the bin shim now
downloads the correct binary from the npm registry on first run.

Three-layer resilience:
1. optionalDependencies (normal path)
2. postinstall script (best-effort pre-warm)
3. On-demand download in bin/archgate.cjs (ultimate fallback)

* fix: use Shiki JS engine to avoid WASM crash on Cloudflare Pages

The oniguruma WASM engine crashes with "call_indirect to a null table
entry" when Astro builds under Bun on Cloudflare Pages. Switch
expressive-code to the pure-JS regex engine which doesn't require WASM.
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

Successfully merging this pull request may close these issues.

1 participant