🎥 Make videos programmatically with React
if cli is installed, we can override
Jonny Burger56166d7ee68c
diff --git a/packages/cli/src/index.tsx b/packages/cli/src/index.tsxindex e84daadb37..81c809b5c6 100644--- a/packages/cli/src/index.tsx+++ b/packages/cli/src/index.tsx@@ -1,3 +1,4 @@+import {overrideRemotion} from '@remotion/config';import {RenderInternals} from '@remotion/renderer';import {chalk} from './chalk';import {checkNodeVersion} from './check-version';@@ -31,6 +32,7 @@ import {} from './versions';export const cli = async () => {+ overrideRemotion();const args = process.argv;const command = args[2];diff --git a/packages/config/src/index.ts b/packages/config/src/index.tsindex 0fc57b1aec..b2392d5ff4 100644--- a/packages/config/src/index.ts+++ b/packages/config/src/index.ts@@ -1,3 +1,5 @@+import {Config as RemotionConfig, Internals} from 'remotion';+import {Config} from './config';import {getBrowser} from './config/browser';import {getBrowserExecutable} from './config/browser-executable';import {@@ -36,7 +38,7 @@ import {getStillFrame, setStillFrame} from './config/still-frame';import {getCurrentPuppeteerTimeout} from './config/timeout';import {getWebpackCaching} from './config/webpack-caching';-export {Config} from './config';+export {Config};export const ConfigInternals = {getRange,@@ -73,3 +75,8 @@ export const ConfigInternals = {getMaxTimelineTracks,defaultOverrideFunction,};++export const overrideRemotion = () => {+ Object.assign(RemotionConfig, Config);+ Internals.enableLegacyRemotionConfig();+};diff --git a/packages/core/src/config.ts b/packages/core/src/config.tsindex c3be75adcb..8a5fa33a72 100644--- a/packages/core/src/config.ts+++ b/packages/core/src/config.ts@@ -225,4 +225,22 @@ export type ConfigType = {};export type {Concurrency, WebpackConfiguration, WebpackOverrideFn};-export const Conf = {} as unknown as ConfigType;+const conf = {} as unknown as ConfigType;++let enabled = false;++export const Config = new Proxy(conf, {+ get(target, prop, receiver) {+ if (!enabled) {+ throw new Error(+ 'To use the Remotion config file, you need to have @remotion/cli installed.\n- Make sure that all versions of Remotion are the same.\n- Make sure that @remotion/cli is installed.\n- Make sure Config is imported from "@remotion/cli", not "remotion".'+ );+ }++ return Reflect.get(target, prop, receiver);+ },+});++export const enableLegacyRemotionConfig = () => {+ enabled = true;+};diff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex 83aeffa326..fe1023b4bd 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -44,7 +44,7 @@ export * from './AbsoluteFill';export * from './audio';export * from './Composition';export {SmallTCompMetadata, TAsset, TCompMetadata} from './CompositionManager';-export {ConfigType} from './config';+export {Config, ConfigType} from './config';export {getInputProps} from './config/input-props';export * from './delay-render';export * from './easing';diff --git a/packages/core/src/internals.ts b/packages/core/src/internals.tsindex 97ffa6fb36..32a82dc4d3 100644--- a/packages/core/src/internals.ts+++ b/packages/core/src/internals.ts@@ -1,3 +1,6 @@+import type {Configuration} from 'webpack';+import {enableLegacyRemotionConfig} from './config';+import {SharedAudioContext,SharedAudioContextProvider,@@ -105,10 +108,9 @@ export const Internals = {validateOffthreadVideoImageFormat,CanUseRemotionHooksProvider,CanUseRemotionHooks,+ enableLegacyRemotionConfig,};-import type {Configuration} from 'webpack';-type WebpackConfiguration = Configuration;type WebpackOverrideFn = (