diff --git a/.changeset/loadconfig-sync.md b/.changeset/loadconfig-sync.md deleted file mode 100644 index d3f1939..0000000 --- a/.changeset/loadconfig-sync.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -"@vlandoss/env": minor ---- - -**`loadConfig` (`@vlandoss/env/fs`) is now synchronous.** It loads the config with `require()` and returns `Config` 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. diff --git a/package/CHANGELOG.md b/package/CHANGELOG.md index deccf73..42ba577 100644 --- a/package/CHANGELOG.md +++ b/package/CHANGELOG.md @@ -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` 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 diff --git a/package/package.json b/package/package.json index 3251a38..bde4d37 100644 --- a/package/package.json +++ b/package/package.json @@ -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": {