-
-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(runtime): allow errorLoadRemote hook catch remote entry resource loading error #3474
base: main
Are you sure you want to change the base?
Changes from 12 commits
10ac480
3cad7b2
6e9c447
2cfbc8c
c2bea61
8c057aa
ae09b59
9418e8f
09a02d1
609e7fe
6eadef5
cec8139
43a8bf6
0d393fc
c5b2966
4b22c70
c45c0e5
0e1d83d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@module-federation/runtime-core': patch | ||
'website-new': patch | ||
--- | ||
|
||
feat: allow errorLoadRemote hook catch remote entry resource loading error |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import type { FederationRuntimePlugin } from '@module-federation/enhanced/runtime'; | ||
|
||
const fallbackPlugin = (): FederationRuntimePlugin => { | ||
return { | ||
name: 'fallback-plugin', | ||
async errorLoadRemote(args) { | ||
// if (args.lifecycle === 'onLoad') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can simply delete redundant comments There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
// const React = await import('react'); | ||
// const FallbackComponent = React.memo(() => | ||
// React.createElement('div', null, 'fallback component'), | ||
// ); | ||
// FallbackComponent.displayName = 'FallbackComponent'; | ||
// return () => ({ | ||
// __esModule: true, | ||
// default: FallbackComponent, | ||
// }); | ||
// } else if (args.lifecycle === 'afterResolve') { | ||
// // you can try another fall back remote entry or return a constant manifest data | ||
// // const response = await fetch('http://localhost:2002/mf-manifest.json'); | ||
// // const manifestJson = (await response.json()) as Manifest; | ||
// // return manifestJson; | ||
// } | ||
// return args; | ||
|
||
const React = await import('react'); | ||
const FallbackComponent = React.memo(() => | ||
React.createElement('div', null, 'fallback component'), | ||
); | ||
FallbackComponent.displayName = 'FallbackComponent'; | ||
return () => ({ | ||
__esModule: true, | ||
default: FallbackComponent, | ||
}); | ||
}, | ||
}; | ||
}; | ||
export default fallbackPlugin; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be deleted directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i've add the specific router to show this case.