Open aminfara opened 2 weeks ago
If I add the following lines to the top of transpiled file node_modules/drizzle-kit/api.mjs
it works (very messy hack).
import { createRequire as topLevelCreateRequire } from 'module';
const require = topLevelCreateRequire(import.meta.url);
The issue seems to be related to tsup bundling both cjs and esm dependencies in api.mjs where require
is not defined. The lines above somehow need to be added to drizzle-kit
build steps as esbuild banner.
What version of
drizzle-orm
are you using?0.33.0
What version of
drizzle-kit
are you using?0.24.2
Describe the Bug
When I import
pushSchema
fromdrizzle-kit/api
in ESM files it fails with the following error:https://codesandbox.io/p/devbox/drizzle-kit-import-xkmlfw?
Expected behavior
Import without a problem like the commonJS file.
Environment & setup
I saw this problem first when I tried to use pushSchema in my unit tests for my Typescript(ESM) package. When I changed to CommonJS it just worked. So I created this empty ESM javascript package to make sure nothing is interfering with the imports.
https://codesandbox.io/p/devbox/drizzle-kit-import-xkmlfw