Skip to content

Commit 04c99d2

Browse files
chore: update versions (#23)
Co-authored-by: vland-bot[bot] <282456776+vland-bot[bot]@users.noreply.github.com>
1 parent fd1f5f8 commit 04c99d2

3 files changed

Lines changed: 28 additions & 26 deletions

File tree

‎.changeset/loadconfig-sync.md‎

Lines changed: 0 additions & 25 deletions
This file was deleted.

‎package/CHANGELOG.md‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
# @vlandoss/env
22

3+
## 0.3.0
4+
5+
### Minor Changes
6+
7+
- [#22](https://github.com/variableland/env/pull/22) [`fd1f5f8`](https://github.com/variableland/env/commit/fd1f5f837f3bafc2d31b7559674cdfd2b018c422) Thanks [@rqbazan](https://github.com/rqbazan)! - **`loadConfig` (`@vlandoss/env/fs`) is now synchronous.** It loads the config with `require()` and returns `Config<S>` directly instead of a `Promise`, so it works in app code **and** in config files that tooling loads via `require()` or bundles to CJS (where a top-level `await` is rejected).
8+
9+
**Migration — drop the `await`:**
10+
11+
```diff
12+
- const config = await loadConfig(Env);
13+
+ const config = loadConfig(Env);
14+
```
15+
16+
`await loadConfig(...)` still returns the right value at runtime (awaiting a non-promise yields the value), but the `await` keeps the module asynchronous — so a config file that keeps it still can't be `require()`d. Remove it.
17+
18+
Auto-discovery now also covers `.cjs` / `.cts` (was: `.ts` `.mts` `.js` `.mjs` `.json`). The options form gains an optional `cwd` so callers can override `process.cwd()` when the working directory isn't the project root.
19+
20+
Files are loaded with `require()`. Runtime requirements by extension:
21+
22+
- `.ts` / `.mts` / `.cts` — needs native TS stripping (native in Bun/Deno, **Node ≥22.18**).
23+
- `.mjs` / `.js` / `.cjs` — needs `require(esm)` (native in Bun/Deno, **Node ≥22.12**).
24+
- `.json` — works on any supported Node.
25+
26+
The package's `engines` is **Node ≥22.12** (the `require(esm)` baseline). The `.ts` strip requirement is documented per-extension; consumers using only `.json`/`.mjs`/`.cjs` configs aren't blocked by an over-broad floor.
27+
28+
CJS configs (`module.exports = {...}`): a CJS exports object that owns a `default` property name is **no longer** silently stripped — `loadConfig` discriminates ESM namespaces by `Symbol.toStringTag === "Module"` and returns CJS exports as-is, so sibling keys survive.
29+
330
## 0.2.1
431

532
### Patch Changes

‎package/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vlandoss/env",
3-
"version": "0.2.1",
3+
"version": "0.3.0",
44
"description": "Contract-first environment configuration with typed schemas",
55
"homepage": "https://github.com/variableland/env/tree/main/package#readme",
66
"bugs": {

0 commit comments

Comments
 (0)