Skip to content

Commit 01a0ef1

Browse files
committed
feat: add data loader demo
1 parent 5994b0c commit 01a0ef1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+74973
-64551
lines changed

modernjs-ssr-data-loader/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry=https://registry.yarnpkg.com

modernjs-ssr-data-loader/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# advance-ssr-demo
2+
3+
This demo shows ssr with data loader in provider and ssr by route abilities.
4+
5+
## how to start?
6+
7+
Run `yarn` to install the dependencies.
8+
9+
Run `pnpm run start`. This will build and serve both `host` and `remote` on ports 3062 and 3061 respectively.
10+
11+
12+
Visit follow url in browser:
13+
* [SSR with data loader in provider](http://localhost:3062/entry-one/nested-routes/pathname)
14+
* [CSR](http://localhost:3062/entry-two)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './compiled-types/src/components/Content';
2+
export { default } from './compiled-types/src/components/Content';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
export type RemoteKeys = 'host/Content' | 'host/mf-full-routes' | 'host/mf-slim-routes' | 'host/mf-routes-meta' | 'host/mf-routes';
3+
type PackageType<T> = T extends 'host/mf-routes' ? typeof import('host/mf-routes') :T extends 'host/mf-routes-meta' ? typeof import('host/mf-routes-meta') :T extends 'host/mf-slim-routes' ? typeof import('host/mf-slim-routes') :T extends 'host/mf-full-routes' ? typeof import('host/mf-full-routes') :T extends 'host/Content' ? typeof import('host/Content') :any;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare const _default: () => JSX.Element;
2+
export default _default;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './compiled-types/node_modules/.federation/mf-full-routes';
2+
export { default } from './compiled-types/node_modules/.federation/mf-full-routes';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './compiled-types/node_modules/.federation/mf-routes-meta';
2+
export { default } from './compiled-types/node_modules/.federation/mf-routes-meta';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './compiled-types/node_modules/.federation/mf-routes';
2+
export { default } from './compiled-types/node_modules/.federation/mf-routes';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './compiled-types/node_modules/.federation/mf-slim-routes';
2+
export { default } from './compiled-types/node_modules/.federation/mf-slim-routes';
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import type { PackageType as PackageType_0,RemoteKeys as RemoteKeys_0 } from './host/apis.d.ts';
2+
import type { PackageType as PackageType_1,RemoteKeys as RemoteKeys_1 } from './remote/apis.d.ts';
3+
declare module "@module-federation/runtime" {
4+
type RemoteKeys = RemoteKeys_0 | RemoteKeys_1;
5+
type PackageType<T, Y=any> = T extends RemoteKeys_0 ? PackageType_0<T> :
6+
T extends RemoteKeys_1 ? PackageType_1<T> :
7+
Y ;
8+
export function loadRemote<T extends RemoteKeys,Y>(packageName: T): Promise<PackageType<T, Y>>;
9+
export function loadRemote<T extends string,Y>(packageName: T): Promise<PackageType<T, Y>>;
10+
}
11+
declare module "@module-federation/enhanced/runtime" {
12+
type RemoteKeys = RemoteKeys_0 | RemoteKeys_1;
13+
type PackageType<T, Y=any> = T extends RemoteKeys_0 ? PackageType_0<T> :
14+
T extends RemoteKeys_1 ? PackageType_1<T> :
15+
Y ;
16+
export function loadRemote<T extends RemoteKeys,Y>(packageName: T): Promise<PackageType<T, Y>>;
17+
export function loadRemote<T extends string,Y>(packageName: T): Promise<PackageType<T, Y>>;
18+
}
19+
declare module "@module-federation/runtime-tools" {
20+
type RemoteKeys = RemoteKeys_0 | RemoteKeys_1;
21+
type PackageType<T, Y=any> = T extends RemoteKeys_0 ? PackageType_0<T> :
22+
T extends RemoteKeys_1 ? PackageType_1<T> :
23+
Y ;
24+
export function loadRemote<T extends RemoteKeys,Y>(packageName: T): Promise<PackageType<T, Y>>;
25+
export function loadRemote<T extends string,Y>(packageName: T): Promise<PackageType<T, Y>>;
26+
}
27+
declare module "@modern-js/runtime/mf" {
28+
type RemoteKeys = RemoteKeys_0 | RemoteKeys_1;
29+
type PackageType<T, Y=any> = T extends RemoteKeys_0 ? PackageType_0<T> :
30+
T extends RemoteKeys_1 ? PackageType_1<T> :
31+
Y ;
32+
export function loadRemote<T extends RemoteKeys,Y>(packageName: T): Promise<PackageType<T, Y>>;
33+
export function loadRemote<T extends string,Y>(packageName: T): Promise<PackageType<T, Y>>;
34+
}
35+

0 commit comments

Comments
 (0)