Skip to content

Add support for both esm and cjs output using rollup bundler, update node to 21, replace mocha test runner with native node test runner#68

Closed
anthony-y-zhu14 wants to merge 2 commits intoolosegres:masterfrom
anthony-y-zhu14:feat/build-config-upgrade
Closed

Add support for both esm and cjs output using rollup bundler, update node to 21, replace mocha test runner with native node test runner#68
anthony-y-zhu14 wants to merge 2 commits intoolosegres:masterfrom
anthony-y-zhu14:feat/build-config-upgrade

Conversation

@anthony-y-zhu14
Copy link

@anthony-y-zhu14 anthony-y-zhu14 commented Mar 2, 2025

  • use rollup to produce both comonjs and esm output
  • remove mocha dependencies and use native node test runner
  • upversion dev dependencies to latest
  • update package-lock.json using node 21

output files:

.
├── LICENSE
├── README.md
├── README_0_2.md
├── lib
│   ├── Jsona.cjs
│   ├── Jsona.cjs.map
│   ├── Jsona.d.ts
│   ├── Jsona.js
│   ├── Jsona.js.map
│   ├── JsonaTypes.d.ts
│   ├── builders
│   │   ├── JsonDeserializer.cjs
│   │   ├── JsonDeserializer.cjs.map
│   │   ├── JsonDeserializer.d.ts
│   │   ├── JsonDeserializer.js
│   │   ├── JsonDeserializer.js.map
│   │   ├── ModelsSerializer.cjs
│   │   ├── ModelsSerializer.cjs.map
│   │   ├── ModelsSerializer.d.ts
│   │   ├── ModelsSerializer.js
│   │   ├── ModelsSerializer.js.map
│   │   ├── ReduxObjectDenormalizer.cjs
│   │   ├── ReduxObjectDenormalizer.cjs.map
│   │   ├── ReduxObjectDenormalizer.d.ts
│   │   ├── ReduxObjectDenormalizer.js
│   │   └── ReduxObjectDenormalizer.js.map
│   ├── cache.cjs
│   ├── cache.cjs.map
│   ├── cache.d.ts
│   ├── cache.js
│   ├── cache.js.map
│   ├── index.cjs
│   ├── index.cjs.map
│   ├── index.d.ts
│   ├── index.js
│   ├── index.js.map
│   ├── simplePropertyMappers.cjs
│   ├── simplePropertyMappers.cjs.map
│   ├── simplePropertyMappers.d.ts
│   ├── simplePropertyMappers.js
│   ├── simplePropertyMappers.js.map
│   ├── switchCasePropertyMappers.cjs
│   ├── switchCasePropertyMappers.cjs.map
│   ├── switchCasePropertyMappers.d.ts
│   ├── switchCasePropertyMappers.js
│   ├── switchCasePropertyMappers.js.map
│   ├── utils.cjs
│   ├── utils.cjs.map
│   ├── utils.d.ts
│   ├── utils.js
│   └── utils.js.map
├── package-lock.json
├── package.json
├── rollup.config.js
├── src
│   ├── Jsona.ts
│   ├── JsonaTypes.ts
│   ├── builders
│   │   ├── JsonDeserializer.ts
│   │   ├── ModelsSerializer.ts
│   │   └── ReduxObjectDenormalizer.ts
│   ├── cache.ts
│   ├── index.ts
│   ├── simplePropertyMappers.ts
│   ├── switchCasePropertyMappers.ts
│   └── utils.ts
├── tests
│   ├── Jsona.test.ts
│   ├── ModelsSerializer.test.ts
│   ├── ReduxObjectDenormalizer.test.ts
│   ├── mocks.ts
│   └── switchCasePropertyMappers.test.ts
└── tsconfig.json

- use rollup to produce both comonjs and esm output
- remove mocha dependencies and use native node test runner
- upversion dev dependencies to latest
- update package-lock.json using node 21
@anthony-y-zhu14 anthony-y-zhu14 changed the title feat: update node to 21, introduce rollup bundler to produce both commonjs and esm output for consumption, replace mocha test runner with native node test runner Add support for both esm and cjs output using rollup bundler, update node to 21, replace mocha test runner with native node test runner Mar 2, 2025
@anthony-y-zhu14
Copy link
Author

anthony-y-zhu14 commented Mar 2, 2025

this may also fix #66

@anthony-y-zhu14
Copy link
Author

@olosegres could you please review the changes to see if it's okay? I happy to explain our usecases but basically we are hoping to have a esm distribution of this library 🙂

@olosegres
Copy link
Owner

Thanks for the contribution! We've implemented dual ESM/CJS output in v1.13.0 with a similar approach but with some fixes:

  • main points to lib/index.cjs for CJS backward compatibility
  • Added module field for bundlers
  • Removed @types/mocha (not needed)
  • Node 22 LTS instead of 21 (EOL)
  • Removed importHelpers/tslib from runtime dependencies
  • Separate rollup plugin instances for ESM and CJS (avoids double declaration emit)

Closing in favor of the merged implementation.

@olosegres olosegres closed this Mar 14, 2026
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.

3 participants