Skip to content

Commit fa37cc4

Browse files
2heal1zhoushaw
andauthored
feat: support modernjs ssr (#2482)
Co-authored-by: Zhou xiao <[email protected]>
1 parent 4da7d33 commit fa37cc4

File tree

241 files changed

+9891
-914
lines changed

Some content is hidden

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

241 files changed

+9891
-914
lines changed

.changeset/long-spies-march.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@module-federation/devtools': minor
3+
'@module-federation/dts-plugin': minor
4+
'@module-federation/enhanced': minor
5+
'@module-federation/manifest': minor
6+
'@module-federation/modern-js': minor
7+
'@module-federation/runtime': minor
8+
'@module-federation/rspack': minor
9+
'@module-federation/node': minor
10+
'@module-federation/sdk': minor
11+
---
12+
13+
feat: support modern.js ssr [#2348](https://github.com/module-federation/core/issues/2348)

.github/workflows/build-and-test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,8 @@ jobs:
6666
needs: checkout-install
6767
uses: ./.github/workflows/e2e-next.yml
6868
secrets: inherit
69+
70+
e2e-modern-ssr:
71+
needs: checkout-install
72+
uses: ./.github/workflows/e2e-modern-ssr.yml
73+
secrets: inherit

.github/workflows/e2e-modern-ssr.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: E2E Test for ModernJS SSR
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
e2e-modern:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout Repository
11+
uses: actions/checkout@v3
12+
with:
13+
fetch-depth: 0
14+
15+
- name: Install Pnpm
16+
run: corepack enable
17+
18+
- name: Setup Node.js 18
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: '18'
22+
cache: 'pnpm'
23+
24+
- name: Set Nx SHA
25+
uses: nrwl/nx-set-shas@v3
26+
27+
- name: Set SKIP_DEVTOOLS_POSTINSTALL environment variable
28+
run: echo "SKIP_DEVTOOLS_POSTINSTALL=true" >> $GITHUB_ENV
29+
30+
- name: Install Dependencies
31+
run: pnpm install
32+
33+
- name: Install Cypress
34+
run: npx cypress install
35+
36+
- name: Run Build for All
37+
run: npx nx run-many --targets=build --projects=tag:type:pkg
38+
39+
- name: Run condition check script
40+
id: check-ci
41+
run: node tools/scripts/ci-is-affected.mjs --appName=modernjs
42+
43+
- name: E2E Test for Modern.js SSR
44+
if: steps.check-ci.outcome == 'success'
45+
run: |
46+
lsof -ti tcp:3050,3051,3052,3053,3054,3055,3056 | xargs -r kill &&
47+
pnpm run app:modern:dev &
48+
sleep 1 &&
49+
npx wait-on http://127.0.0.1:3050/ &&
50+
npx wait-on http://127.0.0.1:3051/ &&
51+
npx wait-on http://127.0.0.1:3052/ &&
52+
npx wait-on http://127.0.0.1:3053/ &&
53+
npx wait-on http://127.0.0.1:3054/ &&
54+
npx wait-on http://127.0.0.1:3055/ &&
55+
npx wait-on http://127.0.0.1:3056/ &&
56+
npx nx run modernjs-ssr-host:e2e &&
57+
lsof -ti tcp:3050,3051,3052,3053,3054,3055,3056 | xargs kill

apps/3000-home/cypress/support/commands.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ declare namespace Cypress {
1919
}
2020

2121
// -- This is a parent command --
22-
Cypress.Commands.add('login', (email, password) => {
23-
console.log('Custom command example: Login', email, password);
24-
});
22+
// Cypress.Commands.add('login', (email, password) => {
23+
// console.log('Custom command example: Login', email, password);
24+
// });
2525
//
2626
// -- This is a child command --
2727
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })

apps/3001-shop/cypress/support/commands.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ declare namespace Cypress {
1919
}
2020

2121
// -- This is a parent command --
22-
Cypress.Commands.add('login', (email, password) => {
23-
console.log('Custom command example: Login', email, password);
24-
});
2522
//
2623
// -- This is a child command --
2724
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })

apps/3002-checkout/cypress/support/commands.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ declare namespace Cypress {
1919
}
2020

2121
// -- This is a parent command --
22-
Cypress.Commands.add('login', (email, password) => {
23-
console.log('Custom command example: Login', email, password);
24-
});
2522
//
2623
// -- This is a child command --
2724
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })

apps/modernjs-ssr/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# modernjs-ssr
2+
3+
## Running Demo
4+
5+
- host: [localhost:3050](http://localhost:3050/)
6+
- remote: [localhost:3051](http://localhost:3051/)
7+
- nested-remote: [localhost:3052](http://localhost:3052/)
8+
- dynamic-remote: [localhost:3053](http://localhost:3053/)
9+
- dynamic-nested-remote: [localhost:3054](http://localhost:3054/)
10+
- remote-new-version: [localhost:3055](http://localhost:3055/)
11+
- dynamic-remote-new-version: [localhost:3056](http://localhost:3056/)
12+
13+
## How to start the demos ?
14+
15+
```bash
16+
# Root directory
17+
pnpm i
18+
19+
nx build modern-js-plugin
20+
21+
pnpm run app:modern:dev
22+
23+
open http://localhost:3050/
24+
```
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './compiled-types/Image';
2+
export { default } from './compiled-types/Image';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare const _default: ({ text }: {
2+
text: string;
3+
}) => JSX.Element;
4+
export default _default;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { appTools, defineConfig } from '@modern-js/app-tools';
2+
import { moduleFederationPlugin } from '@module-federation/modern-js';
3+
4+
// https://modernjs.dev/en/configure/app/usage
5+
export default defineConfig({
6+
dev: {
7+
port: 3054,
8+
},
9+
runtime: {
10+
router: true,
11+
},
12+
server: {
13+
ssr: {
14+
mode: 'stream',
15+
},
16+
port: 3054,
17+
},
18+
plugins: [appTools(), moduleFederationPlugin()],
19+
});

0 commit comments

Comments
 (0)