t3-oss / t3-env

https://env.t3.gg
MIT License
2.67k stars 86 forks source link

chore: use jiti to load ts files in next #188

Closed juliusmarminge closed 7 months ago

juliusmarminge commented 7 months ago

Closes #166

vercel[bot] commented 7 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
t3-env ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 8, 2024 10:25am
t3-env-nextjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 8, 2024 10:25am
deadcoder0904 commented 7 months ago

for some reason, this doesn't work for me.

import createJiti from "jiti"
const jiti = createJiti(new URL(import.meta.url).pathname)

jiti("./src/app/lib/env")

but this does:

import jiti from "jiti"
import { fileURLToPath } from "node:url"

jiti(fileURLToPath(import.meta.url))("./src/app/lib/env")

i got this error when i tried your way:

Error: Cannot find module './src/app/lib/env'

might have something to do with import.meta.url only working with module type.

edit: damn, my code also has import.meta.url hah