Skip to content

v4.0.0 — dual ESM + CommonJS, zero runtime deps

Latest

Choose a tag to compare

@danibram danibram released this 01 Jul 17:25

Modernizes the package to a dual ESM + CommonJS, zero-runtime-dependency build that runs natively in modern Node (>=20) and in the browser, keeping the generator-agnostic design (bring your own generator via addGenerator).

Both module systems work, resolved via conditional exports:

import mocker from 'mocker-data-generator'                // ESM / TypeScript
const mocker = require('mocker-data-generator').default   // CommonJS

This is a major (v4) because of the dependency majors (faker 10, TS 6, ava 8) and the raised engines floor (node >=20), not because of a module-format break — require() keeps working.

Distribution

  • "type": "module" + conditional exports (import → ESM, require → CJS), each with its own type declarations. Validated with @arethetypeswrong/cli (no problems across node10 / node16 CJS+ESM / bundler).
  • unpkg/jsdelivr → minified, self-contained ESM browser bundle (~7.5 kB, esbuild).
  • sideEffects: false.

Dependencies → latest

faker 8 → 10, TypeScript 4.9 → 6, ava 5 → 8, typedoc 0.23 → 0.28, chance, … tslib removed.

Toolchain (replaced dead/deprecated tools)

  • tslint + prettier → Biome
  • standard-version + conventional-github-releaser → changesets
  • nyc → c8 (native ESM coverage); tests run on TS via tsx
  • removed the deprecated codecov package

Fixes

  • Removed the now-unnecessary Array.prototype.includes polyfill.
  • Generator.custom now honors the documented adapter option (previously declared in the type but never invoked).

Full changeset: see CHANGELOG.md.