Releases: variableland/env
@vlandoss/env@0.4.0
@vlandoss/env@0.3.0
Minor Changes
-
#22
fd1f5f8Thanks @rqbazan! -loadConfig(@vlandoss/env/fs) is now synchronous. It loads the config withrequire()and returnsConfig<S>directly instead of aPromise, so it works in app code and in config files that tooling loads viarequire()or bundles to CJS (where a top-levelawaitis rejected).Migration — drop the
await:- const config = await loadConfig(Env); + const config = loadConfig(Env);
await loadConfig(...)still returns the right value at runtime (awaiting a non-promise yields the value), but theawaitkeeps the module asynchronous — so a config file that keeps it still can't berequire()d. Remove it.Auto-discovery now also covers
.cjs/.cts(was:.ts.mts.js.mjs.json). The options form gains an optionalcwdso callers can overrideprocess.cwd()when the working directory isn't the project root.Files are loaded with
require(). Runtime requirements by extension:.ts/.mts/.cts— needs native TS stripping (native in Bun/Deno, Node ≥22.18)..mjs/.js/.cjs— needsrequire(esm)(native in Bun/Deno, Node ≥22.12)..json— works on any supported Node.
The package's
enginesis Node ≥22.12 (therequire(esm)baseline). The.tsstrip requirement is documented per-extension; consumers using only.json/.mjs/.cjsconfigs aren't blocked by an over-broad floor.CJS configs (
module.exports = {...}): a CJS exports object that owns adefaultproperty name is no longer silently stripped —loadConfigdiscriminates ESM namespaces bySymbol.toStringTag === "Module"and returns CJS exports as-is, so sibling keys survive.
@vlandoss/env@0.2.1
@vlandoss/env@0.2.0
Minor Changes
-
#6
d150a70Thanks @rqbazan! - BREAKING Rename<ClientEnv />(in@vlandoss/env/react) to<EnvScript />. The new name stops suggesting client-side use and reflects what the component actually does: emit a<script>tag with the server-resolved env so the browser can read it during SSR or SSG hydration. The entrypoint path (@vlandoss/env/react) is unchanged. The wire format is also unchanged: the DOMid="env"andwindow.__envglobal stay identical, so HTML served by an older build continues to hydrate correctly.Renames included:
- Component:
ClientEnv→EnvScript - Props:
ClientEnvProps→EnvScriptProps - Constants:
CLIENT_ENV_SCRIPT_ID→ENV_SCRIPT_ID,CLIENT_ENV_GLOBAL_ID→ENV_GLOBAL_ID
Migration: replace
<ClientEnv …>with<EnvScript …>. If you imported the constants from the core entrypoint, update those imports too. - Component:
-
#6
d150a70Thanks @rqbazan! - BREAKING Rename@vlandoss/env/nodeto@vlandoss/env/fs. The entrypoint has always been about file-system access on a Node-compatible runtime — the new name reflects that it works on Node, Bun, and Deno (not just Node), and that it does not work on Workers/Edge. The dynamic-import path resolution now usespathToFileURLso Deno can load absolute paths correctly.Migration: replace
from "@vlandoss/env/node"withfrom "@vlandoss/env/fs".
Patch Changes
-
#6
d150a70Thanks @rqbazan! - Replacelodash.mergewithdefufor the internal merge that combinesdefaults + config + envOverride. The precedence (env > config > defaults) is unchanged.This fixes a silent shallow-merge regression on V8 isolate runtimes (Cloudflare Workers, Vercel Edge, Next.js Edge):
lodash.mergerelies onisPlainObject, which returnsfalsewhen the object originates from a different realm than the merger. The fallback path then assigns by reference instead of deep-merging, which caused leaf values present inconfig(e.g.db.LOGGING: true) to be dropped wheneverenvOverridetouched the same parent branch.defu is realm-agnostic and reliably deep-merges in all the runtimes supported by the core.
-
#6
d150a70Thanks @rqbazan! - Polish the package README to match the new docs site language — soften technical references toprocess.env, separate the optionalzodinstall, and align the tagline with the rest of the documentation. -
#6
d150a70Thanks @rqbazan! -readEnv()no longer throwsReferenceErroron runtimes whereprocessis not defined (e.g. Cloudflare Workers withoutnodejs_compat). It now returns{}so callers can supply the environment explicitly viadefineEnv({ runtimeEnv })— the idiomatic pattern in Workerfetch(req, env, ctx)handlers. Behavior on Node, Bun, Deno, browsers, and Edge runtimes that polyfillprocess.envis unchanged.
@vlandoss/env@0.1.2
@vlandoss/env@0.1.1
@vlandoss/env@0.1.0
Minor Changes
-
42c6eb7Thanks @rqbazan! - Initial public release of@vlandoss/envunder the@vlandossscope.Contract-first environment configuration with typed schemas and per-runtime entrypoints:
@vlandoss/env— runtime-agnostic core (schema,defineEnv,envName,readEnv).@vlandoss/env/node—loadConfigwith auto-discovery or{env}template.@vlandoss/env/vite—envConfigVite plugin (#configalias +__ENV_NAME__build-time inject).@vlandoss/env/react—<ClientEnv />for SSR/SSG.@vlandoss/env/zod— opt-in opinionated Zod primitives (port,host,bool,logLevel,secret).