build: make the package npm-publishable#2
Open
alastor0325 wants to merge 1 commit into
Open
Conversation
Add a 'prepare' script (build dist/ before pack/publish and on git installs), a 'files' allowlist so the compiled output ships, an engines floor, and the MIT LICENSE file the package.json already declares. Enables 'npm i -g profiler-cli' instead of clone + build + link.
Contributor
Author
|
@dpalmeiro could you help to review this? Thanks! |
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.
Why
This comes from
fx-bug-toolkit, a Claude Code plugin for Firefox bug investigation that usesprofiler-clito power its/analyze-profilecommand. Today the toolkit has to install it viagit clone+npm run build+npm link, which is clunky for users — and because it pulls and builds code straight from a GitHub repo, Claude Code's auto-mode safety classifier blocks the agent from running it. We'd like to install it the normal way,npm i -g profiler-cli, which is simpler for everyone and is a plain registry install the classifier doesn't block. To do that, the package just needs to be publishable to npm — which is what this PR sets up.The problem
A plain
npm publishtoday would ship a broken package —dist/is git-ignored and there's no build-on-publish step, so thebintarget (./dist/index.js) wouldn't exist in the tarball.The changes
"prepare": "npm run build"— npm runs this beforepack/publish(and on git installs), sodist/is always built into the tarball."files": ["dist"]— ships the compiled output (npm also auto-includespackage.json,README.md,LICENSE)."engines": { "node": ">=18" }— declares the Node floor.LICENSE— adds the MIT license file the manifest already declares. Please confirm the copyright holder — I putdpalmeiroas a placeholder; set it to your name/preference.Verified with
npm pack --dry-run: tarball containsdist/index.js(+ the other compiled files),LICENSE,README.md,package.json.Not included
The Playwright Firefox runtime browser (
npx playwright install firefox) —npm installwon't fetch it. I'd suggest documenting it in the README rather than a heavypostinstall; happy to add either if you prefer.The actual
npm publishis yours to run (your npm account). If you'd like tagged releases to auto-publish, I can follow up with a small publish-on-tag GitHub Action (needs anNPM_TOKENrepo secret).