@@ -116,7 +116,7 @@ export function collectSSRAssets(options: IProps) {
116
116
const {
117
117
id,
118
118
injectLink = true ,
119
- injectScript = true ,
119
+ injectScript = false ,
120
120
} = typeof options === 'string' ? { id : options } : options ;
121
121
const links : React . ReactNode [ ] = [ ] ;
122
122
const scripts : React . ReactNode [ ] = [ ] ;
@@ -131,39 +131,37 @@ export function collectSSRAssets(options: IProps) {
131
131
}
132
132
const { module : targetModule , publicPath, remoteEntry } = moduleAndPublicPath ;
133
133
if ( injectLink ) {
134
- [ ...targetModule . assets . css . sync , ...targetModule . assets . css . async ]
135
- . sort ( )
136
- . forEach ( ( file , index ) => {
137
- links . push (
138
- < link
139
- key = { `${ file . split ( '.' ) [ 0 ] } _${ index } ` }
140
- href = { `${ publicPath } ${ file } ` }
141
- rel = "stylesheet"
142
- type = "text/css"
143
- /> ,
144
- ) ;
145
- } ) ;
146
- }
147
- if ( injectScript ) {
148
- scripts . push (
149
- < script
150
- async = { true }
151
- key = { remoteEntry . split ( '.' ) [ 0 ] }
152
- src = { `${ publicPath } ${ remoteEntry } ` }
153
- crossOrigin = "anonymous"
154
- /> ,
155
- ) ;
156
- [ ...targetModule . assets . js . sync ] . sort ( ) . forEach ( ( file , index ) => {
157
- scripts . push (
158
- < script
134
+ [ ...targetModule . assets . css . async ] . sort ( ) . forEach ( ( file , index ) => {
135
+ links . push (
136
+ < link
159
137
key = { `${ file . split ( '.' ) [ 0 ] } _${ index } ` }
160
- async = { true }
161
- src = { ` ${ publicPath } ${ file } ` }
162
- crossOrigin = "anonymous "
138
+ href = { ` ${ publicPath } ${ file } ` }
139
+ rel = "stylesheet"
140
+ type = "text/css "
163
141
/> ,
164
142
) ;
165
143
} ) ;
166
144
}
145
+ scripts . push (
146
+ < script
147
+ async = { true }
148
+ key = { remoteEntry . split ( '.' ) [ 0 ] }
149
+ src = { `${ publicPath } ${ remoteEntry } ` }
150
+ crossOrigin = "anonymous"
151
+ /> ,
152
+ ) ;
153
+ // if (injectScript) {
154
+ // [...targetModule.assets.js.sync].sort().forEach((file, index) => {
155
+ // scripts.push(
156
+ // <script
157
+ // key={`${file.split('.')[0]}_${index}`}
158
+ // async={true}
159
+ // src={`${publicPath}${file}`}
160
+ // crossOrigin="anonymous"
161
+ // />,
162
+ // );
163
+ // });
164
+ // }
167
165
168
166
return [ ...scripts , ...links ] ;
169
167
}
@@ -190,14 +188,16 @@ export function createRemoteSSRComponent<T, E extends keyof T>(info: {
190
188
}
191
189
const moduleId = m && m [ Symbol . for ( 'mf_module_id' ) ] ;
192
190
193
- //@ts -ignore
194
- const data =
195
- typeof window !== 'undefined' ? window . _ssd : await fetchData ( moduleId ) ;
196
-
197
191
const assets = collectSSRAssets ( {
198
192
id : moduleId ,
199
193
} ) ;
200
- console . log ( 'assets: ' , assets ) ;
194
+ const data =
195
+ //@ts -ignore
196
+ typeof window !== 'undefined' ? window . _ssd : await fetchData ( moduleId ) ;
197
+
198
+ // const data = {data:'fetch data from provider'}
199
+
200
+ // console.log('assets: ', assets);
201
201
console . log ( assets . length ) ;
202
202
console . log ( 'mfData: ' , data ) ;
203
203
0 commit comments