#27

feat: add CJS build for CommonJS compatibility

Openobs-gh-trevorColbywants to merge intofrom

Add CJS build for CommonJS compatibility

Fixes #15

Consuming bash-tool from a CommonJS context (e.g. require(), or tsx running in CJS mode) currently fails with ERR_PACKAGE_PATH_NOT_EXPORTED because the package only exports an "import" condition.

This adds a dual ESM+CJS build via tsup:

  • tsup.config.ts — emits ESM + CJS from the single src/index.ts entry, with dts and sourcemaps. Dependencies and peerDependencies are auto-externalized, so nothing is bundled (output stays the same size as the previous tsc build).
  • build script → tsup (still copies AGENTS.md into dist/).
  • exports → per-condition layout with separate types for import (.d.ts) and require (.d.cts), the canonical dual-package shape.

No code-splitting is required for this single-entry library, so the CJS constraint that makes a just-bash CJS build difficult (per #15) doesn't apply here.

Verification

  • @arethetypeswrong/cli — all green (node10, node16 CJS/ESM, bundler)
  • pnpm validate passes: lint, knip, typecheck, build, 152/152 tests

Note

The pnpm-lock.yaml diff is large because adding tsup pulls in its dependency tree — expected for a lockfile.

Activity

3
socket-security[bot]5mo ago
cramforce5mo ago

Could you re-push with signed commits?

TBH I don't quite understand how this is all that is needed :)