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
The
preparescript inpackage.jsonishusky || true; npm run build, wherenpm run buildis justtsc. Aftertsc,dist/generated/containsAppearances.js,DdiMappings.js,TypeMappings.js— but notconventions.json, which exists insrc/generated/conventions.jsonand is imported bysrc/xlsform/validate.tsviaimport conventions from '"'"'../generated/conventions.json' with { type: '"'"'json' }'.tsconfig.jsonalready hasresolveJsonModule: trueandinclude: src/**/*, so the expectation that the JSON ships todist/is reasonable — but it does not.Reproduction
In any consumer that installs
@correlaid/formtransformfrom GitHub (e.g.CorrelAid/formtransform-app):Why this matters here
This blocks
CorrelAid/formtransform-appissue #4 (adding the library as a dependency). The app-sidebun installworks, thetscbuild of the lib runs without error, but the produceddist/is not a working browser bundle becausevalidate.jscannot resolve the JSON it imports at runtime. From the app's perspective, a clean install with a workingdist/is the acceptance criterion — and the handover doc explicitly forbids shimming this from the consumer side.Suggested fixes (upstream, your call)
buildscript (e.g.tsc && cp -r src/generated/*.json dist/generated/, or a smallnode ./scripts/copy-json.mjs); orimport ... with { type: '"'"'json' }'to inline the JSON viaimport attributes+ a build step that inlines the content; ordist/(as@correlaid/cdl-designdoes, in the same monorepo), which makes this build-script bug moot for consumers but requires keepingdist/in sync withsrc/.Whichever path, the deliverable from a consumer's point of view is the same:
node_modules/@correlaid/formtransform/dist/generated/conventions.jsonmust exist after a fresh install.Environment
@correlaid/formtransformHEAD (542badcas installed by the app)devDependencies)