Skip to content

chore(deps): replace dotenv with Node.js builtins#2185

Open
Xavrir wants to merge 3 commits intowxt-dev:mainfrom
Xavrir:fix/replace-dotenv-2176
Open

chore(deps): replace dotenv with Node.js builtins#2185
Xavrir wants to merge 3 commits intowxt-dev:mainfrom
Xavrir:fix/replace-dotenv-2176

Conversation

@Xavrir
Copy link

@Xavrir Xavrir commented Mar 7, 2026

Drop dotenv in favor of Node's built-in node:util#parseEnv (22+), with a lightweight polyfill for older runtimes. Follows the same approach Vite uses in their loadEnv.

  • New parse-env.ts utility: tries native parseEnv at load time, falls back to a polyfill that matches native semantics (export prefix, inline # comments, quote handling)
  • loadEnv stays synchronous — no async infection
  • Fixed env-file precedence: files are now loaded least-specific → most-specific so that .env.production.chrome.local correctly overrides .env
  • Kept dotenv-expand for variable expansion

Ref: Vite's loadEnv

Closes #2176

Use node:util parseEnv instead of dotenv package for parsing .env files.
Includes a polyfill for Node <22 compatibility.
Keep dotenv-expand for variable expansion support.

Reference: Vite's loadEnv implementation
https://github.com/vitejs/vite/blob/a704abc4e6f1528837030cf92cb7a2de65da54cc/packages/vite/src/node/env.ts

Closes wxt-dev#2176
@Xavrir Xavrir requested a review from aklinker1 as a code owner March 7, 2026 20:28
@netlify
Copy link

netlify bot commented Mar 7, 2026

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit 71d517b
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/69b022209a74da0008883a9a
😎 Deploy Preview https://deploy-preview-2185--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added the pkg/wxt Includes changes to the `packages/wxt` directory label Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg/wxt Includes changes to the `packages/wxt` directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace dotenv with builtins

1 participant