Skip to content

quicktype-core: ship an ESM build with an 'exports' map (currently CJS-only) #2906

Description

@schani

Issue Type

Feature request / packaging: quicktype-core ships CommonJS only, no ESM build or exports map

Context (Environment, Version, Language)

CLI, npm, or app.quicktype.io: npm package quicktype-core
Version: 24.0.0

Description

quicktype-core@24.0.0 publishes only a CommonJS build:

{
  "main": "dist/index.js",
  "types": "dist/index.d.ts"
}
  • No "exports" map
  • No "module" / ESM entry point
  • No "type" field (defaults to CommonJS)

To be fair about the current state: in my testing this causes no runtime breakage on Node 20/22/24 — named imports like import { quicktype, InputData } from "quicktype-core" work from "type": "module" projects via Node's CJS interop (cjs-module-lexer), and moduleResolution: nodenext typechecks correctly. So this is a modernization request, not a "it's broken" report.

What consumers do lose without a real ESM build:

  • Tree-shaking: bundlers (esbuild, Rollup, webpack) treat the CJS build as opaque, so browser/edge consumers pull in the whole library even when using a single target language.
  • Conditional exports: no "exports" map means no way to route browser vs. node entry points (relevant since quicktype-core already depends on browser-or-node and has browser-specific code paths).
  • Named-import interop relies on cjs-module-lexer heuristics rather than being guaranteed by the module format.

Expected Behaviour / Output

Dual CJS/ESM publish (or ESM-only, given engines: ">=20"), with an "exports" map along the lines of:

{
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "import": "./dist/esm/index.js",
      "require": "./dist/index.js"
    }
  }
}

Current Behaviour / Output

CJS-only as described above.

Found while testing the 24.0.0 release on Node 20/22/24 in both CommonJS and "type": "module" TypeScript projects.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions