From c0c11642309c37d8798d395cdbe941ba7345da39 Mon Sep 17 00:00:00 2001 From: Deniz Date: Fri, 7 Jun 2024 00:00:30 +0300 Subject: [PATCH 1/2] replace destructuring with object assignment --- packages/bundler-plugin-core/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/bundler-plugin-core/src/index.ts b/packages/bundler-plugin-core/src/index.ts index a04b03fa..31bcbd19 100644 --- a/packages/bundler-plugin-core/src/index.ts +++ b/packages/bundler-plugin-core/src/index.ts @@ -85,7 +85,7 @@ export function sentryUnpluginFactory({ ); // NOTE: Do not use the dotenv.config API directly to read the dotenv file! For some ungodly reason, it falls back to reading `${process.cwd()}/.env` which is absolutely not what we want. const dotenvResult = dotenv.parse(dotenvFile); - process.env = { ...process.env, ...dotenvResult }; + process.env = Object.assign(process.env, dotenvResult); logger.info('Using environment variables configured in ".env.sentry-build-plugin".'); } catch (e: unknown) { // Ignore "file not found" errors but throw all others From 81f3fe0110cb726cb1e01f6d548bb9395097ee72 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 10 Jun 2024 09:58:14 +0200 Subject: [PATCH 2/2] clean up --- packages/bundler-plugin-core/src/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/bundler-plugin-core/src/index.ts b/packages/bundler-plugin-core/src/index.ts index 31bcbd19..5680103a 100644 --- a/packages/bundler-plugin-core/src/index.ts +++ b/packages/bundler-plugin-core/src/index.ts @@ -85,7 +85,11 @@ export function sentryUnpluginFactory({ ); // NOTE: Do not use the dotenv.config API directly to read the dotenv file! For some ungodly reason, it falls back to reading `${process.cwd()}/.env` which is absolutely not what we want. const dotenvResult = dotenv.parse(dotenvFile); - process.env = Object.assign(process.env, dotenvResult); + + // Vite has a bug/behaviour where spreading into process.env will cause it to crash + // https://github.com/vitest-dev/vitest/issues/1870#issuecomment-1501140251 + Object.assign(process.env, dotenvResult); + logger.info('Using environment variables configured in ".env.sentry-build-plugin".'); } catch (e: unknown) { // Ignore "file not found" errors but throw all others