Skip to content

build(assets): copy contractErrors and schemas into dist on build (closes #932) - #936

Open
mopxam-art wants to merge 1 commit into
Heliobond:mainfrom
mopxam-art:fix/copy-build-json-assets
Open

mopxam-art wants to merge 1 commit into
Heliobond:mainfrom
mopxam-art:fix/copy-build-json-assets

Conversation

@mopxam-art

Copy link
Copy Markdown

Why

TypeScript (tsc) compiles .ts files to .js in dist but does not copy static JSON assets (src/data/contractErrors.json, src/schemas/creator-application.schema.json). In Docker production builds where only dist/ is copied into the runtime stage, importing src/lib/contractErrors throws MODULE_NOT_FOUND at boot time.

What

  • Created asset copy helper scripts/copy-assets.cjs that copies src/data/, src/schemas/, and src/config/ JSON files into dist/.
  • Updated package.json build script to chain asset copying: "build": "tsc && node scripts/copy-assets.cjs".
  • Added COPY scripts ./scripts in Dockerfile builder stage so assets are populated during container image builds.
  • Added comprehensive unit test suite in src/__tests__/buildAssets.test.ts verifying asset presence, schema validation, and error decoding against compiled dist output.

Verified

  • All unit tests pass (npx jest src/__tests__/buildAssets.test.ts --forceExit, 102 tests pass).
  • Clean TypeScript typecheck (npm run typecheck) and linter (npm run lint).
  • Runtime verification: node -e "require('./dist/lib/contractErrors')" succeeds cleanly.

Closes #932

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Production build is missing JSON assets: tsc does not copy contractErrors.json (or schemas/) into dist, so the image crashes at import

1 participant