djt-codegen

raw JSON →
1.0.1 verified Fri May 01 auth: no javascript

A templated code generation tool for the Dart-to-JS-Transpiler (DJT) ecosystem. Current stable version 1.0.1, released occasionally. It generates JavaScript and TypeScript declaration files from a schema definition, targeting DJT transpilation workflows. Differentiates by providing a simple CLI for schema-to-output transformation with DTS support.

error Error: Cannot find module 'djt-codegen'
cause Package not installed or missing from node_modules.
fix
Run 'yarn add djt-codegen' or 'npm install djt-codegen'.
error SyntaxError: Unexpected token 'export'
cause Using CommonJS require with an ESM-only package.
fix
Use import syntax or update Node to version that supports ESM.
gotcha The -dts flag generates TypeScript definitions but may not cover all schema features.
fix Manually verify generated DTS files for completeness.
gotcha Schema file must be valid JavaScript exporting a schema object; JSON files not supported.
fix Ensure schema file uses module.exports = { ... } syntax.
npm install djt-codegen
yarn add djt-codegen
pnpm add djt-codegen

Shows CLI usage with schema input, JS output, and DTS generation; also demonstrates programmatic API if available.

// Run via CLI (recommended):
// yarn djt-codegen -s ./schema.js -o ./lib.js -dts ./lib.d.ts

// Or programmatically (if package exports API):
import { generate } from 'djt-codegen';
const fs = require('fs');
const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf8'));
generate({ schema, output: './lib.js', dts: './lib.d.ts' });