Skip to content

🎥 Make videos programmatically with React

this is needed

Jonny Burger555849f47041
diff --git a/packages/bundler/src/optional-dependencies.ts b/packages/bundler/src/optional-dependencies.ts
index 9b52fd0698..55f640f962 100644
--- a/packages/bundler/src/optional-dependencies.ts
+++ b/packages/bundler/src/optional-dependencies.ts
@@ -1,6 +1,7 @@
// When Webpack cannot resolve these dependencies, it will not print an error message.
import type {Compiler} from 'webpack';
+import type {webpack} from '.';
const OPTIONAL_DEPENDENCIES = [
'zod',
@@ -12,6 +13,15 @@ const OPTIONAL_DEPENDENCIES = [
const SOURCE_MAP_IGNORE = ['path', 'fs'];
export class AllowOptionalDependenciesPlugin {
+ checkIgnore = (resolveData: webpack.ResolveData) => {
+ if (
+ resolveData.context.includes('source-map') &&
+ SOURCE_MAP_IGNORE.includes(resolveData.request)
+ ) {
+ return false;
+ }
+ };
+
filter(error: Error) {
for (const dependency of OPTIONAL_DEPENDENCIES) {
if (error.message.includes(`Can't resolve '${dependency}'`)) {
@@ -39,5 +49,23 @@ export class AllowOptionalDependenciesPlugin {
compilation.warnings = compilation.warnings.filter(this.filter);
},
);
+ compiler.hooks.normalModuleFactory.tap(
+ 'AllowOptionalDependenciesPlugin',
+ (nmf) => {
+ nmf.hooks.beforeResolve.tap(
+ 'AllowOptionalDependenciesPlugin',
+ this.checkIgnore,
+ );
+ },
+ );
+ compiler.hooks.contextModuleFactory.tap(
+ 'AllowOptionalDependenciesPlugin',
+ (cmf) => {
+ cmf.hooks.beforeResolve.tap(
+ 'AllowOptionalDependenciesPlugin',
+ this.checkIgnore,
+ );
+ },
+ );
}
}