chore: add CommonJS export and main; bump version to 1.1.2#1323
chore: add CommonJS export and main; bump version to 1.1.2#1323parirox wants to merge 2 commits into
Conversation
|
Thanks for tackling #1322. The current change is not enough yet because it only advertises a CommonJS entry, but does not actually build one.
I verified this on the PR branch: npm ci
npm pack --dry-run
node -e "require('node-telegram-bot-api')"The packed files include So CommonJS users would still be broken, just with The fix needs to generate a real CJS artifact and test it. Two reasonable options:
If we are okay with CommonJS consumers using either of these shapes: const { TelegramBot } = require('node-telegram-bot-api');
// or
const TelegramBot = require('node-telegram-bot-api').default;then no compatibility wrapper is needed. But the README example in this PR should use one of those forms instead of Also, since the PR bumps |
|
Closed by #1325 |
npm run test:node:unit)npm run test:node:integration)npm run typecheckis cleandoc/api.mdis up to date (bun run generate:docsleaves no diff — required when aTelegramBotmethod signature changed)Description
Adds a CommonJS build entry (
./dist/index.cjs) and arequirecondition to theexportsfield, so the package works as a dual ESM/CJS module. Also setsmainto the CJS build for legacy tooling compatibility and bumps the version to1.1.2.This unblocks NestJS users and any other CJS consumer (e.g. Jest with default config) from upgrading to v1, who currently hit
ERR_PACKAGE_PATH_NOT_EXPORTEDat runtime.References
Running the test suite
...