Skip to content

fix: declare ts-morph as a runtime dependency#498

Merged
nicola-smartive merged 1 commit into
mainfrom
fix/ts-morph-runtime-dependency
Jun 22, 2026
Merged

fix: declare ts-morph as a runtime dependency#498
nicola-smartive merged 1 commit into
mainfrom
fix/ts-morph-runtime-dependency

Conversation

@smartive-nicolai

Copy link
Copy Markdown
Contributor

Problem

gqm generate fails in consumers on 28.0.1 with:

Error: Cannot find module 'ts-morph'
  ... at /node_modules/@smartive/graphql-magic/dist/bin/gqm.cjs

Root cause

The gqm bin is bundled with esbuild --packages=external (build:bin), so its imports are resolved at runtime from the consumer's node_modules. ts-morph is imported across the bin (parse-models.ts, parse-knexfile.ts, parse-functions.ts, permissions.ts, static-eval.ts, visitor.ts, utils.ts) to parse the consumer's models.ts / knexfile.ts, so it is a runtime dependency.

Between 28.0.0 and 28.0.1 it was moved from dependencies to devDependencies (28.0.0 shipped ts-morph: ^27.0.2 under dependencies; 28.0.1 declares no ts-morph at all). Consumers install only production dependencies, so ts-morph is absent and gqm generate throws at module load.

The project's own CI doesn't catch this because it installs devDependencies, so ts-morph is always present in-repo.

Fix

Move ts-morph back to dependencies. Verified a production-only install now resolves it (npm ls ts-morph --omit=devts-morph@28.0.0); lint, unit tests, build and gqm generate all pass.

🤖 Generated with Claude Code

The `gqm` bin is bundled with esbuild `--packages=external`, so `ts-morph`
(used by `gqm generate` to parse models.ts / knexfile.ts) must resolve at
runtime in consumer installs. It had been moved to `devDependencies`, so a
consumer installing only production dependencies hits
`Error: Cannot find module 'ts-morph'` when running `gqm generate`. Move it
back to `dependencies` (where 28.0.0 had it).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@nicola-smartive nicola-smartive merged commit ae639c6 into main Jun 22, 2026
18 of 22 checks passed
@nicola-smartive nicola-smartive deleted the fix/ts-morph-runtime-dependency branch June 22, 2026 14:02
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 28.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant