-
Notifications
You must be signed in to change notification settings - Fork 0
/
offline-remote.js
50 lines (45 loc) · 1.53 KB
/
offline-remote.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
export default function () {
const getErrorMessage = (id, error) => `Remote ${id} is offline due to error: ${error}`;
const getModule = (pg, from) => {
if (from === 'build') {
return () => ({
__esModule: true,
default: pg,
});
} else {
return {
default: pg,
};
}
};
return {
name: 'offline-remote-plugin',
// async beforePreloadRemote(args){
// console.log(args)
// const scope = args.preloadOps[0].nameOrAlias
//
// const remote = args.options.remotes.find(r=> r.name ===scope)
//
// const manipulateUrl=(url)=> {
// const parsedUrl = new URL(url);
// parsedUrl.pathname = '/mf-manifest.json';
// return parsedUrl.toString();
// }
//
// remote.entry= manipulateUrl(remote.entry)
// return args
// },
errorLoadRemote({id, error, from, origin, lifecycle}) {
const pg = function () {
return null;
};
if (lifecycle === 'onLoad') {
const remoteId = id.split('/')?.[0] ?? id
console.log(`%cError Loading Remote: ${remoteId}`, 'color: red; font-size: 20px')
// console.log('Error Loading Remote:', remoteId)
console.error(getErrorMessage(remoteId, error));
}
return getModule(pg, from);
},
};
}