Open mandarzope opened 2 months ago
+1. Also failed with "Node16".
still getting this...
This is a patch that works with Svelte 5, note that package managers such as bun
and pnpm
offer patching generally through the bun patch
command:
diff --git a/bin.cjs b/bin.cjs
index 96235f52f7d0fcaed6abb588107a9fed948bd808..95d4eabc57367e599ceef4185c5e2fa7cedb4e0c 100755
--- a/bin.cjs
+++ b/bin.cjs
@@ -17138,6 +17138,16 @@ var require_node2 = __commonJS({
return originalResolveFilename.apply(this, modifiedArguments);
}
}
+ /***********************Temporary fix start***************************/
+
+ if (request.endsWith('.js')) {
+ const found = require('path').resolve(_parent.path, request.replace('.js', '.ts'))
+ if (require('fs').existsSync(found)) {
+ const modifiedArguments = [found, ...[].slice.call(arguments, 1)];
+ return originalResolveFilename.apply(this, modifiedArguments);
+ }
+ }
+ /***********************Temporary fix end***************************/
return originalResolveFilename.apply(this, arguments);
};
return () => {
This is not an ideal solution but "it just works"
Appreciate the report @mandarzope. Same issue here.
drizzle-kit: 0.24.2.
The above fix didn't work for me (and I'd like to avoid patching libraries that I'll only break again when upgrading / re-installing).
Instead I pointed drizzle.config.ts to the compiled schema.js file instead of the uncompiled schema.ts file. In my case:
// tsconfig.json
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
...
}
and then
// OLD drizzle.config.ts
export default defineConfig({
...
schema: "./src/db/schema.ts",
...
})
// NEW, FIXED drizzle.config.ts
export default defineConfig({
...
schema: "./dist/db/schema.js",
...
})
Not a great fix! Surely someone will come up with something smarter. But you can make it a little nicer by tweaking package.json to run tsc first (see npm docs on pre/post scripts):
// package.json
"scripts": {
...
"pregenerate-sql": "tsc",
"generate-sql": "drizzle-kit generate",
"premigrate-sql": "tsc",
"migrate-sql": "drizzle-kit migrate"
...
}
FWIW: drizzle-kit generate/migrate were working exactly as expected until now. Unclear which commit broke it -- the only recent change to my tsconfig.json was adding skipLibCheck: true
(and alas, that flag was only turned on because of the ts compile errors thrown by drizzle-orm).
But take that with a grain of salt: doesn't make sense that skipLibCheck
would break this, and reverting it to false
didn't fix either. But it's the only hint I could glean from our commit history.
While running migrations in following setup "drizzle-kit": "^0.22.7" throws error with typescript and type:module setup
Currently this is fixed by modifying drizzle-kit/bin.cjs