Skip to content

Comments

Support TypeScript with dual CJS/ESM#45

Open
Nelie-Taylor wants to merge 4 commits intoklughammer:masterfrom
huongda-group:master
Open

Support TypeScript with dual CJS/ESM#45
Nelie-Taylor wants to merge 4 commits intoklughammer:masterfrom
huongda-group:master

Conversation

@Nelie-Taylor
Copy link

Description:

Summary

  • Rewrote source from JavaScript to TypeScript (src/charset.ts, src/index.ts)
  • Added tsup build producing dual CommonJS (dist/index.js) + ES Module (dist/index.mjs) output
  • Ship TypeScript declarations (dist/index.d.ts, dist/index.d.mts) — no @types package needed
  • Exported GenerateOptions interface and CharsetType type for consumers
  • Added exports map in package.json for proper CJS/ESM resolution
  • Fully backwards compatible — require('randomstring').generate() works as before

Changes

  • lib/*.jssrc/*.ts (deleted old JS source)
  • index.js removed (replaced by dist/ build output)
  • bin/randomstring updated to require from dist/
  • Added tsconfig.json, tsup.config.ts
  • Added CJS and ESM import tests (test/cjs.js, test/esm.mjs)
  • Updated README with ESM usage example

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