From 433252bdb11391248d79bcb37d4050473440eeee Mon Sep 17 00:00:00 2001 From: agent_vscode Date: Sun, 12 Jul 2026 04:53:22 +0300 Subject: [PATCH] fix(ci): build @docmost/token-estimate before its non-nx consumers (#490) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The shared @docmost/token-estimate package (main: ./dist/index.js, dist/ gitignored) was never built in the CI jobs that bypass nx, so develop CI went red: - test.yml `test` (pnpm -r test): client vitest failed to resolve the import. - develop.yml `e2e-server` (direct jest e2e): server history-budget.ts hit TS2307 Cannot find module '@docmost/token-estimate'. The nx-driven jobs (build, e2e-mcp) stayed green via dependsOn: ^build. - test.yml: add "Build token-estimate" step to the `test` job. - develop.yml: add "Build token-estimate" step to the `e2e-server` job. - Dockerfile: ship packages/token-estimate/dist + package.json into the installer stage — apps/server depends on it (workspace:*) and imports it at runtime, so the prod image would otherwise crash with ERR_MODULE_NOT_FOUND (masked so far because publish/smoke never ran). Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/develop.yml | 7 +++++++ .github/workflows/test.yml | 8 ++++++++ Dockerfile | 8 ++++++++ 3 files changed, 23 insertions(+) diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml index 224a1e43..2831d643 100644 --- a/.github/workflows/develop.yml +++ b/.github/workflows/develop.yml @@ -226,6 +226,13 @@ jobs: - name: Build mcp run: pnpm --filter @docmost/mcp build + # apps/server imports @docmost/token-estimate at runtime (history-budget.ts, + # #490); its dist/ is gitignored and `test:e2e` type-checks + runs the code, + # so build it here or tsc fails with TS2307 Cannot find module + # '@docmost/token-estimate' (mirrors the editor-ext / mcp build steps above). + - name: Build token-estimate + run: pnpm --filter @docmost/token-estimate build + - name: Run migrations run: pnpm --filter ./apps/server migration:latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 509ad6be..fef6b189 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -159,6 +159,14 @@ jobs: - name: Build prosemirror-markdown run: pnpm --filter @docmost/prosemirror-markdown build + # @docmost/token-estimate is a shared workspace package the client vitest + # suite resolves via its dist build (main: ./dist/index.js); dist/ is + # gitignored and `pnpm -r test` does NOT honour nx `dependsOn: ^build`, so + # build it before the recursive test run or the client suite fails with + # "Failed to resolve import '@docmost/token-estimate'" (#490). + - name: Build token-estimate + run: pnpm --filter @docmost/token-estimate build + - name: Run unit tests run: pnpm -r test diff --git a/Dockerfile b/Dockerfile index 280e5b55..792bf0e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -59,6 +59,14 @@ COPY --from=builder /app/packages/mcp/data /app/packages/mcp/data COPY --from=builder /app/packages/prosemirror-markdown/build /app/packages/prosemirror-markdown/build COPY --from=builder /app/packages/prosemirror-markdown/package.json /app/packages/prosemirror-markdown/package.json +# apps/server imports @docmost/token-estimate (workspace:*) at runtime +# (history-budget.ts, #490). tsc emits only dist/ and dist/ is gitignored, so the +# prod install would resolve a broken workspace symlink and the server would die +# with ERR_MODULE_NOT_FOUND on the first history-budget call. Ship the built +# package + its manifest, mirroring prosemirror-markdown above. +COPY --from=builder /app/packages/token-estimate/dist /app/packages/token-estimate/dist +COPY --from=builder /app/packages/token-estimate/package.json /app/packages/token-estimate/package.json + # Copy root package files COPY --from=builder /app/package.json /app/package.json COPY --from=builder /app/pnpm*.yaml /app/