正在加载视频...

视频加载失败

Motherload solves the typesafe .env problem (getting autocompletion on process.env), no schemas required. 1. Import a .env file 2. That's it

46,147 次观看 • 10 天前 •via X (Twitter)

28 条评论

colinhacks 的头像
colinhacks10 天前

Docs 👇

robby - rbby.dev 的头像
robby - rbby.dev10 天前

Wonder of this could be a potential attack vector down the line …

Jinjing Liang 的头像
Jinjing Liang10 天前

Could you show an example using your real .env file? 👀

Tom 的头像
Tom10 天前

Don’t you want a schema here though? So you can make sure they are what you expect at runtime and fail quickly if they’re not

Rajat 的头像
Rajat10 天前

I have an idea instead of importing .env file with secrets, let us import .env.schema then replace the schema format of @varlockdev with zod eg: # z.enum(["dev", "prod"]).default("dev") NODE_ENV= # z.string().optional() EXPORT=

Oluwafemi | penv.cloud 的头像
Oluwafemi | penv.cloud10 天前

Validation and agent-safe?

Adrian Gierakowski 的头像
Adrian Gierakowski10 天前

No thanks

François Best 的头像
François Best10 天前

How does it handle different .env (or any data file) contents between where you do the typechecking (dev, CI) and at runtime (prod)? Feels like it's missing a schema for true type-safety: import "./.env" with { schema: z.object({ ... }) }

galmenash 的头像
galmenash10 天前

But we need Zod to verify validity of content anyway, and it better be a func call rather than a module side effect. Am I missing something here? p.s. except that it’s really cool

Rohan 的头像
Rohan10 天前

What happens to a variable that only exists in production and is missing from the local .env?

Dhruv Anand 的头像
Dhruv Anand10 天前

Who needs this anymore?

All In Developer 的头像
All In Developer10 天前

Why .env import does not use named imports instead? import { port } from './.env'

Spartak 的头像
Spartak10 天前

importing is cool, type safety is questionable. having runtime safety is more important, like zod validation of env

nori 的头像
nori10 天前

incredible! is PORT inferred as a number?

Eugene 的头像
Eugene10 天前

not a replacement for schema validation then?

Suyash 的头像
Suyash10 天前

does it watch the file or is it a one-time import

Coding in Flow 的头像
Coding in Flow10 天前

I can't install anything with that name

JC Martin🧧 的头像
JC Martin🧧10 天前

It's a little meaningless for builds though that expect a matching env but now have no runtime validation 😢

Adam Genshaft 的头像
Adam Genshaft10 天前

That’s 🔥

Khushal 的头像
Khushal10 天前

importing the .env file directly feels illegal in a good way

Prathmesh 的头像
Prathmesh10 天前

😮

irazz 的头像
irazz10 天前

This has been a thing for a while. The scope of having typesafe is for the end-user to have the correct variables, enforcing minimum characters etc.

mizuki 的头像
mizuki10 天前

cooking again

Alfie Ranstead 的头像
Alfie Ranstead10 天前

This is insanely cool! Obviously orm-less sql is impressive but I hadn't even considered typesafe .envs Ironically had been attempting to find a nice setup with zod for this kind of thing previously.

All In Developer 的头像
All In Developer10 天前

When doing a `tsc` build, does the imported files reach the `dist` already as modules? Or we need to use node register hook for them to work at runtime?

BreezeOg 的头像
BreezeOg10 天前

just import the .env and you get autocomplete, no schema at all? nice

RoboKozo 的头像
RoboKozo10 天前

that's cool but I still would get value from zod for setting defaults, converting things like dates and numbers, and restricting values to a set of things (like log levels or aws regions)

Rishabh Vasudevan 的头像
Rishabh Vasudevan10 天前

You have made text file parsers and then give auto complete for SQL and now this. Have agents been some kind of unlock for you to be able to do this, or is it just you got to this idea only now?

相关视频

grwm sin contexto env
0:33

Sensitive content

grwm sin contexto env

Dennis Ngiabi

79,520 次观看 • 2 年前