Skip to content

fix(mcp-slicer): static-import renderDirectivesAsText — unblock DEV unit-tests bundle step - #3036

Merged
jung-thomas merged 1 commit into
DEVfrom
worktree-fix-mcp-slicer-parsers-bundle
Nov 6, 2026
Merged

jung-thomas merged 1 commit into
DEVfrom
worktree-fix-mcp-slicer-parsers-bundle

Conversation

@jung-thomas

Copy link
Copy Markdown
Contributor

Problem

The unit tests CI job is red on DEV (and was on PR #3033 before it merged). It fails in the bundle-generation prestep (node scripts/bundle-shared.cjs), before any test runs:

X [ERROR] Could not resolve "./_shared/parsers.bundle.mjs"
    packages/mcp/tutorial-step-slicer.js:32:40

Root cause

PR #3033's commit 4c6558a48 ("lazy-import renderDirectivesAsText to survive CF runtime") replaced a static import with a lazy import() + fallback:

try { _directivesMod = await import('../../scripts/parsers/directives.js'); }
catch { _directivesMod = await import('./_shared/parsers.bundle.mjs'); }

esbuild resolves string-literal dynamic imports relative to the source file. From packages/mcp/, ./_shared/parsers.bundle.mjs points at packages/mcp/_shared/ — a directory bundle-shared.cjs never emits (parsers.bundle.mjs is written only into srv/lib/_shared/). esbuild can't resolve it, so building @tutorials/mcp → mcp.bundle.mjs fails.

The #3029 pattern was misapplied: the slicer always reaches CF runtime bundled into srv/lib/_shared/mcp.bundle.mjs, so a static import is inlined at build time and needs no scripts/parsers/ source on disk — exactly like the sibling collectTroubleshootEntries static import one line above it.

Fix

Revert renderDirectivesAsText to a static import, matching collectTroubleshootEntries. esbuild inlines it; no dynamic import, no unresolvable fallback path, no CF-runtime gap. (−14/+8, one file.)

Verification

Reproduced the exact CI error in an isolated esbuild 0.28.2 harness (same version as CI) against the real source:

  • old code → BUILD FAIL: Could not resolve "./_shared/parsers.bundle.mjs" @ packages/mcp/tutorial-step-slicer.js:32
  • fixed code → BUILD OK; esbuild metafile confirms directives.ts is included and renderDirectivesAsText is inlined into the output bundle.

🤖 Generated with Claude Code

@jung-thomas
jung-thomas merged commit 36b5d61 into DEV Nov 6, 2026
3 of 4 checks passed
@jung-thomas
jung-thomas deleted the worktree-fix-mcp-slicer-parsers-bundle branch November 6, 2026 16:50
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