-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
71 changed files
with
74,973 additions
and
64,551 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
registry=https://registry.yarnpkg.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# advance-ssr-demo | ||
|
||
This demo shows ssr with data loader in provider and ssr by route abilities. | ||
|
||
## how to start? | ||
|
||
Run `yarn` to install the dependencies. | ||
|
||
Run `pnpm run start`. This will build and serve both `host` and `remote` on ports 3062 and 3061 respectively. | ||
|
||
|
||
Visit follow url in browser: | ||
* [SSR with data loader in provider](http://localhost:3062/entry-one/nested-routes/pathname) | ||
* [CSR](http://localhost:3062/entry-two) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './compiled-types/src/components/Content'; | ||
export { default } from './compiled-types/src/components/Content'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
export type RemoteKeys = 'host/Content' | 'host/mf-full-routes' | 'host/mf-slim-routes' | 'host/mf-routes-meta' | 'host/mf-routes'; | ||
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; |
2 changes: 2 additions & 0 deletions
2
modernjs-ssr-data-loader/host/@mf-types/host/compiled-types/src/components/Content.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare const _default: () => JSX.Element; | ||
export default _default; |
2 changes: 2 additions & 0 deletions
2
modernjs-ssr-data-loader/host/@mf-types/host/mf-full-routes.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './compiled-types/node_modules/.federation/mf-full-routes'; | ||
export { default } from './compiled-types/node_modules/.federation/mf-full-routes'; |
2 changes: 2 additions & 0 deletions
2
modernjs-ssr-data-loader/host/@mf-types/host/mf-routes-meta.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './compiled-types/node_modules/.federation/mf-routes-meta'; | ||
export { default } from './compiled-types/node_modules/.federation/mf-routes-meta'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './compiled-types/node_modules/.federation/mf-routes'; | ||
export { default } from './compiled-types/node_modules/.federation/mf-routes'; |
2 changes: 2 additions & 0 deletions
2
modernjs-ssr-data-loader/host/@mf-types/host/mf-slim-routes.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './compiled-types/node_modules/.federation/mf-slim-routes'; | ||
export { default } from './compiled-types/node_modules/.federation/mf-slim-routes'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type { PackageType as PackageType_0,RemoteKeys as RemoteKeys_0 } from './host/apis.d.ts'; | ||
import type { PackageType as PackageType_1,RemoteKeys as RemoteKeys_1 } from './remote/apis.d.ts'; | ||
declare module "@module-federation/runtime" { | ||
type RemoteKeys = RemoteKeys_0 | RemoteKeys_1; | ||
type PackageType<T, Y=any> = T extends RemoteKeys_0 ? PackageType_0<T> : | ||
T extends RemoteKeys_1 ? PackageType_1<T> : | ||
Y ; | ||
export function loadRemote<T extends RemoteKeys,Y>(packageName: T): Promise<PackageType<T, Y>>; | ||
export function loadRemote<T extends string,Y>(packageName: T): Promise<PackageType<T, Y>>; | ||
} | ||
declare module "@module-federation/enhanced/runtime" { | ||
type RemoteKeys = RemoteKeys_0 | RemoteKeys_1; | ||
type PackageType<T, Y=any> = T extends RemoteKeys_0 ? PackageType_0<T> : | ||
T extends RemoteKeys_1 ? PackageType_1<T> : | ||
Y ; | ||
export function loadRemote<T extends RemoteKeys,Y>(packageName: T): Promise<PackageType<T, Y>>; | ||
export function loadRemote<T extends string,Y>(packageName: T): Promise<PackageType<T, Y>>; | ||
} | ||
declare module "@module-federation/runtime-tools" { | ||
type RemoteKeys = RemoteKeys_0 | RemoteKeys_1; | ||
type PackageType<T, Y=any> = T extends RemoteKeys_0 ? PackageType_0<T> : | ||
T extends RemoteKeys_1 ? PackageType_1<T> : | ||
Y ; | ||
export function loadRemote<T extends RemoteKeys,Y>(packageName: T): Promise<PackageType<T, Y>>; | ||
export function loadRemote<T extends string,Y>(packageName: T): Promise<PackageType<T, Y>>; | ||
} | ||
declare module "@modern-js/runtime/mf" { | ||
type RemoteKeys = RemoteKeys_0 | RemoteKeys_1; | ||
type PackageType<T, Y=any> = T extends RemoteKeys_0 ? PackageType_0<T> : | ||
T extends RemoteKeys_1 ? PackageType_1<T> : | ||
Y ; | ||
export function loadRemote<T extends RemoteKeys,Y>(packageName: T): Promise<PackageType<T, Y>>; | ||
export function loadRemote<T extends string,Y>(packageName: T): Promise<PackageType<T, Y>>; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './compiled-types/src/components/Button'; | ||
export { default } from './compiled-types/src/components/Button'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './compiled-types/src/components/Image'; | ||
export { default } from './compiled-types/src/components/Image'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
export type RemoteKeys = 'remote/Image' | 'remote/Button' | 'remote/main/mf-routes' | 'remote/main/route-server-loaders'; | ||
type PackageType<T> = T extends 'remote/main/route-server-loaders' ? typeof import('remote/main/route-server-loaders') :T extends 'remote/main/mf-routes' ? typeof import('remote/main/mf-routes') :T extends 'remote/Button' ? typeof import('remote/Button') :T extends 'remote/Image' ? typeof import('remote/Image') :any; |
2 changes: 2 additions & 0 deletions
2
modernjs-ssr-data-loader/host/@mf-types/remote/compiled-types/src/components/Button.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import React from 'react'; | ||
export declare const Button: () => React.JSX.Element; |
3 changes: 3 additions & 0 deletions
3
modernjs-ssr-data-loader/host/@mf-types/remote/compiled-types/src/components/Image.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/// <reference types="react" /> | ||
declare const _default: () => JSX.Element; | ||
export default _default; |
2 changes: 2 additions & 0 deletions
2
modernjs-ssr-data-loader/host/@mf-types/remote/main/mf-routes.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './../compiled-types/node_modules/.federation/data-loader/main/mf-routes'; | ||
export { default } from './../compiled-types/node_modules/.federation/data-loader/main/mf-routes'; |
2 changes: 2 additions & 0 deletions
2
modernjs-ssr-data-loader/host/@mf-types/remote/main/route-server-loaders.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './../compiled-types/node_modules/.federation/data-loader/main/route-server-loaders-client'; | ||
export { default } from './../compiled-types/node_modules/.federation/data-loader/main/route-server-loaders-client'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# modernjs-ssr-nested-remote | ||
|
||
## 0.1.13 | ||
|
||
### Patch Changes | ||
|
||
- @module-federation/modern-js@0.3.3 | ||
|
||
## 0.1.12 | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies [85ae159] | ||
- @module-federation/modern-js@0.3.2 | ||
|
||
## 0.1.13 | ||
|
||
### Patch Changes | ||
|
||
- @module-federation/modern-js@0.3.1 | ||
|
||
## 0.1.12 | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies [fa37cc4] | ||
- @module-federation/modern-js@0.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", | ||
"vcs": { | ||
"enabled": true, | ||
"defaultBranch": "main", | ||
"clientKind": "git", | ||
"useIgnoreFile": true | ||
}, | ||
"formatter": { | ||
"enabled": true, | ||
"indentStyle": "space" | ||
}, | ||
"javascript": { | ||
"formatter": { | ||
"quoteStyle": "single", | ||
"arrowParentheses": "asNeeded", | ||
"jsxQuoteStyle": "double", | ||
"lineWidth": 80 | ||
} | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true | ||
} | ||
}, | ||
"organizeImports": { | ||
"enabled": true | ||
}, | ||
"files": { | ||
"ignoreUnknown": true, | ||
"ignore": [".vscode/**/*", "node_modules/**/*", "dist/**/*"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { appTools, defineConfig } from '@modern-js/app-tools'; | ||
import { moduleFederationPlugin } from '@module-federation/modern-js'; | ||
|
||
// https://modernjs.dev/en/configure/app/usage | ||
export default defineConfig({ | ||
runtime: { | ||
router: true, | ||
}, | ||
server: { | ||
ssr: { | ||
mode: 'stream', | ||
}, | ||
ssrByRouteIds: ['entry-one_nested-routes/pathname/layout'], | ||
port: 3062, | ||
}, | ||
plugins: [ | ||
appTools({ | ||
bundler: 'webpack', | ||
}), | ||
moduleFederationPlugin({ | ||
dataLoader: true, | ||
}), | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { createModuleFederationConfig } from '@module-federation/modern-js'; | ||
export default createModuleFederationConfig({ | ||
name: 'host', | ||
filename: 'remoteEntry.js', | ||
// exposes: { | ||
// './Content': './src/entry-one/components/Content.tsx', | ||
// }, | ||
remotes: { | ||
remote: 'remote@http://localhost:3061/mf-manifest.json', | ||
}, | ||
shared: { | ||
react: { singleton: true }, | ||
'react-dom': { singleton: true }, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"name": "modernjs-ssr-data-loader-host", | ||
"private": true, | ||
"version": "0.1.13", | ||
"scripts": { | ||
"reset": "npx rimraf ./**/node_modules", | ||
"dev": "modern dev", | ||
"build": "modern build", | ||
"start": "modern start", | ||
"serve": "modern serve", | ||
"new": "modern new", | ||
"lint": "biome check", | ||
"prepare": "simple-git-hooks", | ||
"upgrade": "modern upgrade" | ||
}, | ||
"engines": { | ||
"node": ">=16.18.1" | ||
}, | ||
"lint-staged": { | ||
"*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}": [ | ||
"biome check --files-ignore-unknown=true" | ||
] | ||
}, | ||
"simple-git-hooks": { | ||
"pre-commit": "npx lint-staged" | ||
}, | ||
"dependencies": { | ||
"@modern-js/runtime": "2.60.2", | ||
"react": "~18.2.0", | ||
"react-dom": "~18.2.0", | ||
"@module-federation/modern-js": "0.0.0-next-20241014092946", | ||
"@babel/runtime": "7.24.4", | ||
"antd": "4.24.15" | ||
}, | ||
"devDependencies": { | ||
"@modern-js/app-tools": "2.60.2", | ||
"@modern-js/tsconfig": "2.60.2", | ||
"typescript": "~5.0.4", | ||
"@types/jest": "~29.5.0", | ||
"@types/node": "~16.11.7", | ||
"@types/react": "~18.2.0", | ||
"@types/react-dom": "~18.2.0", | ||
"lint-staged": "~13.1.0", | ||
"prettier": "~2.8.1", | ||
"rimraf": "~3.0.2", | ||
"simple-git-hooks": "^2.11.1", | ||
"@biomejs/biome": "1.8.3" | ||
} | ||
} |
Oops, something went wrong.