Skip to content

Commit ba5bedd

Browse files
feat: generate manifest and consume it (#2108)
Co-authored-by: ScriptedAlchemy <[email protected]>
1 parent b84e36c commit ba5bedd

File tree

175 files changed

+9478
-4112
lines changed

Some content is hidden

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

175 files changed

+9478
-4112
lines changed

.changeset/config.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
[
77
"@module-federation/runtime",
88
"@module-federation/enhanced",
9+
"@module-federation/enhanced-rspack",
910
"@module-federation/webpack-bundler-runtime",
1011
"@module-federation/sdk",
11-
"@module-federation/runtime-tools"
12+
"@module-federation/runtime-tools",
13+
"@module-federation/managers",
14+
"@module-federation/manifest"
1215
]
1316
],
1417
"ignorePatterns": ["^alpha|^beta"],

.changeset/lazy-tables-prove.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@module-federation/enhanced-rspack': patch
3+
'@module-federation/enhanced': patch
4+
'@module-federation/managers': patch
5+
'@module-federation/manifest': patch
6+
'@module-federation/sdk': patch
7+
---
8+
9+
feat: support manifest

.changeset/rude-melons-press.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/enhanced-rspack': patch
3+
---
4+
5+
feat: add enhanced-rspack

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,11 @@ jobs:
5656
# - name: E2E Test for 3002-checkout
5757
# run: pnpm run app:next:dev & echo "done" && sleep 15 && npx nx run-many --target=test:e2e --projects=3002-checkout && lsof -ti tcp:3000,3001,3002 | xargs kill
5858

59-
- name: Serve Projects 3005-runtime-host, 3006-runtime-remote, 3007-runtime-remote
60-
run: npx nx run-many --target=serve --projects=3005-runtime-host,3006-runtime-remote,3007-runtime-remote --parallel=3 & echo "done"
61-
6259
- name: E2E Test for 3005-runtime-host
63-
run: sleep 6 && npx nx run-many --target=test:e2e --projects=3005-runtime-host --parallel=1
60+
run: pnpm run app:runtime:dev & echo "done" && sleep 6 && npx nx run-many --target=test:e2e --projects=3005-runtime-host --parallel=1 && lsof -ti tcp:3005,3006,3007 | xargs kill
6461

65-
- name: Kill Processes on Ports 3005, 3006, 3007
66-
run: lsof -ti tcp:3005,3006,3007 | xargs kill
62+
- name: E2E Test for 3008-webpack-host
63+
run: pnpm run app:manifest:dev & echo "done" && sleep 6 && npx nx run-many --target=test:e2e --projects=3008-webpack-host --parallel=1 && lsof -ti tcp:3008,3009,3010,3011,3012 | xargs kill
6764

6865
- name: Build Next.js Apps in Production Mode
6966
run: pnpm app:next:build

apps/3001-shop/cypress/e2e/app.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ describe('3001-shop/', () => {
105105
cy.request(src).its('status').should('eq', 200);
106106
});
107107
});
108-
xit('should check that shop-webpack-png images are not 404 between route clicks', () => {
108+
it('should check that shop-webpack-png images are not 404 between route clicks', () => {
109109
cy.visit('/shop');
110110
cy.url().should('include', '/shop');
111111
getH1().contains('Shop Page');
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"presets": [
3+
[
4+
"@nx/react/babel",
5+
{
6+
"runtime": "automatic"
7+
}
8+
]
9+
],
10+
"plugins": []
11+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
2+
import { defineConfig } from 'cypress';
3+
4+
export default defineConfig({
5+
e2e: nxE2EPreset(__filename, { cypressDir: 'cypress' }),
6+
defaultCommandTimeout: 20000,
7+
});
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { getH1, getH2 } from '../support/app.po';
2+
3+
describe('3008-webpack-host/basic', () => {
4+
beforeEach(() => cy.visit('/basic'));
5+
6+
describe('Welcome message', () => {
7+
it('should display welcome message', () => {
8+
getH2().contains('Manifest Basic Usage');
9+
});
10+
});
11+
12+
describe('Image checks', () => {
13+
it('should check that the home-webpack-png and remote1-webpack-png images are not 404', () => {
14+
// Get the src attribute of the home-webpack-png image
15+
cy.get('img.home-webpack-png')
16+
.invoke('attr', 'src')
17+
.then((src) => {
18+
if (!src) {
19+
throw new Error('src must not be empty');
20+
}
21+
cy.log(src);
22+
cy.request(src).its('status').should('eq', 200);
23+
});
24+
25+
// Get the src attribute of the shop-webpack-png image
26+
cy.get('img.remote1-webpack-png')
27+
.invoke('attr', 'src')
28+
.then((src) => {
29+
if (!src) {
30+
throw new Error('src must not be empty');
31+
}
32+
// Send a GET request to the src URL
33+
cy.request(src).its('status').should('eq', 200);
34+
});
35+
});
36+
37+
it('should check that the home-webpack-svg and remote1-webpack-svg images are not 404', () => {
38+
// Get the src attribute of the home-webpack-png image
39+
cy.get('img.home-webpack-svg')
40+
.invoke('attr', 'src')
41+
.then((src) => {
42+
if (!src) {
43+
throw new Error('src must not be empty');
44+
}
45+
cy.log(src);
46+
cy.request(src).its('status').should('eq', 200);
47+
});
48+
49+
// Get the src attribute of the shop-webpack-png image
50+
cy.get('img.remote1-webpack-svg')
51+
.invoke('attr', 'src')
52+
.then((src) => {
53+
if (!src) {
54+
throw new Error('src must not be empty');
55+
}
56+
// Send a GET request to the src URL
57+
cy.request(src).its('status').should('eq', 200);
58+
});
59+
});
60+
});
61+
62+
describe('Shared react hook check', () => {
63+
it('should display text which comes from remote1 hook', () => {
64+
cy.get('.remote1-text')
65+
.invoke('html')
66+
.should('equal', 'Custom hook from localhost:3009 works!');
67+
});
68+
});
69+
70+
describe('dynamic remote check', () => {
71+
describe('dynamic-remote/ButtonOldAnt', () => {
72+
it('should display remote button', () => {
73+
cy.get('button.test-remote2').contains('Button');
74+
});
75+
it('should use host shared(antd)', () => {
76+
cy.get('button.test-remote2').contains('Button from [email protected]');
77+
});
78+
});
79+
});
80+
});
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { getH1, getH2 } from '../support/app.po';
2+
3+
describe('3008-webpack-host/preload', () => {
4+
beforeEach(() => cy.visit('/preload'));
5+
6+
describe('Welcome message', () => {
7+
it('should display welcome message', () => {
8+
getH2().contains('MF runtime can preload assets with');
9+
});
10+
});
11+
12+
describe('Manifest provider will load component more quickly than js entry provider', () => {
13+
it('manifest provider will load component more quickly than js entry provider', () => {
14+
// simulate browser idle time
15+
cy.wait(2000);
16+
17+
// should load remote successfully
18+
// load manifest provider component
19+
cy.get('#loadManifestProvider').click();
20+
cy.wait(2000);
21+
cy.get('#3011-rspack-manifest-provider').should('exist');
22+
23+
// load js entry provider component
24+
cy.get('#loadJSEntryProvider').click();
25+
cy.wait(2000);
26+
cy.get('#3012-rspack-js-entry-provider').should('exist');
27+
28+
// manifest provider will load component more quickly than js entry provider
29+
let manifestTime = 0;
30+
let jsEntryTime = 0;
31+
cy.get('#manifest-time')
32+
.invoke('text')
33+
.then((text) => {
34+
manifestTime = parseFloat(text);
35+
});
36+
37+
cy.get('#js-entry-time')
38+
.invoke('text')
39+
.then((text) => {
40+
jsEntryTime = parseFloat(text);
41+
});
42+
43+
cy.then(() => {
44+
assert(
45+
manifestTime < jsEntryTime,
46+
'manifest time should be less than js entry time',
47+
);
48+
});
49+
});
50+
});
51+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "[email protected]",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}

0 commit comments

Comments
 (0)