Skip to content

Commit b88ad60

Browse files
committed
chore: comment resources
1 parent ec066cd commit b88ad60

File tree

3 files changed

+41
-36
lines changed

3 files changed

+41
-36
lines changed

apps/modern-component-data-fetch/provider/src/components/Content.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Button from 'antd/lib/button';
33
import stuff from './stuff.module.css';
44
import type { Data } from './Content.data';
55

6-
export default (props: { _mfData: Data }): JSX.Element => {
6+
const Content = (props: { _mfData: Data }): JSX.Element => {
77
console.log(333, props);
88
return (
99
<div
@@ -29,3 +29,5 @@ export default (props: { _mfData: Data }): JSX.Element => {
2929
</div>
3030
);
3131
};
32+
33+
export default Content;

packages/modernjs/src/cli/mfRuntimePlugins/auto-fetch-data.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ const autoFetchData: () => FederationRuntimePlugin = () => ({
88
if (typeof window !== 'undefined') {
99
return args;
1010
}
11-
const { id, moduleInfo, remoteSnapshot, host } = args;
1211

12+
const { id, moduleInfo, remoteSnapshot, host } = args;
13+
if (typeof id === 'string' && id.includes('data')) {
14+
return args;
15+
}
1316
if (!remoteSnapshot || !id || !('modules' in remoteSnapshot)) {
1417
return args;
1518
}

packages/modernjs/src/runtime/createRemoteSSRComponent.tsx

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export function collectSSRAssets(options: IProps) {
116116
const {
117117
id,
118118
injectLink = true,
119-
injectScript = true,
119+
injectScript = false,
120120
} = typeof options === 'string' ? { id: options } : options;
121121
const links: React.ReactNode[] = [];
122122
const scripts: React.ReactNode[] = [];
@@ -131,39 +131,37 @@ export function collectSSRAssets(options: IProps) {
131131
}
132132
const { module: targetModule, publicPath, remoteEntry } = moduleAndPublicPath;
133133
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
159137
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"
163141
/>,
164142
);
165143
});
166144
}
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+
// }
167165

168166
return [...scripts, ...links];
169167
}
@@ -190,14 +188,16 @@ export function createRemoteSSRComponent<T, E extends keyof T>(info: {
190188
}
191189
const moduleId = m && m[Symbol.for('mf_module_id')];
192190

193-
//@ts-ignore
194-
const data =
195-
typeof window !== 'undefined' ? window._ssd : await fetchData(moduleId);
196-
197191
const assets = collectSSRAssets({
198192
id: moduleId,
199193
});
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);
201201
console.log(assets.length);
202202
console.log('mfData: ', data);
203203

0 commit comments

Comments
 (0)