Installation
Prerequisites
- Node.js 22.12 or later. CI tests on Node.js 22.12, 22, 24, and 26. A generator loads its parser
on first use through
require, and Node.js loads an ES module that way only from 22.12, so on 22.12 and later a value a generator returns is an instance of the parser classes your code imports, whether it usesimportorrequire. - A package manager: npm, pnpm, or Yarn.
Install the package and the parsers you need
@cosyte/synth builds each format through its sibling parser, and each parser is an optional peer
dependency. Install the package with the parsers for the formats you generate:
npm install @cosyte/synth @cosyte/hl7
| You import | Install alongside @cosyte/synth |
|---|---|
@cosyte/synth | nothing: the seeded generator, the value providers, and the checks |
@cosyte/synth/hl7 | @cosyte/hl7 |
@cosyte/synth/fhir | @cosyte/fhir |
@cosyte/synth/ccda | @cosyte/ccda |
@cosyte/synth/x12 | @cosyte/x12 |
@cosyte/synth/ncpdp | @cosyte/ncpdp |
@cosyte/synth/astm | @cosyte/astm |
@cosyte/synth/deid | @cosyte/deid, @cosyte/hl7, @cosyte/fhir, @cosyte/ccda, @cosyte/x12, and @cosyte/ncpdp |
The deid subpath loads all five parsers it pairs as soon as it is imported, so all five must be
installed even if you call only one of its loops. Each parser peer is declared at ^0.1, and
@cosyte/deid at ^0.1.5 || ^0.2.0, so either release line installs beside it.
To install every format at once:
npm install @cosyte/synth @cosyte/hl7 @cosyte/fhir @cosyte/ccda @cosyte/x12 @cosyte/ncpdp @cosyte/astm @cosyte/deid
The package has no third-party runtime dependencies. It ships ESM and CommonJS builds, each with its
own type declarations, so import and require both work without configuration.
Bundle an application that uses it
A bundler cannot follow the first-use load: the generator requires its parser at run time, by a
name the bundler does not see. If you bundle code that imports @cosyte/synth, mark
@cosyte/synth and each @cosyte/* parser you use as external, and install them in the
node_modules the bundle runs beside:
- esbuild:
--external:@cosyte/*, orexternal: ["@cosyte/*"]in the build options. - Rollup:
external: [/^@cosyte\//]; in Vite, the same underbuild.rollupOptions. - webpack: an
externalsentry for@cosyte/synthand for each@cosyte/*parser.
If the bundle inlines a parser while the generator loads the installed one, your code and the
generator hold two copies of that parser, and instanceof against its classes is false. If the
parser is not installed beside the bundle at all, the first generator call that needs it throws
"Cannot find module".
Check the install
import { VERSION } from "@cosyte/synth";
typeof VERSION; // => "string"
VERSION is the version of the package you installed, written from its manifest at release. The
check asserts its type rather than its value so this page never names a version.
To check a format subpath, generate one artifact from it:
import { generateAdt, roundTrip } from "@cosyte/synth/hl7";
roundTrip(generateAdt({ seed: 1 })).specClean; // => true
If the import fails with "Cannot find module", the parser for that subpath is missing; see Troubleshooting.
Next
The Quickstart generates a first message, draws a synthetic value, and builds a reproducible corpus.