Skip to content

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

Closed
Xavrir wants to merge 3 commits into
wxt-dev:mainfrom
Xavrir:fix/replace-dotenv-2176
Closed

Xavrir wants to merge 3 commits into
wxt-dev:mainfrom
Xavrir:fix/replace-dotenv-2176

Conversation

@Xavrir

@Xavrir Xavrir commented Mar 7, 2026 •

Copy link
Copy Markdown
Contributor

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

netlify Bot commented Mar 7, 2026 •

Copy link
Copy Markdown

✅ 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
@PatrykKuniczak

Copy link
Copy Markdown
Collaborator

Good work :)

Maybe we can enforce users to use 22+ here:

"node": ">=18.20.3"

IMO it's good idea, because anyway the latest LTS is 24 and we're about to have 26 as newest LTS.

And we can avoid your fallback.
But @aklinker1 need to support that idea

@aklinker1

Copy link
Copy Markdown
Member

Ugh, so it's only node 22+... Can you change this PR to merge into the major branch? We'll have to do this in a breaking change.

@aklinker1

aklinker1 commented Mar 17, 2026 •

Copy link
Copy Markdown
Member

Actually, sorry, noticed this was a duplicate PR... Closing in favor of #2181

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

3 participants