🎥 Make videos programmatically with React
fix node env
Jonny Burger755410ff4993
diff --git a/packages/core/src/setup-env-variables.ts b/packages/core/src/setup-env-variables.tsindex 57469820e2..2d03b8b16f 100644--- a/packages/core/src/setup-env-variables.ts+++ b/packages/core/src/setup-env-variables.ts@@ -10,17 +10,15 @@ const getEnvVariables = (): Record<string, string> => {return {...JSON.parse(param), NODE_ENV: process.env.NODE_ENV};}- if (getRemotionEnvironment().isStudio) {- // For the Studio, we already set the environment variables in index-html.ts.- // We just add NODE_ENV here.- return {- NODE_ENV: 'development',- };+ // For the Studio, we already set the environment variables in index-html.ts.+ // We just add NODE_ENV here.+ if (!process.env.NODE_ENV) {+ throw new Error('process.env.NODE_ENV is not set');}- throw new Error(- 'Can only call getEnvVariables() if environment is `rendering` or `preview`',- );+ return {+ NODE_ENV: process.env.NODE_ENV,+ };};export const setupEnvVariables = () => {diff --git a/packages/example/src/DropDots/DropDots.tsx b/packages/example/src/DropDots/DropDots.tsxindex f52f3cccaf..481bfd33b2 100644--- a/packages/example/src/DropDots/DropDots.tsx+++ b/packages/example/src/DropDots/DropDots.tsx@@ -25,45 +25,43 @@ const DropDots: React.FC<{const cycle = 15;const iteration = Math.floor(frame / cycle);const {height, width} = useVideoConfig();- const dots = new Array(process.env.NODE_ENV === 'development' ? 45 : 45)- .fill(true)- .map((_x, i) => {- const startX = random(`x-${i}-${iteration}`) * width;- const startY = random(`y-${i}-${iteration}`) * height;- const startRotation = random(`rotation-${i}-${iteration}`) * 360;- return {- startX,- endX:- startX +- interpolate(random(`x-end-${i}-${iteration}`), [0, 1], [-600, 600]),- startY,- endY:- startY +- interpolate(random(`y-end-${i}-${iteration}`), [0, 1], [-600, 600]),- startRotation,- endRotation:- startRotation +- interpolate(random(`rotatad-${i}`), [0, 1], [-180, 180]),- size: interpolate(- random(`size-${i}-${iteration}`),- [0, 0.9, 0.901, 1],- [40, 40, 160, 160],- ),+ const dots = new Array(45).fill(true).map((_x, i) => {+ const startX = random(`x-${i}-${iteration}`) * width;+ const startY = random(`y-${i}-${iteration}`) * height;+ const startRotation = random(`rotation-${i}-${iteration}`) * 360;+ return {+ startX,+ endX:+ startX ++ interpolate(random(`x-end-${i}-${iteration}`), [0, 1], [-600, 600]),+ startY,+ endY:+ startY ++ interpolate(random(`y-end-${i}-${iteration}`), [0, 1], [-600, 600]),+ startRotation,+ endRotation:+ startRotation ++ interpolate(random(`rotatad-${i}`), [0, 1], [-180, 180]),+ size: interpolate(+ random(`size-${i}-${iteration}`),+ [0, 0.9, 0.901, 1],+ [40, 40, 160, 160],+ ),- background:- gradients[- Math.floor(random(`color-${i}-${iteration}`) * gradients.length)- ],- opacity: interpolate(- random(`opacity-${i}-${iteration}`),- [0, 1],- [0.83, 0.95],- ),- gradId: random(`gradient-${i}-${iteration}`),- hasShine: random(`shine-${i}`) > 0.6,- shineOpacity: random(`shine-opacity-${i}-${iteration}`) * 0.7,- };- });+ background:+ gradients[+ Math.floor(random(`color-${i}-${iteration}`) * gradients.length)+ ],+ opacity: interpolate(+ random(`opacity-${i}-${iteration}`),+ [0, 1],+ [0.83, 0.95],+ ),+ gradId: random(`gradient-${i}-${iteration}`),+ hasShine: random(`shine-${i}`) > 0.6,+ shineOpacity: random(`shine-opacity-${i}-${iteration}`) * 0.7,+ };+ });const progress = interpolate(frame % cycle, [0, cycle], [0, 1]);return (<div style={{width, height, opacity}}>diff --git a/packages/example/src/SkipZeroFrame/index.tsx b/packages/example/src/SkipZeroFrame/index.tsxindex 2021a0a9bf..25a198256d 100644--- a/packages/example/src/SkipZeroFrame/index.tsx+++ b/packages/example/src/SkipZeroFrame/index.tsx@@ -1,5 +1,5 @@import React from 'react';-import {useCurrentFrame} from 'remotion';+import {getRemotionEnvironment, useCurrentFrame} from 'remotion';// Try to render using:// npx remotion render src/index.ts skip-zero-frame --frames=10-20 skip.mp4@@ -7,7 +7,7 @@ import {useCurrentFrame} from 'remotion';export const SkipZeroFrame: React.FC = () => {const frame = useCurrentFrame();- if (frame === 0 && process.env.NODE_ENV === 'production') {+ if (frame === 0 && getRemotionEnvironment().isRendering) {throw new Error('should not render frame 0');}