fix(dead-export-finder): split CLI from library exports#52
Merged
Conversation
The bin and exports fields both pointed to index.js, which contained top-level CLI side effects (NodeRuntime.runMain). Importing the package programmatically would trigger CLI execution and potentially set process.exitCode. Move CLI into dedicated cli.ts so index.ts is a pure re-export module with no side effects. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
No new issues found.
TL;DR — Mechanical refactor splitting the CLI entry point from library exports so that programmatic imports of @wolfcola/dead-export-finder no longer trigger NodeRuntime.runMain as a side effect.
Key changes
- Move CLI implementation to dedicated
cli.ts— All CLI code (command definition, options, pipeline stages, error handling,NodeRuntime.runMain) extracted fromsrc/index.tsintosrc/cli.tswith a shebang - Update
binfield inpackage.json— Points to./dist/cli.jsinstead of the old./dist/index.js - Retain
index.tsas pure library barrel — Re-exports only; unchanged public API surface
Summary | 3 files | 1 commit | base: main ← fix/split-cli-from-library-export
Both lenses (correctness, impact) confirmed the split is complete: no CLI code remains in index.ts, tsconfig.lib.json's include: ["src/**/*.ts"] covers the new file, package.json files: ["dist"] includes the compiled output, and no stale references to the old entry point exist anywhere in the repo. Pre-existing Scope LSP noise in test files is unrelated.
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.

Summary
src/index.tsintosrc/index.ts(pure library re-exports) andsrc/cli.ts(CLI entry point with shebang andNodeRuntime.runMain)package.jsonbinfield to point to./dist/cli.jsinstead of./dist/index.jsexports/main/typesunchanged — still point to./dist/index.jsPreviously, both
binandexportspointed toindex.js, which had top-level side effects (NodeRuntime.runMain). Anyone importing the package programmatically (e.g.import { Reporter } from '@wolfcola/dead-export-finder') would inadvertently trigger CLI execution, parsingprocess.argvand potentially settingprocess.exitCode = 1.Test plan
pnpm build— clean compilationpnpm test— 42/42 tests passingpnpm lint— 0 errors--helpworks fromdist/cli.jsdist/cli.jsdist/index.jshas no side effects (verified with dynamic import)pnpm pack— clean tarball, no stale artifacts🤖 Generated with Claude Code