Skip to content

fix(dead-export-finder): split CLI from library exports#52

Merged
ryanbas21 merged 1 commit into
mainfrom
fix/split-cli-from-library-export
May 14, 2026
Merged

fix(dead-export-finder): split CLI from library exports#52
ryanbas21 merged 1 commit into
mainfrom
fix/split-cli-from-library-export

Conversation

@ryanbas21
Copy link
Copy Markdown
Owner

Summary

  • Split src/index.ts into src/index.ts (pure library re-exports) and src/cli.ts (CLI entry point with shebang and NodeRuntime.runMain)
  • Updated package.json bin field to point to ./dist/cli.js instead of ./dist/index.js
  • exports/main/types unchanged — still point to ./dist/index.js

Previously, both bin and exports pointed to index.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, parsing process.argv and potentially setting process.exitCode = 1.

Test plan

  • pnpm build — clean compilation
  • pnpm test — 42/42 tests passing
  • pnpm lint — 0 errors
  • CLI --help works from dist/cli.js
  • Full monorepo E2E scan completes correctly via dist/cli.js
  • Library import from dist/index.js has no side effects (verified with dynamic import)
  • pnpm pack — clean tarball, no stale artifacts

🤖 Generated with Claude Code

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>
Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 from src/index.ts into src/cli.ts with a shebang
  • Update bin field in package.json — Points to ./dist/cli.js instead of the old ./dist/index.js
  • Retain index.ts as pure library barrel — Re-exports only; unchanged public API surface

Summary | 3 files | 1 commit | base: mainfix/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.

Pullfrog  | View workflow run𝕏

@ryanbas21 ryanbas21 merged commit 1136271 into main May 14, 2026
1 check passed
@ryanbas21 ryanbas21 deleted the fix/split-cli-from-library-export branch May 14, 2026 01:01
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.

1 participant