File tree Expand file tree Collapse file tree 4 files changed +25
-56
lines changed Expand file tree Collapse file tree 4 files changed +25
-56
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { moduleFederationPlugin } from '@module-federation/modern-js';
3
3
4
4
// https://modernjs.dev/en/configure/app/usage
5
5
export default defineConfig ( {
6
- dev :{
6
+ dev : {
7
7
// FIXME: it should be removed , related issue: https://github.com/web-infra-dev/modern.js/issues/5999
8
8
host : '0.0.0.0' ,
9
9
} ,
@@ -18,7 +18,7 @@ export default defineConfig({
18
18
} ,
19
19
plugins : [
20
20
// not support data loader in rspack mode yet
21
- appTools ( ) ,
21
+ appTools ( { bundler : 'experimental-rspack' } ) ,
22
22
moduleFederationPlugin ( )
23
23
] ,
24
24
} ) ;
Original file line number Diff line number Diff line change
1
+ import { createRemoteSSRComponent , loadRemote , registerRemotes } from '@modern-js/runtime/mf' ;
2
+
3
+ registerRemotes ( [
4
+ {
5
+ name : 'dynamic_provider' ,
6
+ entry : 'http://localhost:3008/mf-manifest.json' ,
7
+ }
8
+ ] )
9
+
10
+ export const DynamicRemoteSSRComponents = createRemoteSSRComponent ( {
11
+ loader : ( ) => loadRemote ( 'dynamic_provider/Image' ) ,
12
+ loading : 'loading...' ,
13
+ fallback : ( { error } ) => {
14
+ if ( error instanceof Error && error . message . includes ( 'not exist' ) ) {
15
+ return < div > fallback - not existed id</ div > ;
16
+ }
17
+ return < div > fallback</ div > ;
18
+ } ,
19
+ } ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
import { createRemoteSSRComponent , loadRemote , registerRemotes } from '@modern-js/runtime/mf' ;
2
- import type { DataLoaderRes } from './page.data'
3
- import { useRouteLoaderData } from '@modern-js/runtime/router' ;
4
-
2
+ import { DynamicRemoteSSRComponents } from '../components/dynamic-remote'
5
3
import './index.css' ;
6
4
7
5
const RemoteSSRComponent = createRemoteSSRComponent ( {
@@ -16,28 +14,13 @@ const RemoteSSRComponent = createRemoteSSRComponent({
16
14
} ,
17
15
} ) ;
18
16
19
- const Index = ( ) => {
20
- const dataLoader = useRouteLoaderData ( 'page' ) as DataLoaderRes ;
21
- registerRemotes ( dataLoader . providerList ) ;
22
17
23
- const DynamicRemoteSSRComponents = dataLoader . providerList . map ( item => {
24
- const { id } = item ;
25
- const Com = createRemoteSSRComponent ( {
26
- loader : ( ) => loadRemote ( id ) ,
27
- loading : 'loading...' ,
28
- fallback : ( { error } ) => {
29
- if ( error instanceof Error && error . message . includes ( 'not exist' ) ) {
30
- return < div > fallback - not existed id</ div > ;
31
- }
32
- return < div > fallback</ div > ;
33
- } ,
34
- } ) ;
35
- return < Com />
36
- } )
18
+
19
+ const Index = ( ) => {
37
20
return (
38
21
< div className = "container-box" >
39
22
< RemoteSSRComponent />
40
- { DynamicRemoteSSRComponents }
23
+ < DynamicRemoteSSRComponents />
41
24
</ div >
42
25
) ;
43
26
}
You can’t perform that action at this time.
0 commit comments