Bug: zod-to-json-schema import fails in CommonJS bundle (v0.2.6)
Bug Description
The @composio/[email protected] package has a bug in its CommonJS bundle where zod-to-json-schema is imported incorrectly, causing a runtime error when trying to use createCustomTool.
Error
TypeError: (0 , import_zod_to_json_schema.default) is not a function
at CustomTools.createTool (/opt/nodejs/node_modules/@composio/core/dist/index.cjs:2131:64)
Root Cause
In /node_modules/@composio/core/dist/index.cjs line 927:
var import_zod_to_json_schema = __toESM(require("zod-to-json-schema"), 1);
The __toESM helper is not correctly handling the CommonJS export from [email protected].
Affected Versions
@composio/[email protected]@composio/[email protected][email protected]
Workaround
Replace line 927 with:
var import_zod_to_json_schema = { default: require("zod-to-json-schema").zodToJsonSchema };
Expected Behavior
The createCustomTool method should work without manual patching of the bundled code.
Environment
- Runtime: AWS Lambda (Node.js 20.x)
- Package manager: npm
- Installation:
npm install @composio/[email protected] --omit=dev
Suggested Fix
Update the bundler configuration to correctly handle the zod-to-json-schema CommonJS export, or explicitly import the named export zodToJsonSchema instead of using default import.
Hey @pontus-devoteam, could you share a snippet where we can reproduce this issue?
Thanks for opening this issue. Looks like this may be an instance of a known tsup issue: https://github.com/egoist/tsup/issues/596