Skip to content

🎥 Make videos programmatically with React

`remotion`: Obfuscate process.env.NODE_ENV so Vite doesn't replace it

Jonny Burger3b4ee078c3b5
diff --git a/packages/core/src/setup-env-variables.ts b/packages/core/src/setup-env-variables.ts
index 0500f683be..02023e5e7b 100644
--- a/packages/core/src/setup-env-variables.ts
+++ b/packages/core/src/setup-env-variables.ts
@@ -1,5 +1,12 @@
import {getRemotionEnvironment} from './get-remotion-environment.js';
+// https://github.com/remotion-dev/remotion/issues/3412#issuecomment-1910120552
+// eslint-disable-next-line no-useless-concat
+function getEnvVar() {
+ const parts = ['proc', 'ess', '.', 'en', 'v', '.', 'NOD', 'E_EN', 'V'];
+ return parts.join('');
+}
+
const getEnvVariables = (): Record<string, string> => {
if (getRemotionEnvironment().isRendering) {
const param = window.remotion_envVariables;
@@ -13,9 +20,7 @@ const getEnvVariables = (): Record<string, string> => {
// For the Studio, we already set the environment variables in index-html.ts.
// We just add NODE_ENV here.
if (!process.env.NODE_ENV) {
- // https://github.com/remotion-dev/remotion/issues/3412#issuecomment-1910120552
- // eslint-disable-next-line no-useless-concat
- throw new Error('process.en' + '' + 'v.NODE_ENV is not set');
+ throw new Error(`${getEnvVar()} is not set`);
}
return {