Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

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 Aufrufe • vor 10 Tagen •via X (Twitter)

28 Kommentare

Profilbild von colinhacks
colinhacksvor 10 Tagen

Docs 👇

Profilbild von robby - rbby.dev
robby - rbby.devvor 10 Tagen

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

Profilbild von Jinjing Liang
Jinjing Liangvor 10 Tagen

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

Profilbild von Tom
Tomvor 10 Tagen

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

Profilbild von Rajat
Rajatvor 10 Tagen

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=

Profilbild von Oluwafemi | penv.cloud
Oluwafemi | penv.cloudvor 10 Tagen

Validation and agent-safe?

Profilbild von Adrian Gierakowski
Adrian Gierakowskivor 10 Tagen

No thanks

Profilbild von François Best
François Bestvor 10 Tagen

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({ ... }) }

Profilbild von galmenash
galmenashvor 10 Tagen

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

Profilbild von Rohan
Rohanvor 10 Tagen

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

Profilbild von Dhruv Anand
Dhruv Anandvor 10 Tagen

Who needs this anymore?

Profilbild von All In Developer
All In Developervor 10 Tagen

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

Profilbild von Spartak
Spartakvor 10 Tagen

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

Profilbild von nori
norivor 10 Tagen

incredible! is PORT inferred as a number?

Profilbild von Eugene
Eugenevor 10 Tagen

not a replacement for schema validation then?

Profilbild von Suyash
Suyashvor 10 Tagen

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

Profilbild von Coding in Flow
Coding in Flowvor 10 Tagen

I can't install anything with that name

Profilbild von JC Martin🧧
JC Martin🧧vor 10 Tagen

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

Profilbild von Adam Genshaft
Adam Genshaftvor 10 Tagen

That’s 🔥

Profilbild von Khushal
Khushalvor 10 Tagen

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

Profilbild von Prathmesh
Prathmeshvor 10 Tagen

😮

Profilbild von irazz
irazzvor 10 Tagen

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.

Profilbild von mizuki
mizukivor 10 Tagen

cooking again

Profilbild von Alfie Ranstead
Alfie Ransteadvor 10 Tagen

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.

Profilbild von All In Developer
All In Developervor 10 Tagen

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?

Profilbild von BreezeOg
BreezeOgvor 10 Tagen

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

Profilbild von RoboKozo
RoboKozovor 10 Tagen

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)

Profilbild von Rishabh Vasudevan
Rishabh Vasudevanvor 10 Tagen

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?

Ähnliche Videos

grwm sin contexto env
0:33

Sensitive content

grwm sin contexto env

Dennis Ngiabi

79,520 Aufrufe • vor 2 Jahren