Skip to content

Commit 98eb40d

Browse files
2heal1ScriptedAlchemysemantic-release-botRussellCanfieldnyqykk
authored
feat: refactor module federation runtime (#1913)
Co-authored-by: ScriptedAlchemy <zackary.l.jackson@gmail.com> Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net> Co-authored-by: ScriptedAlchemy <zackaryjackson@bytedance.com> Co-authored-by: rcanfield <Rcanfield86@gmail.com> Co-authored-by: nyqykk <65393845+nyqykk@users.noreply.github.com> Co-authored-by: Bruno Silva <bruno3dcontato@gmail.com> Co-authored-by: zhouxiao.shaw <zhouxiao.shaw@bytdance.net> Co-authored-by: zhouxiao.shaw <codingzx@gmail.com> Co-authored-by: zhouxiao.shaw <zhouxiao.shaw@bytdance.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 306921a commit 98eb40d

File tree

463 files changed

+20534
-3986
lines changed

Some content is hidden

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

463 files changed

+20534
-3986
lines changed

.changeset/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"@module-federation/runtime",
88
"@module-federation/enhanced",
99
"@module-federation/webpack-bundler-runtime",
10-
"@module-federation/sdk"
10+
"@module-federation/sdk",
11+
"@module-federation/runtime-tools"
1112
]
1213
],
1314
"ignorePatterns": ["^alpha|^beta"],

.changeset/modern-peas-move.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@module-federation/webpack-bundler-runtime': patch
3+
'@module-federation/nextjs-mf': patch
4+
'@module-federation/runtime': patch
5+
'@module-federation/sdk': patch
6+
---
7+
8+
Support offline remotes recovery in errorLoadRemote. Allows hook to return a Module / factory / fallback mock when a request fails or container cannot be accessed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@module-federation/webpack-bundler-runtime': patch
3+
'@module-federation/enhanced': patch
4+
'@module-federation/runtime': patch
5+
'@module-federation/runtime-tools': patch
6+
'@module-federation/sdk': patch
7+
---
8+
9+
feat: enhanced

.github/.github/release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ changelog:
88
categories:
99
- title: Breaking Changes 🍭
1010
labels:
11-
- "change: breaking"
11+
- 'change: breaking'
1212
- title: New Features 🎉
1313
labels:
14-
- "change: feat"
14+
- 'change: feat'
1515
- title: Performance 🚀
1616
labels:
17-
- "change: perf"
17+
- 'change: perf'
1818
- title: Bug Fixes 🐞
1919
labels:
20-
- "change: fix"
20+
- 'change: fix'
2121
- title: Document 📖
2222
labels:
23-
- "change: docs"
23+
- 'change: docs'
2424
- title: Other Changes
2525
labels:
26-
- "*"
26+
- '*'

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches: ['main']
66
pull_request:
7-
branches: ['main', 'next', 'canary']
87

98
jobs:
109
main:
@@ -34,3 +33,6 @@ jobs:
3433
- run: npx nx run-many --target=serve --projects=3000-home,3001-shop,3002-checkout --parallel=3 & echo "done"
3534
- run: sleep 10 && npx nx run-many --target=test:e2e --projects=3000-home,3001-shop,3002-checkout --parallel=1
3635
- run: lsof -ti tcp:3000,3001,3002 | xargs kill
36+
- run: npx nx run-many --target=serve --projects=3005-runtime-host,3006-runtime-remote,3007-runtime-remote --parallel=3 & echo "done"
37+
- run: sleep 6 && npx nx run-many --target=test:e2e --projects=3005-runtime-host --parallel=1
38+
- run: lsof -ti tcp:3005,3006,3006 | xargs kill

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,8 @@ migrations.json
4848

4949
# build contnt
5050
packages/**/dist
51-
apps/**/dist
51+
apps/**/dist
52+
53+
# test cases
54+
!packages/enhanced/test/configCases/**/**/node_modules
55+
packages/enhanced/test/js

apps/3000-home/cypress/e2e/app.cy.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@ describe('3000-home/', () => {
3636
cy.visit('/shop');
3737
cy.url().should('include', '/shop');
3838
getH1().contains('Shop Page');
39+
//eslint-disable-next-line
3940
cy.wait(3000);
40-
4141
cy.get('.home-menu-link').contains('Home 3000');
4242
cy.get('.home-menu-link').click();
43-
//eslint-disable-next-line
4443
cy.wait(1000);
4544
cy.url().should('include', '/');
4645
cy.wait(700);

apps/3000-home/next.config.js

Lines changed: 3 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,5 @@
11
const { withNx } = require('@nx/next/plugins/with-nx');
2-
const { workspaceRoot } = require('nx/src/utils/workspace-root');
3-
4-
const path = require('path');
52
const NextFederationPlugin = require('@module-federation/nextjs-mf');
6-
const fs = require('fs');
7-
8-
// function renameDefaultDelegate() {
9-
// const filesToRename = [
10-
// {
11-
// oldPath: path.resolve(
12-
// __dirname,
13-
// '../../dist/packages/nextjs-mf/src/default-delegate.js',
14-
// ),
15-
// newPath: path.resolve(
16-
// __dirname,
17-
// '../../dist/packages/nextjs-mf/src/default-delegate.cjs',
18-
// ),
19-
// },
20-
// {
21-
// oldPath: path.resolve(
22-
// __dirname,
23-
// '../../dist/packages/nextjs-mf/src/federation-noop.js',
24-
// ),
25-
// newPath: path.resolve(
26-
// __dirname,
27-
// '../../dist/packages/nextjs-mf/src/federation-noop.cjs',
28-
// ),
29-
// },
30-
// ];
31-
32-
// filesToRename.forEach(({ oldPath, newPath }) => {
33-
// fs.rename(oldPath, newPath, function (err) {
34-
// if (err) {
35-
// // Do not log error
36-
// }
37-
// });
38-
// });
39-
// }
40-
// try {
41-
// renameDefaultDelegate();
42-
// } catch (e) {
43-
// /* empty */
44-
// }
45-
const {
46-
createDelegatedModule,
47-
} = require('@module-federation/nextjs-mf/utilities');
483

494
/**
505
* @type {import('@nrwl/next/plugins/with-nx').WithNxOptions}
@@ -60,35 +15,12 @@ const nextConfig = {
6015

6116
// used for testing build output snapshots
6217
const remotes = {
63-
// shop: {
64-
// name: 'shop',
65-
// alias: 'shop',
66-
// entry: `http://localhost:3001/_next/static/${
67-
// isServer ? 'ssr' : 'chunks'
68-
// }/remoteEntry.js`,
69-
// },
70-
// checkout: {
71-
// name: 'checkout',
72-
// alias: 'checkout',
73-
// entry: `http://localhost:3002/_next/static/${
74-
// isServer ? 'ssr' : 'chunks'
75-
// }/remoteEntry.js`,
76-
// },
77-
// shop: createDelegatedModule(require.resolve('./remote-delegate.js'), {
78-
// remote: `shop@http://localhost:3001/_next/static/${
79-
// isServer ? 'ssr' : 'chunks'
80-
// }/remoteEntry.js`,
81-
// }),
82-
// checkout: createDelegatedModule(require.resolve('./remote-delegate.js'), {
83-
// remote: `checkout@http://localhost:3002/_next/static/${isServer ? 'ssr' : 'chunks'}/remoteEntry.js`,
84-
// }),
85-
86-
// shop: `shop@http://localhost:3001/_next/static/${
87-
// isServer ? 'ssr' : 'chunks'
88-
// }/remoteEntry.js`,
8918
checkout: `checkout@http://localhost:3002/_next/static/${
9019
isServer ? 'ssr' : 'chunks'
9120
}/remoteEntry.js`,
21+
home_app: `home_app@http://localhost:3000/_next/static/${
22+
isServer ? 'ssr' : 'chunks'
23+
}/remoteEntry.js`,
9224
shop: `shop@http://localhost:3001/_next/static/${
9325
isServer ? 'ssr' : 'chunks'
9426
}/remoteEntry.js`,
@@ -115,8 +47,6 @@ const nextConfig = {
11547
exposePages: true,
11648
enableImageLoaderFix: true,
11749
enableUrlLoaderFix: true,
118-
skipSharingNextInternals: false,
119-
automaticPageStitching: false,
12050
},
12151
}),
12252
);

apps/3000-home/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
},
1313
"devDependencies": {
1414
"@module-federation/nextjs-mf": "workspace:*",
15-
"@module-federation/sdk": "workspace:*",
1615
"@module-federation/utilities": "workspace:*"
1716
}
1817
}

apps/3000-home/remote-delegate.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)