Skip to content

πŸŽ₯ Make videos programmatically with React

include warning for version mismatches

Jonny Burgerb3ac163f25df
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index 109796e6cc..c4869f8bf8 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -26,7 +26,7 @@ declare global {
remotion_finishedBuilding: undefined | (() => void);
siteVersion: '4';
remotion_version: string;
- remotion_imported: boolean;
+ remotion_imported: string | boolean;
}
}
diff --git a/packages/core/src/internals.ts b/packages/core/src/internals.ts
index 52c5466bd1..b5ee16283e 100644
--- a/packages/core/src/internals.ts
+++ b/packages/core/src/internals.ts
@@ -45,7 +45,6 @@ import {validateDimension} from './validation/validate-dimensions';
import {validateDurationInFrames} from './validation/validate-duration-in-frames';
import {validateFps} from './validation/validate-fps';
import {validateOffthreadVideoImageFormat} from './validation/validate-offthreadvideo-image-format';
-import {VERSION} from './version';
import type {
MediaVolumeContextValue,
SetMediaVolumeContextValue,
@@ -100,7 +99,6 @@ export const Internals = {
CanUseRemotionHooksProvider,
CanUseRemotionHooks,
enableLegacyRemotionConfig,
- VERSION,
};
type WebpackConfiguration = Configuration;
diff --git a/packages/core/src/multiple-versions-warning.ts b/packages/core/src/multiple-versions-warning.ts
index ae3056d619..e94192766f 100644
--- a/packages/core/src/multiple-versions-warning.ts
+++ b/packages/core/src/multiple-versions-warning.ts
@@ -1,19 +1,32 @@
+import {truthy} from './truthy';
+import {VERSION} from './version';
+
export const checkMultipleRemotionVersions = () => {
if (typeof globalThis === 'undefined') {
return;
}
- if (
+ const alreadyImported =
(globalThis as unknown as Window).remotion_imported ||
- (typeof window !== 'undefined' && window.remotion_imported)
- ) {
+ (typeof window !== 'undefined' && window.remotion_imported);
+
+ if (alreadyImported) {
throw new TypeError(
- '🚨 Multiple versions of Remotion detected. This will cause things to break in an unexpected way.\nCheck that all your Remotion packages are on the same version. You can also run `npx remotion versions` from your terminal to see which versions are mismatching.'
+ `🚨 Multiple versions of Remotion detected: ${[
+ VERSION,
+ typeof alreadyImported === 'string'
+ ? alreadyImported
+ : 'an older version',
+ ]
+ .filter(truthy)
+ .join(
+ ' and '
+ )}. This will cause things to break in an unexpected way.\nCheck that all your Remotion packages are on the same version. If your dependencies depend on Remotion, make them peer dependencies. You can also run \`npx remotion versions\` from your terminal to see which versions are mismatching.`
);
}
(globalThis as unknown as Window).remotion_imported = true;
if (typeof window !== 'undefined') {
- window.remotion_imported = true;
+ window.remotion_imported = VERSION;
}
};