Skip to content

Added source export condition so ghost/core reads Koenig packages build-free - #29198

Merged
acburdine merged 2 commits into
mainfrom
koenig-source-export-condition
Jul 9, 2026
Merged

Added source export condition so ghost/core reads Koenig packages build-free#29198
acburdine merged 2 commits into
mainfrom
koenig-source-export-condition

Conversation

@acburdine

Copy link
Copy Markdown
Member

Cross-workspace requires forced a tsc build of every kg-* package before ghost/core could require them — a source change in a Koenig package wasn't visible in dev until you rebuilt it. This wires up the same build-free dev pattern already used by ghost/parse-email-address.

What changed

  • Adds a "source" exports condition pointing at ./src/*.ts to the 10 kg-* packages in ghost/core's runtime closure, ahead of types/import/require:

    ".": {
      "source": "./src/index.ts",     // dev/test: raw TS
      "types": "./build/esm/index.d.ts",
      "import": "./build/esm/index.js",
      "require": "./build/cjs/index.js" // prod/published: compiled JS
    }
  • Drops the now-redundant hardcoded kg-* build list from the docker:up nx target in the root package.json, so pnpm dev boots without building Koenig.

  • Documents the convention in AGENTS.md.

Why it's safe

  • ghost/core already runs its dev + test lanes with --conditions=source --import=tsx (nodemon.json + vitest.config.ts/vitest.config.db.ts), so it now resolves these packages to raw TS with no build step.
  • Plain node in prod/CI and the published npm tarball ignore the source condition and use build/; src/ stays out of each package's files array, so published output is unchanged.
  • The ^build nx graph is untouched (still needed for tsc type-checking and non-source-condition deps) — Koenig builds just become cache-hit no-ops for tests and are skipped for pnpm dev.

Verification

  • All 8 direct + 2 transitive kg-* deps resolve to src/*.ts under the dev flags; the full lexical→HTML render chain executes correctly with every build/ dir deleted.
  • Plain node (no flags) correctly falls back to build/ — the two lanes are cleanly separated.
  • Booted pnpm dev: Ghost serves HTTP 200 and the running container resolves @tryghost/kg-default-nodes to koenig/kg-default-nodes/src/index.ts.

🤖 Generated with Claude Code

…ld-free

no ref

- cross-workspace requires forced a tsc build of every kg-* package before
  ghost/core could require them; a source change meant rebuilding before it
  was visible in dev
- adds a "source" exports condition pointing at src/*.ts to the 10 kg-*
  packages in ghost/core's runtime closure, ahead of types/import/require
- ghost/core already runs its dev + test lanes with --conditions=source
  --import=tsx (nodemon.json + vitest configs), so it now resolves these
  packages to raw TS with no build step; plain node in prod/CI ignores the
  condition and uses build/, and src/ stays out of each package's files array
- drops the now-redundant kg-* build list from the docker:up nx target so
  pnpm dev boots without building Koenig
- mirrors the existing ghost/parse-email-address setup; documented in AGENTS.md

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 9, 2026

Copy link
Copy Markdown

Bugbot is not enabled for this team, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@coderabbitai

coderabbitai Bot commented Jul 9, 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: 2df5fc2d-cd8e-42e5-b099-c7777eb50b3d

📥 Commits

Reviewing files that changed from the base of the PR and between 8378f32 and cee7d1a.

📒 Files selected for processing (12)
  • AGENTS.md
  • koenig/kg-card-factory/package.json
  • koenig/kg-clean-basic-html/package.json
  • koenig/kg-converters/package.json
  • koenig/kg-default-cards/package.json
  • koenig/kg-default-nodes/package.json
  • koenig/kg-default-transforms/package.json
  • koenig/kg-html-to-lexical/package.json
  • koenig/kg-lexical-html-renderer/package.json
  • koenig/kg-markdown-html-renderer/package.json
  • koenig/kg-utils/package.json
  • package.json

Walkthrough

This PR adds a source field to the exports["."] map (and ./visibility subpath for kg-default-nodes) in multiple koenig kg-* package.json files, pointing to raw TypeScript source files instead of built output. AGENTS.md is updated with documentation explaining this "zero-build dev" export condition, how dev tooling and Vitest activate it, and how production builds ignore it. Separately, the root package.json simplifies the Nx docker:up target's dependsOn configuration by removing an explicit build target dependency with a project list, retaining only docker:build.

Possibly related PRs

  • TryGhost/Ghost#28842: Adds a similar source condition to a package's exports map for dev resolution to src/*.ts.
  • TryGhost/Ghost#28844: Updates Vitest/SSR resolver settings to correctly resolve the same source exports added across koenig packages.
  • TryGhost/Ghost#28902: Also modifies Nx docker.*.dependsOn targets in package.json affecting docker task ordering.

Suggested reviewers: jonatansberg

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: adding a source export condition for Koenig packages to enable build-free reads in ghost/core.
Description check ✅ Passed The description matches the change set and accurately explains the source export condition, docker:up update, and AGENTS.md docs.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch koenig-source-export-condition

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.

@nx-cloud

nx-cloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit cee7d1a

Command Status Duration Result
nx run @tryghost/admin-x-settings:test:acceptance ✅ Succeeded 10m 36s View ↗
nx run ghost:test:ci:integration ✅ Succeeded 2m 47s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded 1s View ↗
nx run-many -t test:unit -p @tryghost/kg-card-f... ✅ Succeeded 5m 33s View ↗
nx run ghost:test:integration ✅ Succeeded 2m 43s View ↗
nx run ghost:test:legacy ✅ Succeeded 2m 55s View ↗
nx run @tryghost/koenig-lexical:test:acceptance ✅ Succeeded 2m 23s View ↗
nx run ghost:test:e2e ✅ Succeeded 2m 23s View ↗
Additional runs (9) ✅ Succeeded ... View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-09 14:04:26 UTC

@cursor

cursor Bot commented Jul 9, 2026

Copy link
Copy Markdown

Bugbot is not enabled for this team, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.04%. Comparing base (de358cb) to head (ae7e231).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #29198      +/-   ##
==========================================
- Coverage   74.07%   74.04%   -0.04%     
==========================================
  Files        1570     1570              
  Lines      136621   136621              
  Branches    16524    16519       -5     
==========================================
- Hits       101199   101155      -44     
- Misses      34419    34463      +44     
  Partials     1003     1003              
Flag Coverage Δ
e2e-tests 76.15% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@acburdine
acburdine merged commit d956a89 into main Jul 9, 2026
51 checks passed
@acburdine
acburdine deleted the koenig-source-export-condition branch July 9, 2026 14:15
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.

1 participant