Skip to content

fix: dual-layer ESM fix for Node 22/24 vscode-jsonrpc resolution#474

Merged
bradygaster merged 1 commit intodevfrom
squad/449-node22-esm-fix
Mar 22, 2026
Merged

fix: dual-layer ESM fix for Node 22/24 vscode-jsonrpc resolution#474
bradygaster merged 1 commit intodevfrom
squad/449-node22-esm-fix

Conversation

@bradygaster
Copy link
Copy Markdown
Owner

Summary

Fixes #449 — Node 22/24 ESM module resolution failure for \�scode-jsonrpc\ subpath imports.

Root Cause

\�scode-jsonrpc@8.2.1\ ships without an \�xports\ field. Node 22+ strict ESM rejects \import('vscode-jsonrpc/node')\ because it can't resolve the subpath without explicit exports.

What Changed

Layer 1 — \�scode-jsonrpc/package.json\ exports injection (new)

  • Postinstall now injects the \�xports\ field from vscode-jsonrpc v9.x into the installed v8.2.1 \package.json\
  • This fixes ALL subpath imports at once (./node, ./browser, .) — not just the one in session.js

Layer 2 — copilot-sdk \session.js\ patch (preserved)

  • Existing defense-in-depth patch that adds .js\ extension to the import

Layer 3 — Runtime \Module._resolveFilename\ intercept (existing, unchanged)

  • Handles npx cache hits where postinstall never runs

\squad doctor\ ESM checks (new)

Testing

  • All 8 doctor tests pass (2 new assertions for ESM checks)
  • Build passes
  • Postinstall verified: patches correctly on first run, idempotent on re-run

Working as GNC (Node.js Runtime specialist)

Layer 1: Inject exports field into vscode-jsonrpc@8.2.1 package.json at
postinstall, matching v9.x schema. Fixes ALL subpath imports at once.

Layer 2: Keep existing copilot-sdk session.js .js extension patch as
defense-in-depth fallback.

Layer 3 (existing): Runtime Module._resolveFilename intercept in
cli-entry.ts for npx cache hits where postinstall never runs.

squad doctor now detects both missing exports field and unpatched
session.js imports, with actionable remediation messages.

Closes #449

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bradygaster bradygaster force-pushed the squad/449-node22-esm-fix branch from 42bfd7b to 8a7d5f5 Compare March 22, 2026 06:59
@bradygaster
Copy link
Copy Markdown
Owner Author

GNC review (Node.js Runtime specialist): ESM fix correctly addresses Node 22/24 vscode-jsonrpc resolution.

Key findings:

  • Layer 1 (postinstall exports injection) matches vscode-jsonrpc v9.x structure — fixes all subpath imports at once
  • Fixed during review: Added ./node.js\ to exports field to prevent conflict with Layer 2's .js\ extension rewrite. Without this, when both layers apply, \import('vscode-jsonrpc/node.js')\ would fail against exports that only mapped ./node\ — this was the root cause of CI E2E failures
  • Layer 2 (session.js patch) correctly preserved as defense-in-depth
  • Layer 3 (runtime Module._resolveFilename) handles CJS resolution for npx cache hits
  • Doctor checks properly validate both layers with graceful warn/fail semantics

Rebased on dev (includes #483 CI timeout fix). All 8 doctor tests pass. LGTM ✅

@bradygaster bradygaster merged commit d9d0ae3 into dev Mar 22, 2026
1 of 2 checks passed
@bradygaster bradygaster deleted the squad/449-node22-esm-fix branch March 22, 2026 07:04
chrislomonico pushed a commit to clomonico/squad that referenced this pull request Mar 26, 2026
…dygaster#474)

- typewrite() default: 30ms → 8ms/char
- revealLines() default: 100ms → 30ms/line
- Explicit typewrite calls: 25ms/40ms → 8ms/10ms
- sleep() calls: 200ms/300ms → 50ms/80ms
- NO_COLOR mode still skips animations entirely

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

squad-cli fails with ERR_MODULE_NOT_FOUND on Node 22 (vscode-jsonrpc ESM import)

1 participant