#27
feat: add CJS build for CommonJS compatibility
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 singlesrc/index.tsentry, withdtsand sourcemaps. Dependencies and peerDependencies are auto-externalized, so nothing is bundled (output stays the same size as the previoustscbuild).buildscript →tsup(still copiesAGENTS.mdintodist/).exports→ per-condition layout with separate types forimport(.d.ts) andrequire(.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 validatepasses: 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
3Could you re-push with signed commits?
TBH I don't quite understand how this is all that is needed :)
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
Security
View full report