🎥 Make videos programmatically with React
Pin Transformers auxiliary installs
JonnyBurgerc17c64bfa53b
diff --git a/packages/cli/src/extra-packages.ts b/packages/cli/src/extra-packages.tsindex af6fbeac19..86bc563094 100644--- a/packages/cli/src/extra-packages.ts+++ b/packages/cli/src/extra-packages.ts@@ -1,15 +1,16 @@+import {extraPackages} from '@remotion/studio-shared';+export const EXTRA_PACKAGES: Record<string, string> = {- mediabunny: '1.55.5',- '@mediabunny/ac3': '1.55.5',- '@mediabunny/dts': '1.55.5',+ ...Object.fromEntries(+ extraPackages.map(({name, version}) => [name, version]),+ ),'@mediabunny/mp3-encoder': '1.55.5','@mediabunny/aac-encoder': '1.55.5','@mediabunny/flac-encoder': '1.55.5',- '@mediabunny/prores': '1.55.5',- zod: '4.5.4',};export const EXTRA_PACKAGES_DOCS: Record<string, string> = {+ '@huggingface/transformers': 'https://www.remotion.dev/docs/whisper-webgpu',mediabunny: 'https://www.remotion.dev/docs/mediabunny/version','@mediabunny/ac3':'https://www.remotion.dev/docs/mediabunny/formats#ac-3-and-e-ac-3',diff --git a/packages/cli/src/test/extra-packages.test.ts b/packages/cli/src/test/extra-packages.test.tsnew file mode 100644index 0000000000..2bd4e6dd08--- /dev/null+++ b/packages/cli/src/test/extra-packages.test.ts@@ -0,0 +1,11 @@+import {expect, test} from 'bun:test';+import {extraPackages} from '@remotion/studio-shared';+import {EXTRA_PACKAGES} from '../extra-packages';++test('uses the shared recommended versions for auxiliary packages', () => {+ for (const {name, version} of extraPackages) {+ expect(EXTRA_PACKAGES[name]).toBe(version);+ }++ expect(EXTRA_PACKAGES['@huggingface/transformers']).toBe('4.2.0');+});diff --git a/packages/docs/components/Installation.tsx b/packages/docs/components/Installation.tsxindex 21313307f7..e4db3a789f 100644--- a/packages/docs/components/Installation.tsx+++ b/packages/docs/components/Installation.tsx@@ -4,6 +4,7 @@ import CodeBlock from '@theme/CodeBlock';import TabItem from '@theme/TabItem';// @ts-expect-errorimport Tabs from '@theme/Tabs';+import {extraPackages} from '@remotion/studio-shared';import React from 'react';import {VERSION} from 'remotion';@@ -54,12 +55,18 @@ export const Installation: React.FC<{}const pkgList = pkg.split(' ');+ const extraPackageVersions = new Map(+ extraPackages.map(({name, version}) => [name, version]),+ );- const allRemotionOnly = pkgList.every(- (p) => p.startsWith('@remotion/') || p === 'remotion',+ const allSupportedByRemotionCli = pkgList.every(+ (p) =>+ p.startsWith('@remotion/') ||+ p === 'remotion' ||+ extraPackageVersions.has(p),);const showRemotionCli =- allRemotionOnly &&+ allSupportedByRemotionCli &&!pkgList.includes('remotion') &&!pkgList.includes('@remotion/cli');@@ -69,6 +76,10 @@ export const Installation: React.FC<{return `${p}@${VERSION}`;}+ if (allSupportedByRemotionCli && extraPackageVersions.has(p)) {+ return `${p}@${extraPackageVersions.get(p)}`;+ }+return p;}).join(' ');diff --git a/packages/docs/docs/cli/add.mdx b/packages/docs/docs/cli/add.mdxindex e89a50f571..61ab57e5b9 100644--- a/packages/docs/docs/cli/add.mdx+++ b/packages/docs/docs/cli/add.mdx@@ -7,7 +7,7 @@ crumb: CLI ReferenceAdds one or more Remotion packages to your project with the same version as your other Remotion packages.-Also supports adding `zod` and `mediabunny` with the correct version for your Remotion installation.+Also supports adding auxiliary packages such as `zod`, `mediabunny`, and `@huggingface/transformers` with the recommended version for your Remotion installation.```npx remotion add <package-name...>@@ -29,7 +29,7 @@ npx remotion add @remotion/transitions @remotion/three @remotion/lottieThis command will:-1. Verify that all package names are valid Remotion packages (or supported extra packages: `zod`, `mediabunny`)+1. Verify that all package names are valid Remotion packages or supported auxiliary packages2. Check which packages are already installed (and skip them)3. Detect the version of your currently installed Remotion packages4. Install the specified packages with the matching versiondiff --git a/packages/docs/docs/whisper-webgpu/index.mdx b/packages/docs/docs/whisper-webgpu/index.mdxindex 66ab2c90bf..aeeed1647f 100644--- a/packages/docs/docs/whisper-webgpu/index.mdx+++ b/packages/docs/docs/whisper-webgpu/index.mdx@@ -12,9 +12,7 @@ import {TableOfContents} from './table-of-contents';## Installation-<Installation pkg="@remotion/whisper-webgpu @huggingface/[email protected]" />--`@huggingface/transformers` is a peer dependency. Remotion recommends and tests version `4.2.0` so that multiple browser-based AI workflows can share one Transformers.js runtime.+<Installation pkg="@remotion/whisper-webgpu @huggingface/transformers" />## Examplediff --git a/packages/docs/src/test/installation.test.tsx b/packages/docs/src/test/installation.test.tsxnew file mode 100644index 0000000000..7a0e699f0d--- /dev/null+++ b/packages/docs/src/test/installation.test.tsx@@ -0,0 +1,25 @@+import {expect, mock, test} from 'bun:test';+import React from 'react';+import {renderToStaticMarkup} from 'react-dom/server';++mock.module('@theme/CodeBlock', () => ({+ default: ({children}: {children: React.ReactNode}) => <pre>{children}</pre>,+}));+mock.module('@theme/TabItem', () => ({+ default: ({children}: {children: React.ReactNode}) => <div>{children}</div>,+}));+mock.module('@theme/Tabs', () => ({+ default: ({children}: {children: React.ReactNode}) => <div>{children}</div>,+}));++test('pins auxiliary packages in every installation command', async () => {+ const {Installation} = await import('../../components/Installation');+ const markup = renderToStaticMarkup(+ <Installation pkg="@remotion/whisper-webgpu @huggingface/transformers" />,+ );++ expect(markup).toContain(+ 'npx remotion add @remotion/whisper-webgpu @huggingface/transformers',+ );+ expect(markup).toContain('@huggingface/[email protected]');+});diff --git a/packages/studio-shared/src/package-info.ts b/packages/studio-shared/src/package-info.tsindex af53d3b799..c224cac767 100644--- a/packages/studio-shared/src/package-info.ts+++ b/packages/studio-shared/src/package-info.ts@@ -127,6 +127,12 @@ export type ExtraPackage = {};export const extraPackages: ExtraPackage[] = [+ {+ name: '@huggingface/transformers',+ version: '4.2.0',+ description: 'Machine learning models in the browser',+ docsUrl: 'https://huggingface.co/docs/transformers.js',+ },{name: 'mediabunny',version: '1.55.5',