Skip to content

fix: correct @agent-relay/utils CJS exports for CommonJS compatibility#328

Merged
khaliqgant merged 1 commit intomainfrom
fix/utils-cjs-export
Jan 28, 2026
Merged

fix: correct @agent-relay/utils CJS exports for CommonJS compatibility#328
khaliqgant merged 1 commit intomainfrom
fix/utils-cjs-export

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

@khaliqgant khaliqgant commented Jan 28, 2026

Summary

Root Cause: The Docker 18 spawn infrastructure test fails because require('@agent-relay/utils') receives the ES module instead of the CommonJS version.

Issue: @agent-relay/utils/package.json had:

  • "main": "dist/index.js" (ES module)
  • "default": "./dist/index.js" in exports (ES module)

When CommonJS code tries to require() the package, Node.js gets the ES module path, causing:

ERROR: require() of ES Module .../dist/src/index.js not supported

Solution

Updated @agent-relay/utils/package.json:

  • Changed "main" from dist/index.jsdist/cjs/index.js
  • Reordered exports conditions: require before import
  • Changed all "default" fields to point to dist/cjs/* versions

This matches the fix from PR #325 applied to the root package and ensures CommonJS compatibility.

Testing

  • Local npm install test with require('agent-relay')
  • Docker 18 spawn infrastructure test passes
  • Docker 20/22 tests pass
  • Verify Node tests pass
  • Linux/Docker tests pass

Files Changed

  • packages/utils/package.json: Updated main and exports fields for CJS compatibility

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 noreply@anthropic.com


Open with Devin

The @agent-relay/utils package had "main" and "default" export fields pointing to
the ES module (dist/index.js) instead of the CommonJS version (dist/cjs/index.js).
This caused require() calls to fail with "ERROR: require() of ES Module ... not supported"
when used from CommonJS contexts like the Docker verification tests.

Changes:
- Set "main" field to "dist/cjs/index.js" (was "dist/index.js")
- Reorder exports conditions: require before import
- Set "default" field to "./dist/cjs/index.js" for all export paths

This matches the fix applied to the root package in PR #325 and resolves the
Docker 18 spawn infrastructure test failure.

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional flags.

Open in Devin Review

@khaliqgant khaliqgant merged commit 1a0cf6e into main Jan 28, 2026
23 checks passed
@khaliqgant khaliqgant deleted the fix/utils-cjs-export branch January 28, 2026 10:07
khaliqgant added a commit that referenced this pull request Jan 28, 2026
 packages

Add bundledDependencies array to force npm to include all @agent-relay/* packages
in the tarball instead of fetching them from npm registry. This ensures that when
Docker installs the package, it uses the fixed CJS exports from the bundled
versions rather than old registry versions.

This fixes the Docker 18 spawn infrastructure test by ensuring:
1. npm install uses bundled packages from tarball (not registry)
2. All @agent-relay packages include the CJS export fixes
3. require('@agent-relay/utils') works correctly in Docker tests

Bundled packages:
- All 17 @agent-relay/* dependencies
- Ensures consistent versions across all environments
- Tradeoff: Larger tarball (~50MB) but guarantees registry independence

Follow-up to:
- PR #328: CJS export fixes for @agent-relay/utils
- Merged commit 1a0cf6e

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.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.

1 participant