@@ -233,15 +233,35 @@ export class ModuleFederationPluginV2 implements RspackPluginInstance {
233233 return adjustedSharedDependencies ;
234234 }
235235
236- apply ( compiler : Compiler ) {
237- this . ensureModuleFederationPackageInstalled ( compiler . context ) ;
238-
236+ private setupIgnoredWarnings ( compiler : Compiler ) {
239237 // MF2 produces warning about not supporting async await
240238 // we can silence this warning since it works just fine
241239 compiler . options . ignoreWarnings = compiler . options . ignoreWarnings ?? [ ] ;
242240 compiler . options . ignoreWarnings . push (
243241 ( warning ) => warning . name === 'EnvironmentNotSupportAsyncWarning'
244242 ) ;
243+ // MF2 produces warning about dynamic import in loadEsmEntry but it's not relevant
244+ // in RN env since we override the loadEntry logic through a hook
245+ // https://github.com/module-federation/core/blob/fa7a0bd20eb64eccd6648fea340c6078a2268e39/packages/runtime/src/utils/load.ts#L28-L37
246+ compiler . options . ignoreWarnings . push ( ( warning ) => {
247+ // @ts -expect-error moduleDescriptor is present in the warning object
248+ const modulePath = warning . moduleDescriptor . name ;
249+ const moduleName = '@module-federation/runtime/dist/index.cjs.js' ;
250+ const isMF2Runtime = modulePath . endsWith ( moduleName ) ;
251+ const requestExpressionWarning =
252+ / C r i t i c a l d e p e n d e n c y : t h e r e q u e s t o f a d e p e n d e n c y i s a n e x p r e s s i o n / ;
253+
254+ if ( isMF2Runtime && requestExpressionWarning . test ( warning . message ) ) {
255+ return true ;
256+ }
257+
258+ return false ;
259+ } ) ;
260+ }
261+
262+ apply ( compiler : Compiler ) {
263+ this . ensureModuleFederationPackageInstalled ( compiler . context ) ;
264+ this . setupIgnoredWarnings ( compiler ) ;
245265
246266 const ModuleFederationPlugin = this . getModuleFederationPlugin ( compiler ) ;
247267
0 commit comments