drizzle-orm: [BUG]: ERROR: Transforming const to the configured target environment ("es5") is not supported
What version of drizzle-orm are you using?
0.27.0
What version of drizzle-kit are you using?
0.19.2
Describe the Bug
Created a new next13 project and setup drizzle/drizzle kit using the quick start https://orm.drizzle.team/kit-docs/quick. Tried to run the generate script - dirzzle-kit generate:pg and got the following error:
Error: Transform failed with 1 error:
<path-to-app>/src/db/schema.ts:3:7: ERROR: Transforming const to the configured target environment ("es5") is not supported yet
errors: [
{
detail: undefined,
id: '',
location: [Object],
notes: [],
pluginName: '',
text: 'Transforming const to the configured target environment ("es5") is not supported yet'
}
],
Downgrading to version 0.18.1 and 0.26.5 runs the generate command successfully not sure why this occurs with the latest version
Expected behavior
Run generate migrations successfully with drizzle kit version 0.19.2 and nextjs 13
Environment & setup
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 17
- Comments: 17 (2 by maintainers)
Here’s another solution without creating an extra
tsconfig.json, just hard code the target option.I’m using
pnpm patchto patch this.Next.js has
es5configured as its default and I assume not without reason. What is your suggestion?es5as a target is not supported, just try to use higher versions.es6should work wellWorkaround for now is to change the target in your tsconfig to ESNext when you want to run the drizzle-kit commands:
I’d still like to see a fix on the Drizzle kit side - I don’t think drizzle kit should be stuck using the same tsconfig as the src directory - drizzle kit shouldn’t cause clashes like this.
@andresgutgon I’m not a contributor to Drizzle, hopefully this issue has been seen by the Drizzle team. Unfortunately Drizzle-kit is not open source at the moment so we can’t submit pull request fixes even if we wanted to.
Ok, I think I found a better way:
I created a file called
tsconfig.drizzle.jsonwith these contents:I then patched the
node_modules/drizzle-kit/index.cjsby replacing all instances oftsconfig.jsonwithtsconfig.drizzle.json.I got this patch from using
patch-package:Additionally, if you want to just fix that withpatch-packagethen you can use this patch:See https://dev.to/zhnedyalkow/the-easiest-way-to-patch-your-npm-package-4ece
Thank you for the suggestion! I tried using
es6as the target and it worked well.Actually @samhithk I think I may have not got the patch correct. I thought it was working but now I am not sure - I’m still tinkering so I will post again if I get more info