Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CJS version of AgentKit improperly imports an ESM module. Had to patch package to force ESM import. #82

Open
DreamwareDevelopment opened this issue Mar 4, 2025 · 1 comment · May be fixed by #83

Comments

@DreamwareDevelopment
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @inngest/agent-kit@0.3.1 for the project I'm working on.

Here is the error I encountered when importing the CJS version.

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/zander/Documents/Code/goaltime/node_modules/@dmitryrechkin/json-schema-to-zod/dist/index.js from /Users/zander/Documents/Code/goaltime/node_modules/@inngest/agent-kit/dist/index.cjs not supported.
Instead change the require of index.js in /Users/zander/Documents/Code/goaltime/node_modules/@inngest/agent-kit/dist/index.cjs to a dynamic import() which is available in all CommonJS modules.
    at Module._load (/Users/zander/Documents/Code/goaltime/node_modules/@nx/js/src/executors/node/node-with-require-overrides.js:18:31)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at Object.<anonymous> (/Users/zander/Documents/Code/goaltime/node_modules/@inngest/agent-kit/dist/index.cjs:71:33)

Here is the diff that forces agent-kit to be imported by ESM.

diff --git a/node_modules/@inngest/agent-kit/package.json b/node_modules/@inngest/agent-kit/package.json
index cb40f0d..8130939 100644
--- a/node_modules/@inngest/agent-kit/package.json
+++ b/node_modules/@inngest/agent-kit/package.json
@@ -27,18 +27,18 @@
   "exports": {
     ".": {
       "import": "./dist/index.js",
-      "require": "./dist/index.cjs",
+      "require": "./dist/index.js",
       "types": {
         "import": "./dist/index.d.ts",
-        "require": "./dist/index.d.cts"
+        "require": "./dist/index.d.ts"
       }
     },
     "./server": {
       "import": "./dist/server.js",
-      "require": "./dist/server.cjs",
+      "require": "./dist/server.js",
       "types": {
         "import": "./dist/server.d.ts",
-        "require": "./dist/server.d.cts"
+        "require": "./dist/server.d.ts"
       }
     }
   },

This issue body was partially generated by patch-package.

@jpwilliams
Copy link
Member

Thanks for the report, @DreamwareDevelopment!

Could you try out this canary version to see if it fixes the issue for you without needing to revert to ESM-only?

#83 (comment)

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 a pull request may close this issue.

2 participants