From 0bd4b89f1d0881b36a6e3aaf0d313875ad8da970 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 01:47:28 +0000 Subject: [PATCH 1/3] chore(deps): update dependency dotenv-expand to v11 --- packages/vite/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/package.json b/packages/vite/package.json index 83ee75fafd120c..50f4b7dfb52ce0 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -117,7 +117,7 @@ "debug": "^4.3.4", "dep-types": "link:./src/types", "dotenv": "^16.4.1", - "dotenv-expand": "^10.0.0", + "dotenv-expand": "^11.0.3", "es-module-lexer": "^1.4.1", "escape-html": "^1.0.3", "estree-walker": "^3.0.3", From 3a46a0a6a71e2741f4669b9cef55835ae1c2a3e3 Mon Sep 17 00:00:00 2001 From: bluwy Date: Mon, 12 Feb 2024 20:25:38 +0800 Subject: [PATCH 2/3] chore: fix dotenv-expand --- package.json | 1 - packages/vite/src/node/env.ts | 9 +++++---- patches/dotenv-expand@10.0.0.patch | 18 ------------------ pnpm-lock.yaml | 14 ++++++-------- 4 files changed, 11 insertions(+), 31 deletions(-) delete mode 100644 patches/dotenv-expand@10.0.0.patch diff --git a/package.json b/package.json index 66de88749b8c97..5855b006e74980 100644 --- a/package.json +++ b/package.json @@ -125,7 +125,6 @@ }, "patchedDependencies": { "chokidar@3.6.0": "patches/chokidar@3.6.0.patch", - "dotenv-expand@10.0.0": "patches/dotenv-expand@10.0.0.patch", "sirv@2.0.4": "patches/sirv@2.0.4.patch" }, "peerDependencyRules": { diff --git a/packages/vite/src/node/env.ts b/packages/vite/src/node/env.ts index 1052f894ec8c2d..897524612f3c7d 100644 --- a/packages/vite/src/node/env.ts +++ b/packages/vite/src/node/env.ts @@ -1,7 +1,7 @@ import fs from 'node:fs' import path from 'node:path' import { parse } from 'dotenv' -import { expand } from 'dotenv-expand' +import { type DotenvPopulateInput, expand } from 'dotenv-expand' import { arraify, normalizePath, tryStatSync } from './utils' import type { UserConfig } from './config' @@ -49,9 +49,10 @@ export function loadEnv( process.env.BROWSER_ARGS = parsed.BROWSER_ARGS } - // let environment variables use each other - // `expand` patched in patches/dotenv-expand@9.0.0.patch - expand({ parsed }) + // let environment variables use each other. make a copy of `process.env` so that `dotenv-expand` + // doesn't re-assign the expanded values to the global `process.env`. + const processEnv = { ...process.env } as DotenvPopulateInput + expand({ parsed, processEnv }) // only keys that start with prefix are exposed to client for (const [key, value] of Object.entries(parsed)) { diff --git a/patches/dotenv-expand@10.0.0.patch b/patches/dotenv-expand@10.0.0.patch deleted file mode 100644 index ae483e0f3d3c7c..00000000000000 --- a/patches/dotenv-expand@10.0.0.patch +++ /dev/null @@ -1,18 +0,0 @@ -diff --git a/lib/main.js b/lib/main.js -index 79d973c22f06403bfee45ff122bd384841c30da8..9392de262140f8f336146bef2419794532e4170f 100644 ---- a/lib/main.js -+++ b/lib/main.js -@@ -69,9 +69,10 @@ function expand (config) { - ) - } - -- for (const processKey in config.parsed) { -- environment[processKey] = config.parsed[processKey] -- } -+ // PATCH: don't write to process.env -+ // for (const processKey in config.parsed) { -+ // environment[processKey] = config.parsed[processKey] -+ // } - - return config - } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d618a5768358cc..f54627328aa2b0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,9 +13,6 @@ patchedDependencies: chokidar@3.6.0: hash: bckcfsslxcffppz65mxcq6naau path: patches/chokidar@3.6.0.patch - dotenv-expand@10.0.0: - hash: weuqf2vlv5b5g6cikeo4slurbm - path: patches/dotenv-expand@10.0.0.patch sirv@2.0.4: hash: amdes53ifqfntejkflpaq5ifce path: patches/sirv@2.0.4.patch @@ -319,8 +316,8 @@ importers: specifier: ^16.4.1 version: 16.4.1 dotenv-expand: - specifier: ^10.0.0 - version: 10.0.0(patch_hash=weuqf2vlv5b5g6cikeo4slurbm) + specifier: ^11.0.3 + version: 11.0.3 es-module-lexer: specifier: ^1.4.1 version: 1.4.1 @@ -5596,11 +5593,12 @@ packages: is-obj: 2.0.0 dev: true - /dotenv-expand@10.0.0(patch_hash=weuqf2vlv5b5g6cikeo4slurbm): - resolution: {integrity: sha512-GopVGCpVS1UKH75VKHGuQFqS1Gusej0z4FyQkPdwjil2gNIv+LNsqBlboOzpJFZKVT95GkCyWJbBSdFEFUWI2A==} + /dotenv-expand@11.0.3: + resolution: {integrity: sha512-qkK+MLTvZ86oq4sjMqGpUN/38SQ/J37mny88CsEUFFjb2MBVz06a809ri0QeVDXpxkvZkXzqjGUb0M1R6n3OGw==} engines: {node: '>=12'} + dependencies: + dotenv: 16.4.1 dev: true - patched: true /dotenv@16.4.1: resolution: {integrity: sha512-CjA3y+Dr3FyFDOAMnxZEGtnW9KBR2M0JvvUtXNW+dYJL5ROWxP9DUHCwgFqpMk0OXCc0ljhaNTr2w/kutYIcHQ==} From 46aa1038f831da9b5f990f188f64101865fdbf35 Mon Sep 17 00:00:00 2001 From: bluwy Date: Mon, 12 Feb 2024 20:39:13 +0800 Subject: [PATCH 3/3] chore: update lockfile --- pnpm-lock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a0f7c4c59041db..0bcfb23744d3f8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5593,7 +5593,7 @@ packages: resolution: {integrity: sha512-qkK+MLTvZ86oq4sjMqGpUN/38SQ/J37mny88CsEUFFjb2MBVz06a809ri0QeVDXpxkvZkXzqjGUb0M1R6n3OGw==} engines: {node: '>=12'} dependencies: - dotenv: 16.4.1 + dotenv: 16.4.2 dev: true /dotenv@16.4.2: