Package: @google/adk (Node.js/TypeScript) Version: 0.5.0 through 0.6.1 (all current versions)
Component: DatabaseSessionService / getConnectionOptionsFromUri File: dist/esm/index.js and dist/esm/sessions/db/operations.js
Summary: The ESM distribution of @google/adk uses CJS require() to dynamically load database drivers (@mikro-orm/postgresql, @mikro-orm/mysql, etc.), which throws "Dynamic require of @mikro-orm/postgresql is not supported" at runtime in ESM contexts.
Root cause: The package is built with esbuild, which converts await import() in the TypeScript source into __toESM(require(...), 1) in the ESM output. This CJS interop pattern doesn't work in Node.js ESM runtime because require() is not defined in ES modules.
Reproduction:
mkdir test && cd test && npm init -y
npm install @google/adk @mikro-orm/postgresql @mikro-orm/core pg
DATABASE_URL="postgresql://user:pass@localhost:5432/db" \
npx adk api_server . --port=8000
# Then: curl -X POST http://localhost:8000/apps/agent/users/u/sessions/s
# Error: "Dynamic require of @mikro-orm/postgresql is not supported"
Affected code (in dist/esm/sessions/db/operations.js and inlined in dist/esm/index.js):
const { PostgreSqlDriver } = await Promise.resolve().then(
() => __toESM(require("@mikro-orm/postgresql"), 1)
);
Expected: Should use await import("@mikro-orm/postgresql") in the ESM build.
Workaround: Replace __toESM(require("@mikro-orm/postgresql"), 1) with (async()=>await import("@mikro-orm/postgresql"))() in both dist/esm/index.js and dist/esm/sessions/db/operations.js.
Package: @google/adk (Node.js/TypeScript) Version: 0.5.0 through 0.6.1 (all current versions)
Component:
DatabaseSessionService/getConnectionOptionsFromUriFile:dist/esm/index.jsanddist/esm/sessions/db/operations.jsSummary: The ESM distribution of @google/adk uses CJS require() to dynamically load database drivers (@mikro-orm/postgresql, @mikro-orm/mysql, etc.), which throws "Dynamic require of @mikro-orm/postgresql is not supported" at runtime in ESM contexts.
Root cause: The package is built with esbuild, which converts await import() in the TypeScript source into __toESM(require(...), 1) in the ESM output. This CJS interop pattern doesn't work in Node.js ESM runtime because require() is not defined in ES modules.
Reproduction:
Affected code (in dist/esm/sessions/db/operations.js and inlined in dist/esm/index.js):
Expected: Should use await import("@mikro-orm/postgresql") in the ESM build.
Workaround: Replace __toESM(require("@mikro-orm/postgresql"), 1) with (async()=>await import("@mikro-orm/postgresql"))() in both dist/esm/index.js and dist/esm/sessions/db/operations.js.