Skip to main content
← Back to list
01Issue
BugClosedSwamp Club
AssigneesNone

fix: extension npm packages fail to resolve in compiled binary

Opened by swampadmin · 6/17/2025

Description

Since #611 (--external npm:*), extension models that import npm packages (e.g., @john/k8s importing npm:@kubernetes/client-node@1.0.0) fail when run from the compiled swamp binary:

Warning: Failed to load user model k8s/configmap.ts: TypeError: Could not find constraint '@kubernetes/client-node@1.0.0' in the list of packages.

This affects ALL extension npm packages except npm:zod (which is in swamp's own dependency graph).

Root Cause

Two conflicting deno bundle failure modes:

  1. CJS interop (#609): When npm packages are INLINED, CJS-dependent packages (e.g., @aws-sdk/client-s3tslib) break with import_tslib.default is undefined. This was fixed by #611 externalizing all npm packages.

  2. Compiled binary resolution: When npm packages are EXTERNALIZED (--external npm:*), the compiled binary can't resolve packages not in its embedded dependency graph. This is the current regression.

Proposed Fix

  1. Only externalize npm:zod — revert --external npm:* to --external npm:zod@4 --external npm:zod. All other npm packages get inlined by the bundler, which works in compiled binaries.

  2. Ban dynamic imports — the CJS interop issue (#609) was triggered by await import("npm:@aws-sdk/client-s3@3"). Add validation during extension push to reject dynamic import() calls with a clear error. Static top-level imports are handled correctly by deno bundle.

  3. Update skill docs — guide extension authors to use static imports only.

Impact

  • Fixes @john/k8s and any extension using npm packages from compiled binary
  • Prevents future CJS interop issues by rejecting the problematic pattern at push time
  • No new runtime requirements (bundles remain self-contained)
  • Extensions using dynamic imports will need to convert to static imports
  • #609 — Bundler breaks tslib CJS/ESM interop for dynamic imports
  • #611 — Externalize all npm packages in extension bundler (introduced this regression)
02Bog Flow
OPENTRIAGEDIN PROGRESSCLOSED

Closed

No activity in this phase yet.

03Sludge Pulse

Sign in to post a ripple.