Skip to content

npm: replace postinstall download with platform-specific optional packages#1119

Merged
JohnnyMorganz merged 8 commits into
mainfrom
claude/analyze-stylua-deps-ACxIX
May 16, 2026
Merged

npm: replace postinstall download with platform-specific optional packages#1119
JohnnyMorganz merged 8 commits into
mainfrom
claude/analyze-stylua-deps-ACxIX

Conversation

@JohnnyMorganz
Copy link
Copy Markdown
Owner

@JohnnyMorganz JohnnyMorganz commented May 16, 2026

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

claude added 5 commits May 16, 2026 09:57
…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
@JohnnyMorganz JohnnyMorganz changed the title refactor(npm): replace postinstall download with platform-specific optional packages npmeplace postinstall download with platform-specific optional packages May 16, 2026
@JohnnyMorganz JohnnyMorganz changed the title npmeplace postinstall download with platform-specific optional packages npm: replace postinstall download with platform-specific optional packages May 16, 2026
claude added 3 commits May 16, 2026 14:16
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
@JohnnyMorganz JohnnyMorganz merged commit f8ad1f4 into main May 16, 2026
21 checks passed
@JohnnyMorganz JohnnyMorganz deleted the claude/analyze-stylua-deps-ACxIX branch May 16, 2026 14:27
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.

2 participants