From 90a3f373782dd591d8f2d7e2f9bd3fd416450d3f Mon Sep 17 00:00:00 2001 From: jubnl Date: Mon, 25 May 2026 20:27:50 +0200 Subject: [PATCH] fix(ci): build shared before tests; fix vitest MCP SDK alias paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit vitest.config.ts aliases pointed at ./node_modules/ (server-local) but packages are hoisted to the root node_modules/ in the npm workspace — changed to ../node_modules/. CI jobs now install and build shared before running server/client tests so that @trek/shared's dist/ exists when vitest resolves the package. --- .github/workflows/test.yml | 16 +++++++++++----- server/vitest.config.ts | 11 +++++++---- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c8cc7ccb..00ca623e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,14 +49,17 @@ jobs: cache-dependency-path: package-lock.json - name: Install dependencies - run: npm ci --workspace server + run: npm ci --workspace shared && npm ci --workspace server - - name: Build (tsc + tsc-alias -> dist) + - name: Build shared + run: npm run build --workspace=shared + + - name: Build server (tsc -> dist) run: cd server && npm run build - name: Typecheck (informational) - # Legacy code still has pre-existing type errors; this surfaces them - # without blocking the migration. Ratchet to blocking once cleaned up. + # Pre-existing type errors in the NestJS rewrite; surfaces them without + # blocking CI. Ratchet to blocking once the legacy code is cleaned up. continue-on-error: true run: cd server && npm run typecheck @@ -85,7 +88,10 @@ jobs: cache-dependency-path: package-lock.json - name: Install dependencies - run: npm ci --workspace client + run: npm ci --workspace shared && npm ci --workspace client + + - name: Build shared + run: npm run build --workspace=shared - name: Run tests run: cd client && npm run test:coverage diff --git a/server/vitest.config.ts b/server/vitest.config.ts index ef65960f..660e71f3 100644 --- a/server/vitest.config.ts +++ b/server/vitest.config.ts @@ -38,20 +38,23 @@ export default defineConfig({ }, resolve: { alias: { + // MCP SDK's exports map uses extension-less wildcard targets that neither + // Node nor Vite can resolve. Point directly at the CJS dist files. + // Paths are relative to the monorepo root (packages are hoisted there). '@modelcontextprotocol/sdk/server/mcp': new URL( - './node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js', + '../node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js', import.meta.url ).pathname, '@modelcontextprotocol/sdk/server/streamableHttp': new URL( - './node_modules/@modelcontextprotocol/sdk/dist/cjs/server/streamableHttp.js', + '../node_modules/@modelcontextprotocol/sdk/dist/cjs/server/streamableHttp.js', import.meta.url ).pathname, '@modelcontextprotocol/sdk/inMemory': new URL( - './node_modules/@modelcontextprotocol/sdk/dist/cjs/inMemory.js', + '../node_modules/@modelcontextprotocol/sdk/dist/cjs/inMemory.js', import.meta.url ).pathname, '@modelcontextprotocol/sdk/client/index': new URL( - './node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.js', + '../node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.js', import.meta.url ).pathname, },