@@ -28,12 +28,14 @@ import {
28
28
} from './apply-server-plugins' ;
29
29
import { applyClientPlugins } from './apply-client-plugins' ;
30
30
import { ModuleFederationPlugin } from '@module-federation/enhanced' ;
31
+ import type { moduleFederationPlugin } from '@module-federation/sdk' ;
32
+
31
33
import path from 'path' ;
32
34
/**
33
35
* NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.
34
36
*/
35
37
export class NextFederationPlugin {
36
- private _options : ModuleFederationPluginOptions ;
38
+ private _options : moduleFederationPlugin . ModuleFederationPluginOptions ;
37
39
private _extraOptions : NextFederationPluginExtraOptions ;
38
40
public name : string ;
39
41
/**
@@ -140,25 +142,31 @@ export class NextFederationPlugin {
140
142
compiler : Compiler ,
141
143
isServer : boolean ,
142
144
) : ModuleFederationPluginOptions {
145
+ console . log ( this . _extraOptions . skipSharingNextInternals ) ;
143
146
const defaultShared = this . _extraOptions . skipSharingNextInternals
144
147
? { }
145
148
: retrieveDefaultShared ( isServer ) ;
146
149
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
+ } ;
147
159
return {
148
160
...this . _options ,
149
161
runtime : false ,
150
162
remoteType : 'script' ,
151
- // @ts -ignore
152
163
runtimePlugins : [
153
164
require . resolve ( path . join ( __dirname , '../container/runtimePlugin' ) ) ,
154
- //@ts -ignore
155
165
...( this . _options . runtimePlugins || [ ] ) ,
156
166
] ,
167
+ //@ts -ignore
157
168
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 ) ,
162
170
...this . _options . exposes ,
163
171
...( this . _extraOptions . exposePages
164
172
? exposeNextjsPages ( compiler . options . context as string )
0 commit comments