Skip to content

build: publish the attw CLI as a self-contained binary - #10

Merged
ryanleecode merged 3 commits into
mainfrom
cli-fraud
Sep 11, 2026
Merged

ryanleecode merged 3 commits into
mainfrom
cli-fraud

Conversation

@systemfsoftware-maker

Copy link
Copy Markdown
Collaborator

Summary

Installing the CLI no longer drags its dependency tree into your project: attw now publishes as one self-contained binary, its manifest exposes only the bin entry, and the analyzer always runs the TypeScript it was built against rather than whichever version your tree hoisted. The command, its flags, and its output are unchanged.

What a consumer sees

  • npm install of the tarball adds exactly one package. Before, the CLI's five runtime dependencies — including the analyzer and a TypeScript compiler — resolved inside the consumer's node_modules, where dedupe or hoisting could hand the analysis a different version of either.
  • The download is now ~1.7 MB gzipped, most of it that compiler, against ~33 KB of CLI code before. Paid once, in exchange for no resolution at install time and a compiler pinned to the analyzer's own version.

Design decisions

  • Bundling is enforced, not asserted. The build fails when any bare import survives into the bundle, so a dependency left external stops pnpm build instead of shipping a binary that dies in a consumer's tree.
  • No runtime dependencies are declared. The former ones are build-time inputs now, kept in devDependencies for the workspace build.
  • The second entry point is gone. The build also emitted AttwHandler, a library entry nothing outside the package imported (checked across the workspace); the executable is the only artifact, and no exports map is published.

Related: #8, #9

Validation

  • pnpm check:ci — format, lint, typecheck, typecheck:node, tests, build, and mutation all green.
  • Packed tarball contains only dist/main.mjs, LICENSE, README.md, and package.json; installed into an empty project (npm install, one package added), where node_modules/.bin/attw --pack ran a real analysis on an ESM-only fixture and exited 1 on the expected CJS failure.
  • The same bundle ran with no node_modules present at all.
  • The enforcement was checked by leaving effect external: the build fails and names the offending import.

The published CLI declared five runtime dependencies and externalized them, so
installing it pulled the analyzer, effect, and a compiler into the consumer's
tree, and the analyzer ran whatever TypeScript the host hoisted.

Inline every dependency into the single dist/main.mjs entry, drop the library
entry for AttwHandler that nothing outside the package imports, and move the
former runtime dependencies to devDependencies. deps.onlyImport fails the build
if a bare import survives, so the manifest cannot drift from the bundle; the
inlined TypeScript is the analyzer's own pinned 6.0.3.

The published manifest now exposes only bin. Verified by packing, installing the
tarball in an empty project (npm adds exactly one package, then the bin link
resolves), and running attw --pack on an ESM-only fixture from the installed
binary
`prepare` ran tsdown on every `pnpm install`, before any package was built. The
bundle inlines the analyzer, so on a fresh clone the analyzer's dist/ did not
exist yet, rolldown left it external, and the onlyImport gate failed the install
with "@systemfsoftware/arethetypeswrong is imported in main.mjs but is not
included in deps.onlyImport option" — the Commitlint workflow's
`pnpm install --frozen-lockfile` broke on it.

turbo already orders this: every task that needs dist depends on `^build`, so
`pnpm build` builds the analyzer before the CLI. Install no longer builds, and
the bundle is produced by the task graph that knows the order
The note was added alongside the bundling change without being part of it. The
package page describes what the CLI does; what changed about its packaging
belongs to the release note
@ryanleecode
ryanleecode merged commit 6aa3aa3 into main Sep 11, 2026
3 checks passed
@ryanleecode
ryanleecode deleted the cli-fraud branch September 11, 2026 19:10
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