File tree Expand file tree Collapse file tree 2 files changed +21
-6
lines changed
streaming/src/NodeModuleFederation Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change 11{
22 "public" : true ,
33 "name" : " @module-federation/nextjs-ssr" ,
4- "version" : " 0.0.6-beta.0 " ,
4+ "version" : " 0.0.6-beta.1 " ,
55 "description" : " Module Federation CSR & SSR Support for Next.js" ,
66 "main" : " bundle.js" ,
77 "types" : " index.d.ts" ,
Original file line number Diff line number Diff line change @@ -17,9 +17,20 @@ const executeLoadTemplate = `
1717 }).catch((e)=>{
1818 console.error('failed to fetch remote', moduleName, scriptUrl);
1919 console.error(e);
20- reject(null)
20+ reject(null)
2121 })
22- });
22+ }).catch(()=>{
23+ console.warn(moduleName,'is offline, returning fake remote')
24+ return {
25+ fake: true,
26+ get:(arg)=>{
27+ console.log('faking', arg,'module on', moduleName);
28+
29+ return ()=> Promise.resolve();
30+ },
31+ init:()=>{}
32+ }
33+ })
2334 }
2435` ;
2536
@@ -59,16 +70,20 @@ function buildRemotes(mfConf, webpack) {
5970 })
6071 })
6172 .then(function(remote){
62-
63- const proxy= {
73+ const proxy= {
6474 get: remote.get,
6575 chunkMap: remote.chunkMap,
6676 path: "${ config } ",
6777 init:(arg)=>{
6878 try {
69- return remote.init(shareScope.default)
79+ return remote.init(shareScope.default)
7080 } catch(e){console.log('remote container already initialized')}}
7181 }
82+
83+ if(remote.fake) {
84+ res(proxy);
85+ return null
86+ }
7287 Object.assign(global.loadedRemotes,{${ JSON . stringify ( name ) } : proxy});
7388
7489 res(global.loadedRemotes[${ JSON . stringify ( name ) } ])
You can’t perform that action at this time.
0 commit comments