File tree Expand file tree Collapse file tree 5 files changed +16
-16
lines changed Expand file tree Collapse file tree 5 files changed +16
-16
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @module-federation/nextjs-mf ' : patch
3
+ ---
4
+
5
+ fix broken loading of non nextjs json remotes
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { removeUnnecessarySharedKeys } from './remove-unnecessary-shared-keys';
2
2
3
3
describe ( 'removeUnnecessarySharedKeys' , ( ) => {
4
4
beforeEach ( ( ) => {
5
- jest . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
5
+ jest . spyOn ( console , 'warn' ) . mockImplementation ( jest . fn ( ) ) ;
6
6
} ) ;
7
7
8
8
afterEach ( ( ) => {
Original file line number Diff line number Diff line change 6
6
} from '@module-federation/enhanced' ;
7
7
8
8
class InvertedContainerPlugin {
9
- constructor ( ) { }
10
-
11
9
public apply ( compiler : Compiler ) : void {
12
10
compiler . hooks . thisCompilation . tap (
13
11
'EmbeddedContainerPlugin' ,
Original file line number Diff line number Diff line change 1
1
import { FederationRuntimePlugin } from '@module-federation/runtime/types' ;
2
- import {
3
- ModuleInfo ,
4
- ConsumerModuleInfoWithPublicPath ,
5
- } from '@module-federation/sdk' ;
6
2
7
3
export default function ( ) : FederationRuntimePlugin {
8
4
return {
@@ -199,22 +195,23 @@ export default function (): FederationRuntimePlugin {
199
195
return args ;
200
196
}
201
197
202
- // re-assign publicPath based on remoteEntry location
203
- if ( options . inBrowser ) {
204
- remoteSnapshot . publicPath = remoteSnapshot . publicPath . substring (
198
+ // re-assign publicPath based on remoteEntry location if in browser nextjs remote
199
+ const { publicPath } = remoteSnapshot ;
200
+ if ( options . inBrowser && publicPath . includes ( '/_next/' ) ) {
201
+ remoteSnapshot . publicPath = publicPath . substring (
205
202
0 ,
206
- remoteSnapshot . publicPath . lastIndexOf ( '/_next/' ) + 7 ,
203
+ publicPath . lastIndexOf ( '/_next/' ) + 7 ,
207
204
) ;
208
205
} else {
209
206
const serverPublicPath = manifestUrl . substring (
210
207
0 ,
211
208
manifestUrl . indexOf ( 'mf-manifest.json' ) ,
212
209
) ;
213
-
214
210
remoteSnapshot . publicPath = serverPublicPath ;
215
- if ( 'publicPath' in manifestJson . metaData ) {
216
- manifestJson . metaData . publicPath = serverPublicPath ;
217
- }
211
+ }
212
+
213
+ if ( 'publicPath' in manifestJson . metaData ) {
214
+ manifestJson . metaData . publicPath = remoteSnapshot . publicPath ;
218
215
}
219
216
220
217
return args ;
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ export type { FlushedChunksProps } from './flushedChunks';
22
22
*/
23
23
export const revalidate = function (
24
24
fetchModule : any = undefined ,
25
- force : boolean = false ,
25
+ force = false ,
26
26
) : Promise < boolean > {
27
27
if ( typeof window !== 'undefined' ) {
28
28
console . error ( 'revalidate should only be called server-side' ) ;
You can’t perform that action at this time.
0 commit comments