Skip to content

fix: missing create env functions - #27

Merged
brunozoric merged 4 commits into
mainfrom
bruno/fix/env
Jul 16, 2026
Merged

fix: missing create env functions#27
brunozoric merged 4 commits into
mainfrom
bruno/fix/env

Conversation

@brunozoric

Copy link
Copy Markdown
Contributor

Summary

  • Add createProcessEnv() factory to @webiny/stdlib/node — returns Env.Interface backed by process.env by default, or a custom variables record when provided
  • Add createBrowserEnv() factory to @webiny/stdlib/browser — returns Env.Interface backed by a required variables record
  • Both allow using Env outside of DI

Usage

Node

import { createProcessEnv } from "@webiny/stdlib/node";

// Default: reads from process.env
const env = createProcessEnv();

// Custom: pre-process variables before injection
const env = createProcessEnv({
  variables: { ...process.env, MY_VAR: "overridden" }
});

Browser

import { createBrowserEnv } from "@webiny/stdlib/browser";

const env = createBrowserEnv({
  variables: { API_URL: "https://api.example.com" }
});

Breaking changes

- BrowserEnvFeature.register() now requires { variables } param (was optional)
- ProcessEnvFeature.register() accepts optional { variables } param to override process.env

brunozoric and others added 4 commits July 16, 2026 13:01
Env implementations can now be used outside DI via standalone factory
functions, matching the pattern already established by other tools
(createPathTool, createFileTool, etc.).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ProcessEnv now takes an optional variables record instead of reading
process.env directly. Defaults to process.env when not provided.
Enables pre-processing env vars before injection.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
BrowserEnv has no meaning without variables. Feature now requires
the variables record; test updated to pass empty record instead
of undefined for the no-variables scenario.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@brunozoric brunozoric self-assigned this Jul 16, 2026
@brunozoric
brunozoric merged commit 93f9f83 into main Jul 16, 2026
16 checks passed
@brunozoric
brunozoric deleted the bruno/fix/env branch July 16, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant