Skip to content

tsc build does not emit dist/generated/conventions.json — prepare script leaves dist incomplete #1

Description

@jstet

The prepare script in package.json is husky || true; npm run build, where npm run build is just tsc. After tsc, dist/generated/ contains Appearances.js, DdiMappings.js, TypeMappings.js — but not conventions.json, which exists in src/generated/conventions.json and is imported by src/xlsform/validate.ts via import conventions from '"'"'../generated/conventions.json' with { type: '"'"'json' }'.

tsconfig.json already has resolveJsonModule: true and include: src/**/*, so the expectation that the JSON ships to dist/ is reasonable — but it does not.

Reproduction

In any consumer that installs @correlaid/formtransform from GitHub (e.g. CorrelAid/formtransform-app):

rm -rf node_modules/@correlaid/formtransform/dist
npm install   # or bun install + bun pm trust
ls node_modules/@correlaid/formtransform/dist/generated
# Appearances.js   DdiMappings.js   TypeMappings.js
# (no conventions.json)

# building the consumer:
npm run build
# → Could not resolve "../generated/conventions.json"
#   from "node_modules/@correlaid/formtransform/dist/xlsform/validate.js"

Why this matters here

This blocks CorrelAid/formtransform-app issue #4 (adding the library as a dependency). The app-side bun install works, the tsc build of the lib runs without error, but the produced dist/ is not a working browser bundle because validate.js cannot resolve the JSON it imports at runtime. From the app's perspective, a clean install with a working dist/ is the acceptance criterion — and the handover doc explicitly forbids shimming this from the consumer side.

Suggested fixes (upstream, your call)

  • Add a JSON-copy step to the build script (e.g. tsc && cp -r src/generated/*.json dist/generated/, or a small node ./scripts/copy-json.mjs); or
  • Switch the import ... with { type: '"'"'json' }' to inline the JSON via import attributes + a build step that inlines the content; or
  • Commit dist/ (as @correlaid/cdl-design does, in the same monorepo), which makes this build-script bug moot for consumers but requires keeping dist/ in sync with src/.

Whichever path, the deliverable from a consumer's point of view is the same: node_modules/@correlaid/formtransform/dist/generated/conventions.json must exist after a fresh install.

Environment

  • @correlaid/formtransform HEAD (542badc as installed by the app)
  • TypeScript 5.6.x (per devDependencies)
  • bun 1.3.10 / npm 10.x — same result on both

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions