🎥 Make videos programmatically with React
allow optional dependencies
Jonny Burgerc507c8edddc8
diff --git a/packages/bundler/src/optional-depdendencies.ts b/packages/bundler/src/optional-depdendencies.tsnew file mode 100644index 0000000000..d92614977a--- /dev/null+++ b/packages/bundler/src/optional-depdendencies.ts@@ -0,0 +1,32 @@+// When Webpack cannot resolve these dependencies, it will not print an error message.++import type {Compiler} from 'webpack';++const OPTIONAL_DEPENDENCIES = [+ 'zod',+ '@remotion/zod-types',+ 'react-native-reanimated',+ 'react-native-reanimated/package.json',+];++export class AllowOptionalDependenciesPlugin {+ filter(error: Error) {+ for (const dependency of OPTIONAL_DEPENDENCIES) {+ if (error.message.includes(`Can't resolve '${dependency}'`)) {+ return false;+ }+ }++ return true;+ }++ apply(compiler: Compiler) {+ compiler.hooks.afterEmit.tap(+ 'AllowOptionalDependenciesPlugin',+ (compilation) => {+ compilation.errors = compilation.errors.filter(this.filter);+ compilation.warnings = compilation.warnings.filter(this.filter);+ }+ );+ }+}diff --git a/packages/bundler/src/webpack-config.ts b/packages/bundler/src/webpack-config.tsindex 145422c61d..a69df62605 100644--- a/packages/bundler/src/webpack-config.ts+++ b/packages/bundler/src/webpack-config.ts@@ -5,6 +5,7 @@ import {Internals} from 'remotion';import webpack, {ProgressPlugin} from 'webpack';import type {LoaderOptions} from './esbuild-loader/interfaces';import {ReactFreshWebpackPlugin} from './fast-refresh';+import {AllowOptionalDependenciesPlugin} from './optional-depdendencies';import {jsonStringifyWithCircularReferences} from './stringify-with-circular-references';import {getWebpackCacheName} from './webpack-cache';import esbuild = require('esbuild');@@ -108,6 +109,7 @@ export const webpackConfig = ({[`process.env.${Internals.ENV_VARIABLES_ENV_NAME}`]:JSON.stringify(envVariables),}),+ new AllowOptionalDependenciesPlugin(),]: [new ProgressPlugin((p) => {@@ -115,6 +117,7 @@ export const webpackConfig = ({onProgress(Number((p * 100).toFixed(2)));}}),+ new AllowOptionalDependenciesPlugin(),],output: {hashFunction: 'xxhash64',