Skip to content

Fixed generate-data CLI failing to load TypeScript modules#28413

Merged
9larsons merged 1 commit into
mainfrom
fix-generate-data-ts-loader
Jun 8, 2026
Merged

Fixed generate-data CLI failing to load TypeScript modules#28413
9larsons merged 1 commit into
mainfrom
fix-generate-data-ts-loader

Conversation

@9larsons

@9larsons 9larsons commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

pnpm reset:data broke after #28388 converted the topological-sort seeder utility to TypeScript.

The generate-data/repl/timetravel CLI commands run via bare node index.js, which has no TypeScript resolution — unlike pnpm dev (nodemon --import=tsx) or the production build (tsc). So require('./utils/topological-sort') failed with Cannot find module.

These commands are dev/local-only, where tsx is always installed. Registering the tsx CommonJS loader at the CLI dispatch point lets them require .ts files regardless of how they're invoked, covering all three reset:data* scripts and the VS Code task.

ref #28388

- the topological-sort utility was converted to TypeScript in #28388, but the generate-data/repl/timetravel CLI commands run via bare `node index.js`, which has no TS resolution (unlike `pnpm dev`'s nodemon --import=tsx or the production tsc build)
- this broke `pnpm reset:data` with "Cannot find module './utils/topological-sort'"
- registering the tsx CommonJS loader at the CLI dispatch point lets these dev-only commands require .ts files regardless of how they are invoked
@9larsons 9larsons enabled auto-merge (squash) June 8, 2026 14:16
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c122e8dd-8f44-4bbf-9db8-b33e9c3287cc

📥 Commits

Reviewing files that changed from the base of the PR and between 049e4e2 and ebae1ef.

📒 Files selected for processing (1)
  • ghost/core/core/cli/command.js

Walkthrough

This change adds a single-line require statement to register the tsx CommonJS loader at the top of ghost/core/core/cli/command.js. The registration enables development-only CLI commands executed via node index.js <command> to require and load TypeScript modules directly. No command logic, control flow, or exported APIs were modified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: registering the tsx CommonJS loader to fix CLI commands failing to load TypeScript modules, which directly addresses the issue described in the PR objectives.
Description check ✅ Passed The description is directly related to the changeset, clearly explaining the problem (TypeScript modules not loading in CLI commands after PR #28388), the context (dev/local-only workflows), and the solution (registering tsx CommonJS loader).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-generate-data-ts-loader

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@9larsons 9larsons merged commit ebdc21c into main Jun 8, 2026
50 checks passed
@9larsons 9larsons deleted the fix-generate-data-ts-loader branch June 8, 2026 14:35
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.

2 participants