Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions .changeset/loadconfig-sync.md

This file was deleted.

27 changes: 27 additions & 0 deletions package/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# @vlandoss/env

## 0.3.0

### Minor Changes

- [#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).

**Migration — drop the `await`:**

```diff
- 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 the `await` keeps the module asynchronous — so a config file that keeps it still can't be `require()`d. Remove it.

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.

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` — needs `require(esm)` (native in Bun/Deno, **Node ≥22.12**).
- `.json` — works on any supported Node.

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.

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.

## 0.2.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vlandoss/env",
"version": "0.2.1",
"version": "0.3.0",
"description": "Contract-first environment configuration with typed schemas",
"homepage": "https://github.com/variableland/env/tree/main/package#readme",
"bugs": {
Expand Down