npm: replace postinstall download with platform-specific optional packages#1119
Merged
Conversation
…tional packages Eliminates all 5 npm dependencies (92 transitive packages) and the recurring dependabot noise they generate. npm now installs only the pre-built binary for the current platform via optionalDependencies, matching the pattern used by esbuild, Biome, and Prettier. - Add five platform packages under stylua-npm-bin/platforms/ - Simplify run.js to resolve the binary from the installed platform package - Remove binary.js / install.js / uninstall.js and their postinstall hooks - Update release workflow to wait for all binaries, then publish each platform package before publishing the main package - Update CI smoke test to download the released binary, pack the platform package locally, and install it via file: reference for testing
Replaces the 1,691-line lockfile for 92 packages with a 26-line lockfile reflecting the zero-dependency main package.
spawnSync defaults cwd to process.cwd() so the explicit arg was noise. result.status is null when the child is signal-killed; process.exit(null) coerces to 0, hiding the failure — use ?? 1 as fallback.
- Add publishConfig (access:public, provenance:true) to all packages, replacing --access public CLI flags and enabling SLSA provenance - Add files:["run.js"] to main package to prevent platforms/ directories (with extracted binaries) from landing in the published tarball - Add preferUnplugged:true to platform packages for Yarn PnP compatibility - Use process.exitCode instead of process.exit() for the final exit, allowing cleanup handlers to run (matches Biome pattern) - Remove package-lock.json from git (no deps to lock; esbuild/biome don't commit one either); add stylua-npm-bin/.gitignore - Update release.py: drop npm install step and lock file from git add, add platform package.json files to version bump and git add - Update CHANGELOG.md - Rewrite smoketest to install both packages into a fresh test-install/ directory, mirroring how a real user install looks (sibling packages in node_modules/), and test via the npm bin symlink
- Consolidate five per-platform .gitignore files into one stylua-npm-bin/.gitignore - Simplify smoketest download to a single bash step (Windows runners support bash) - Use npx to invoke stylua in smoketest instead of reaching into node_modules/.bin - Tighten CHANGELOG wording
Running two separate npm install commands caused npm 7+ to prune the platform package during the second install: when building the ideal tree for the main package with --no-optional, the already-installed platform package appeared extraneous and was removed. Installing both packages together in one command keeps both in the ideal tree so npm doesn't prune the platform binary. https://claude.ai/code/session_01BHixnLU6KwGZh8gXsFBzGi
The os/cpu fields on the platform packages already prevent npm from installing mismatched platform packages; on a macOS arm64 runner, only @johnnymorganz/stylua-bin-darwin-arm64 matches. The explicitly provided $PLATFORM_TGZ satisfies that optional dependency locally, so no registry lookup is needed. optionalDependencies failures are non-fatal anyway. Removing --no-optional also clears the deprecation warning (replaced by --omit=optional in npm 7+). https://claude.ai/code/session_01BHixnLU6KwGZh8gXsFBzGi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Eliminates all 5 npm dependencies (92 transitive packages) and the recurring dependabot noise they generate. npm now installs only the pre-built binary for the current platform via optionalDependencies, matching the pattern used by esbuild, Biome, and Prettier.