@@ -28,12 +28,14 @@ import {
2828} from './apply-server-plugins' ;
2929import { applyClientPlugins } from './apply-client-plugins' ;
3030import { ModuleFederationPlugin } from '@module-federation/enhanced' ;
31+ import type { moduleFederationPlugin } from '@module-federation/sdk' ;
32+
3133import path from 'path' ;
3234/**
3335 * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.
3436 */
3537export class NextFederationPlugin {
36- private _options : ModuleFederationPluginOptions ;
38+ private _options : moduleFederationPlugin . ModuleFederationPluginOptions ;
3739 private _extraOptions : NextFederationPluginExtraOptions ;
3840 public name : string ;
3941 /**
@@ -140,25 +142,31 @@ export class NextFederationPlugin {
140142 compiler : Compiler ,
141143 isServer : boolean ,
142144 ) : ModuleFederationPluginOptions {
145+ console . log ( this . _extraOptions . skipSharingNextInternals ) ;
143146 const defaultShared = this . _extraOptions . skipSharingNextInternals
144147 ? { }
145148 : retrieveDefaultShared ( isServer ) ;
146149 const noop = this . getNoopPath ( ) ;
150+
151+ const defaultExpose = this . _extraOptions . skipSharingNextInternals
152+ ? { }
153+ : {
154+ './noop' : noop ,
155+ './react' : require . resolve ( 'react' ) ,
156+ './react-dom' : require . resolve ( 'react-dom' ) ,
157+ './next/router' : require . resolve ( 'next/router' ) ,
158+ } ;
147159 return {
148160 ...this . _options ,
149161 runtime : false ,
150162 remoteType : 'script' ,
151- // @ts -ignore
152163 runtimePlugins : [
153164 require . resolve ( path . join ( __dirname , '../container/runtimePlugin' ) ) ,
154- //@ts -ignore
155165 ...( this . _options . runtimePlugins || [ ] ) ,
156166 ] ,
167+ //@ts -ignore
157168 exposes : {
158- './noop' : noop ,
159- './react' : require . resolve ( 'react' ) ,
160- './react-dom' : require . resolve ( 'react-dom' ) ,
161- './next/router' : require . resolve ( 'next/router' ) ,
169+ ...( this . _extraOptions . skipSharingNextInternals ? { } : defaultExpose ) ,
162170 ...this . _options . exposes ,
163171 ...( this . _extraOptions . exposePages
164172 ? exposeNextjsPages ( compiler . options . context as string )
0 commit comments