Skip to content

Commit 23e6a8a

Browse files
Update mf ecosystem (#3802)
* upgrade federation libraries * upgrade federation libraries * upgrade federation libraries * upgrade federation libraries * upgrade federation libraries * upgrade federation libraries * locks * locks * locks * locks * locks * locks * locks * locks * locks * locks * locks * locks * locks * locks * locks * locks * fix package install * fix package install * fix package install * fix package install * fix package install * fix package install * fix package install * fix package install * fix package install * fix package install * fix package install * fix package install * locks * locks * locks * locks * locks * locks * locks * fix hmr * update packages * update packages * add clo * add clo * add clo * update packages * ff * update packages * update packages * hydration issues * hydration issues * port killers --------- Co-authored-by: ScriptedAlchemy <zackaryjackson@bytedance.com>
1 parent 3956a60 commit 23e6a8a

File tree

244 files changed

+8592
-2615
lines changed

Some content is hidden

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

244 files changed

+8592
-2615
lines changed

advanced-api/automatic-vendor-sharing/app1/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"webpack": "^5.91.0",
1414
"webpack-cli": "^5.1.4",
1515
"webpack-dev-server": "^4.15.1",
16-
"@module-federation/enhanced": "^0.0.0-next-20240330232226"
16+
"@module-federation/enhanced": "^0.1.4"
1717
},
1818
"scripts": {
1919
"start": "rspack serve -c rspack.config.js",
@@ -27,4 +27,4 @@
2727
"react": "^16.13.0",
2828
"react-dom": "^16.13.0"
2929
}
30-
}
30+
}

advanced-api/automatic-vendor-sharing/app2/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"webpack": "^5.91.0",
1414
"webpack-cli": "^5.1.4",
1515
"webpack-dev-server": "^4.15.1",
16-
"@module-federation/enhanced": "^0.0.0-next-20240330232226"
16+
"@module-federation/enhanced": "^0.1.4"
1717
},
1818
"scripts": {
1919
"start": "rspack serve -c rspack.config.js",
@@ -27,4 +27,4 @@
2727
"react": "^16.13.0",
2828
"react-dom": "^16.13.0"
2929
}
30-
}
30+
}

advanced-api/dynamic-remotes-runtime-environment-variables/host/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@rspack/core": "^0.5.6",
1515
"@rspack/cli": "^0.5.6",
1616
"@rspack/dev-server": "^0.5.6",
17-
"@module-federation/enhanced": "^0.0.0-next-20240330232226"
17+
"@module-federation/enhanced": "^0.1.4"
1818
},
1919
"scripts": {
2020
"start": "chmod +x ./env.sh && cp env-config.json ./public/ && rspack serve",
@@ -32,4 +32,4 @@
3232
"react": "^16.13.0",
3333
"react-dom": "^16.13.0"
3434
}
35-
}
35+
}

advanced-api/dynamic-remotes-runtime-environment-variables/remote/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@rspack/core": "^0.5.6",
1414
"@rspack/cli": "^0.5.6",
1515
"@rspack/dev-server": "^0.5.6",
16-
"@module-federation/enhanced": "^0.0.0-next-20240330232226"
16+
"@module-federation/enhanced": "^0.1.4"
1717
},
1818
"scripts": {
1919
"start": "chmod +x ./env.sh && cp env-config.json ./public/ && rspack serve",
@@ -32,4 +32,4 @@
3232
"react": "^16.13.0",
3333
"react-dom": "^16.13.0"
3434
}
35-
}
35+
}

advanced-api/dynamic-remotes-synchronous-imports/app1/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"webpack": "^5.91.0",
1111
"webpack-cli": "5.1.4",
1212
"webpack-dev-server": "4.15.1",
13-
"@module-federation/enhanced": "^0.0.0-next-20240330232226"
13+
"@module-federation/enhanced": "^0.1.4"
1414
},
1515
"scripts": {
1616
"start": "webpack-cli serve",

advanced-api/dynamic-remotes-synchronous-imports/app2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"webpack": "^5.91.0",
1111
"webpack-cli": "5.1.4",
1212
"webpack-dev-server": "4.15.1",
13-
"@module-federation/enhanced": "^0.0.0-next-20240330232226"
13+
"@module-federation/enhanced": "^0.1.4"
1414
},
1515
"scripts": {
1616
"start": "webpack-cli serve",

advanced-api/dynamic-remotes/app1/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"devDependencies": {
55
"@babel/core": "7.24.3",
66
"@babel/preset-react": "7.23.3",
7-
"@module-federation/enhanced": "^0.0.0-next-20240330232226",
8-
"@module-federation/runtime": "^0.0.0-next-20240330232226",
7+
"@module-federation/enhanced": "^0.1.4",
8+
"@module-federation/runtime": "^0.1.4",
99
"@rspack/cli": "0.5.9",
1010
"@rspack/core": "0.5.9",
1111
"@rspack/dev-server": "0.5.9",
@@ -28,4 +28,4 @@
2828
"react": "^16.13.0",
2929
"react-dom": "^16.13.0"
3030
}
31-
}
31+
}

advanced-api/dynamic-remotes/app2/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"devDependencies": {
55
"@babel/core": "7.24.3",
66
"@babel/preset-react": "7.23.3",
7-
"@module-federation/enhanced": "^0.0.0-next-20240330232226",
7+
"@module-federation/enhanced": "^0.1.4",
88
"@rspack/cli": "0.5.9",
99
"@rspack/core": "0.5.9",
1010
"@rspack/dev-server": "0.5.9",
@@ -28,4 +28,4 @@
2828
"react": "^16.13.0",
2929
"react-dom": "^16.13.0"
3030
}
31-
}
31+
}

advanced-api/dynamic-remotes/app3/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"devDependencies": {
55
"@babel/core": "7.24.3",
66
"@babel/preset-react": "7.23.3",
7-
"@module-federation/enhanced": "^0.0.0-next-20240330232226",
7+
"@module-federation/enhanced": "^0.1.4",
88
"@rspack/cli": "0.5.9",
99
"@rspack/core": "0.5.9",
1010
"@rspack/dev-server": "0.5.9",
@@ -30,4 +30,4 @@
3030
"react-redux": "^7.2.0",
3131
"redux": "^4.2.1"
3232
}
33-
}
33+
}

apollo-client/app1/config/webpack.server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const webpackConfig = {
1515
filename: '[name].js',
1616
libraryTarget: 'commonjs-module',
1717
},
18+
externals: ['express'],
1819
mode: 'production',
1920
plugins: [...moduleFederationPlugin.server],
2021
stats: {

apollo-client/app1/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@babel/preset-env": "7.23.8",
2828
"@babel/preset-react": "7.23.3",
2929
"@babel/preset-typescript": "7.23.3",
30-
"@module-federation/node": "^0.0.0-next-20240330232226",
30+
"@module-federation/node": "^2.1.4",
3131
"@types/express": "4.17.14",
3232
"@types/react": "18.2.64",
3333
"@types/react-dom": "18.2.21",

apollo-client/app2/config/webpack.shared.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const webpackConfig = {
88
resolve: {
99
extensions: ['.tsx', '.ts', '.jsx', '.js', '.json'],
1010
},
11+
externals: ['express'],
1112
module: {
1213
rules: [
1314
{

apollo-client/app2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@babel/preset-env": "7.23.8",
2828
"@babel/preset-react": "7.23.3",
2929
"@babel/preset-typescript": "7.23.3",
30-
"@module-federation/node": "^0.0.0-next-20240330232226",
30+
"@module-federation/node": "^2.1.4",
3131
"@types/express": "4.17.14",
3232
"@types/react": "18.2.64",
3333
"@types/react-dom": "18.2.21",

basic-host-remote/app1/modern.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import appTools, { defineConfig } from '@modern-js/app-tools';
2+
import {ModuleFederationPlugin} from "@module-federation/enhanced"
23

34
// https://modernjs.dev/en/configure/app/usage
45
export default defineConfig({
@@ -22,7 +23,7 @@ export default defineConfig({
2223
config.output.publicPath = 'auto';
2324

2425
appendPlugins([
25-
new webpack.container.ModuleFederationPlugin({
26+
new ModuleFederationPlugin({
2627
name: 'app1',
2728
remotes: {
2829
app2: 'app2@http://localhost:3002/static/js/remoteEntry.js',

basic-host-remote/app1/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"react-dom": "~18.2.0"
3333
},
3434
"devDependencies": {
35+
"@module-federation/enhanced": "^0.1.4",
3536
"@modern-js/app-tools": "2.48.4",
3637
"@modern-js/eslint-config": "2.48.4",
3738
"@modern-js/tsconfig": "2.48.4",
@@ -42,4 +43,4 @@
4243
"husky": "~8.0.3",
4344
"rimraf": "~5.0.5"
4445
}
45-
}
46+
}

basic-host-remote/app2/modern.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import appTools, { defineConfig } from '@modern-js/app-tools';
1+
import appTools, { defineConfig } from '@modern-js/app-tools'
2+
import {ModuleFederationPlugin} from "@module-federation/enhanced"
23

34
// https://modernjs.dev/en/configure/app/usage
45
export default defineConfig({
@@ -22,7 +23,7 @@ export default defineConfig({
2223
config.output.publicPath = 'auto';
2324

2425
appendPlugins([
25-
new webpack.container.ModuleFederationPlugin({
26+
new ModuleFederationPlugin({
2627
name: 'app2',
2728
library: { type: 'window', name: 'app2' },
2829
runtime: false,

basic-host-remote/app2/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"react-dom": "~18.2.0"
3333
},
3434
"devDependencies": {
35+
"@module-federation/enhanced": "^0.1.4",
3536
"@modern-js/app-tools": "2.48.4",
3637
"@modern-js/eslint-config": "2.48.4",
3738
"@modern-js/tsconfig": "2.48.4",
@@ -42,4 +43,4 @@
4243
"husky": "~8.0.3",
4344
"rimraf": "~5.0.5"
4445
}
45-
}
46+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22

33
const Button = () => (
4-
<button style={{ padding: '10px', background: 'red' }}>App 2 Button</button>
4+
<button style={{ padding: '10px', background: 'red' }}>App 2 Button!!!!</button>
55
);
66

77
export default Button;

basic-host-remote/app2/src/routes/layout.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Outlet } from '@modern-js/runtime/router';
2-
2+
import B from '../components/button'
3+
console.log(B)
34
export default function Layout() {
45
return (
56
<div>

clo/.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

clo/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Rsbuild / Create React App Example
2+
3+
This example demos a basic host application loading remote component.
4+
5+
- `host` is the host application (cra-based).
6+
- `remote` standalone application (cra-based) which exposes `Button` component.
7+
8+
# Running Demo
9+
10+
Run `pnpm run start`. This will build and serve both `host` and `remote` on ports 3001 and 3002 respectively.
11+
12+
- [localhost:3001](http://localhost:3000/) (HOST)
13+
- [localhost:3002](http://localhost:3002/) (STANDALONE REMOTE)
14+
15+
# Running Cypress E2E Tests
16+
17+
To run tests in interactive mode, run `npm run cypress:debug` from the root directory of the project. It will open Cypress Test Runner and allow to run tests in interactive mode. [More info about "How to run tests"](../../cypress/README.md#how-to-run-tests)
18+
19+
To build app and run test in headless mode, run `yarn e2e:ci`. It will build app and run tests for this workspace in headless mode. If tets failed cypress will create `cypress` directory in sample root folder with screenshots and videos.
20+
21+
["Best Practices, Rules amd more interesting information here](../../cypress/README.md)

clo/cypress.env.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"allure": true,
3+
"allureResultsPath": "../cypress-e2e/results/allure-results"
4+
}

clo/e2e/checkCraApps.cy.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { baseSelectors } from './../../cypress-e2e/common/selectors';
2+
import { BaseMethods } from '../../cypress-e2e/common/base';
3+
import { Constants } from '../../cypress-e2e/fixtures/constants';
4+
5+
const basePage: BaseMethods = new BaseMethods();
6+
7+
const appsData = [
8+
{
9+
appNameText: Constants.commonConstantsData.basicComponents.host,
10+
host: 3000,
11+
},
12+
{
13+
appNameText: Constants.commonConstantsData.basicComponents.remote,
14+
host: 3002,
15+
},
16+
];
17+
18+
appsData.forEach((property: { appNameText: string; host: number }) => {
19+
const appName = property.host === 3000 ? appsData[0].appNameText : appsData[1].appNameText;
20+
21+
describe('CLO', () => {
22+
context(`Check ${appName}`, () => {
23+
beforeEach(() => {
24+
basePage.openLocalhost({
25+
number: property.host,
26+
});
27+
});
28+
29+
it(`Check ${appName} elements exist on the page`, () => {
30+
basePage.checkElementWithTextPresence({
31+
selector: baseSelectors.tags.headers.h1,
32+
text: Constants.commonConstantsData.basicComponents.basicHostRemote,
33+
});
34+
basePage.checkElementWithTextPresence({
35+
selector: baseSelectors.tags.headers.h2,
36+
text: property.appNameText,
37+
});
38+
basePage.checkElementWithTextPresence({
39+
selector: baseSelectors.tags.coreElements.button,
40+
text: Constants.elementsText.craApp.buttonText,
41+
});
42+
});
43+
});
44+
});
45+
});

clo/host/.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

clo/host/modulefederation.config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const { dependencies } = require('./package.json');
2+
3+
module.exports = {
4+
name: 'host',
5+
remotes: {
6+
remote: 'remote@http://localhost:3002/remoteEntry.js',
7+
},
8+
shared: {
9+
...dependencies,
10+
react: {
11+
singleton: true,
12+
requiredVersion: dependencies['react'],
13+
},
14+
'react-dom': {
15+
singleton: true,
16+
requiredVersion: dependencies['react-dom'],
17+
},
18+
},
19+
};

0 commit comments

Comments
 (0)