Skip to content

🎥 Make videos programmatically with React

Use browser-safe concurrency validation to fix webpack bundle error

JonnyBurgerb26999629291
diff --git a/packages/renderer/src/options/concurrency.tsx b/packages/renderer/src/options/concurrency.tsx
index da6de3942d..1a3907df03 100644
--- a/packages/renderer/src/options/concurrency.tsx
+++ b/packages/renderer/src/options/concurrency.tsx
@@ -1,4 +1,3 @@
-import {validateConcurrency} from '../validate-concurrency';
import type {AnyRemotionOption} from './option';
export type Concurrency = number | string | null;
@@ -7,6 +6,30 @@ let currentConcurrency: Concurrency = null;
const cliFlag = 'concurrency' as const;
+// Browser-safe validation that does not pull in Node.js modules
+// (validate-concurrency.ts imports node:child_process via get-cpu-count.ts)
+const validateConcurrencyValue = (value: unknown, setting: string) => {
+ if (typeof value === 'undefined' || value === null) {
+ return;
+ }
+
+ if (typeof value !== 'number' && typeof value !== 'string') {
+ throw new Error(setting + ' must a number or a string but is ' + value);
+ }
+
+ if (typeof value === 'number') {
+ if (value % 1 !== 0) {
+ throw new Error(setting + ' must be an integer, but is ' + value);
+ }
+ } else if (!/^\d+(\.\d+)?%$/.test(value)) {
+ throw new Error(
+ `${setting} must be a number or percentage, but is ${JSON.stringify(
+ value,
+ )}`,
+ );
+ }
+};
+
export const concurrencyOption = {
name: 'Concurrency',
cliFlag,
@@ -23,11 +46,7 @@ export const concurrencyOption = {
getValue: ({commandLine}) => {
if (commandLine[cliFlag] !== undefined) {
const value = commandLine[cliFlag] as Concurrency;
- validateConcurrency({
- value,
- setting: 'concurrency',
- checkIfValidForCurrentMachine: false,
- });
+ validateConcurrencyValue(value, 'concurrency');
return {
source: 'cli',
@@ -48,11 +67,7 @@ export const concurrencyOption = {
};
},
setConfig: (value) => {
- validateConcurrency({
- value,
- setting: 'Config.setConcurrency',
- checkIfValidForCurrentMachine: false,
- });
+ validateConcurrencyValue(value, 'Config.setConcurrency');
currentConcurrency = value;
},