Skip to content

Commit c53c05f

Browse files
chore: general housekeeping (#3952)
* chore: general housekeeping * chore: general housekeeping * chore: general housekeeping * chore: general housekeeping * chore: general housekeeping * chore: general housekeeping * chore: general housekeeping * chore: general housekeeping * chore: general housekeeping * chore: general housekeeping * chore: general housekeeping * chore: general housekeeping * chore: general housekeeping * chore: general housekeeping * chore: general housekeeping * chore: general housekeeping * chore: general housekeeping * chore: general housekeeping * chore: general housekeeping * chore: general housekeeping * chore: general housekeeping * ll * chore: general housekeeping * chore: general housekeeping * hk * fix single runtime for rspack * fix single runtime for rspack --------- Co-authored-by: ScriptedAlchemy <[email protected]>
1 parent 3f7c407 commit c53c05f

File tree

24 files changed

+56248
-65538
lines changed

24 files changed

+56248
-65538
lines changed

bi-directional/app1/modern.config.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
11
import appTools, { defineConfig } from '@modern-js/app-tools';
2-
2+
import {ModuleFederationPlugin} from '@module-federation/enhanced/webpack'
33
// https://modernjs.dev/en/configure/app/usage
44
export default defineConfig({
55
server: {
66
port: 3001,
77
},
8-
// dev: {
9-
// // set publicPath
10-
// assetPrefix: 'http://localhost:3001/',
11-
// },
128
runtime: {
139
router: true,
1410
},
1511
source: {
16-
// automatically generated asynchronous boundary via Dynamic Import, allowing the page code to consume remote modules generated by the module federation.
17-
enableAsyncEntry: true,
12+
enableAsyncEntry: true, // Enable async entry for module federation
1813
},
1914
tools: {
2015
webpack: (config, { webpack, appendPlugins }) => {
16+
// Remove splitChunks optimization
2117
delete config.optimization.splitChunks;
2218
config.output.publicPath = 'auto';
2319

20+
// Add Module Federation Plugin
2421
appendPlugins([
25-
new webpack.container.ModuleFederationPlugin({
22+
new ModuleFederationPlugin({
2623
name: 'app1',
2724
runtime: false,
2825
filename: 'static/js/remoteEntry.js',

bi-directional/app1/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"@modern-js/eslint-config": "2.50.0",
3737
"@modern-js/tsconfig": "2.50.0",
3838
"@modern-js-app/eslint-config": "2.50.0",
39+
"@module-federation/enhanced": "0.1.13",
3940
"@modern-js/builder-rspack-provider": "2.46.1",
4041
"lint-staged": "15.0.2",
4142
"prettier": "3.0.3",

bi-directional/app1/src/routes/page.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ const Index = () => (
2424
<p className="description">
2525
FEDERATED: <Button />
2626
</p>
27-
<p className="description">
28-
go to http://localhost:3002
29-
</p>
27+
<p className="description">go to http://localhost:3002</p>
3028

3129
<div className="grid">
3230
<a

bi-directional/app2/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/webpack';
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
runtime: false,
2829
filename: 'static/js/remoteEntry.js',

bi-directional/app2/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@modern-js/tsconfig": "2.50.0",
3838
"@modern-js-app/eslint-config": "2.50.0",
3939
"@modern-js/builder-rspack-provider": "2.46.1",
40+
"@module-federation/enhanced": "0.1.13",
4041
"lint-staged": "15.0.2",
4142
"prettier": "3.0.3",
4243
"husky": "8.0.3",

cra-react-app-rewired/pnpm-lock.yaml

Lines changed: 4622 additions & 7332 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cypress-e2e/fixtures/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ export class Constants {
893893
componentState: 'Component in Action..',
894894
},
895895
dynamicSystemHostApp: {
896-
hostParagraph: 'The Dynamic System will take advantage Module Federation ',
896+
hostParagraph: 'The Dynamic System will take advantage of Module Federation ',
897897
paragraphText: [
898898
'App2 Moment Dep',
899899
'for format the date'

cypress-e2e/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"private": true,
77
"ignored": true,
88
"dependencies": {
9-
"typescript": "^5.2.2"
9+
"typescript": "^5.2.2",
10+
"moment": "^2.30.1"
1011
}
1112
}

dynamic-remotes-node/app1/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,12 @@ init({
1414

1515

1616
loadRemote('app2/sample').then((sample) => {
17+
if(process.env.TEST) {
18+
if(sample === 'dynamically consumed from app2') {
19+
process.exit(0)
20+
} else {
21+
process.exit(1)
22+
}
23+
}
1724
console.log(sample)
1825
});

dynamic-remotes-node/package.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,24 @@
66
"license": "MIT",
77
"scripts": {
88
"serve": "concurrently 'serve -s app1/dist -l 3001' 'serve -s app2/dist -l 3002'",
9-
"build:legacy": "rimraf dist/server && concurrently 'cd app1; webpack --config ./webpack.config.js' 'cd runtime-container; webpack --config ./webpack.config.js' 'cd app2; webpack --config ./webpack.config.js'",
10-
"build": "rimraf dist/server && concurrently 'cd app1; rspack --config ./rspack.config.js' 'cd runtime-container; rspack --config ./rspack.config.js' 'cd app2; rspack --config ./rspack.config.js'",
9+
"build:legacy": "rimraf dist/server && concurrently 'cd app1; webpack --config ./webpack.config.js' 'cd runtime-container; webpack --config ./webpack.config.js' 'cd app2; webpack --config ./webpack.config.js'",
10+
"build": "rimraf dist/server && concurrently 'cd app1; rspack --config ./rspack.config.js' 'cd runtime-container; rspack --config ./rspack.config.js' 'cd app2; rspack --config ./rspack.config.js'",
1111
"start:legacy": "pnpm build:legacy && concurrently 'pnpm serve' 'sleep 5 && node app1/dist/main.js'",
12-
"start": "pnpm build && concurrently 'pnpm serve' 'sleep 5 && node app1/dist/main.js'"
12+
"start": "pnpm build && concurrently 'TEST=true pnpm serve' 'sleep 5 && node app1/dist/main.js'"
1313
},
1414
"dependencies": {
1515
"@module-federation/node": "2.2.9",
1616
"@module-federation/enhanced": "0.1.18",
1717
"@module-federation/runtime": "0.1.18",
1818
"concurrently": "^8.0.1",
19-
"webpack": "5.91.0",
19+
"webpack": "^5.91.0",
2020
"rimraf": "^5.0.5",
2121
"webpack-cli": "^5.1.4",
22-
"@rspack/cli": "0.6.5",
23-
"@rspack/core": "0.6.5",
24-
"@rspack/dev-server": "0.6.5"
22+
"@rspack/cli": "^0.7.0-beta.0",
23+
"@rspack/core": "^0.7.0-beta.0",
24+
"@rspack/dev-server": "^0.7.0-beta.0"
25+
},
26+
"devDependencies": {
27+
"kill-port": "^2.0.1"
2528
}
26-
}
29+
}

dynamic-system-host/app1/rspack.config.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
const {
2-
container: { ModuleFederationPlugin },
3-
} = require('@rspack/core');
1+
const { ModuleFederationPlugin } = require('@module-federation/enhanced/rspack');
42
const path = require('path');
53
const HtmlWebpackPlugin = require('html-webpack-plugin');
64

@@ -64,10 +62,4 @@ module.exports = {
6462
template: './public/index.html',
6563
}),
6664
],
67-
// it will be fixed soon...
68-
resolve: {
69-
alias: {
70-
'@module-federation/runtime$': require.resolve('@module-federation/runtime'),
71-
},
72-
},
7365
};

dynamic-system-host/app1/src/App.js

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { useState, lazy, Suspense } from 'react';
22
import { loadRemote, init } from '@module-federation/runtime';
33
import ReactDOM from 'react-dom';
44

@@ -27,7 +27,6 @@ init({
2727
},
2828
beforeLoadShare(args) {
2929
console.log('beforeLoadShare: ', args);
30-
3130
return args;
3231
},
3332
},
@@ -53,32 +52,26 @@ init({
5352
},
5453
},
5554
});
56-
function System(props) {
57-
const { request } = props;
5855

56+
const System = ({ request }) => {
5957
if (!request) {
6058
return <h2>No system specified</h2>;
6159
}
6260

63-
const Component = React.lazy(() => loadRemote(request));
61+
const Component = lazy(() => loadRemote(request));
6462

6563
return (
66-
<React.Suspense fallback="Loading System">
64+
<Suspense fallback="Loading System">
6765
<Component />
68-
</React.Suspense>
66+
</Suspense>
6967
);
70-
}
71-
72-
function App() {
73-
const [system, setSystem] = React.useState(false);
68+
};
7469

75-
function setApp2() {
76-
setSystem('app2/Widget');
77-
}
70+
const App = () => {
71+
const [system, setSystem] = useState(null);
7872

79-
function setApp3() {
80-
setSystem('app3/Widget');
81-
}
73+
const setApp2 = () => setSystem('app2/Widget');
74+
const setApp3 = () => setSystem('app3/Widget');
8275

8376
return (
8477
<div
@@ -90,7 +83,7 @@ function App() {
9083
<h1>Dynamic System Host</h1>
9184
<h2>App 1</h2>
9285
<p>
93-
The Dynamic System will take advantage Module Federation <strong>remotes</strong> and{' '}
86+
The Dynamic System will take advantage of Module Federation <strong>remotes</strong> and{' '}
9487
<strong>exposes</strong>. It will not load any components or modules that have been loaded
9588
already.
9689
</p>
@@ -101,6 +94,6 @@ function App() {
10194
</div>
10295
</div>
10396
);
104-
}
97+
};
10598

10699
export default App;

dynamic-system-host/app2/rspack.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
const {
2-
container: { ModuleFederationPlugin },
3-
} = require('@rspack/core');
1+
const { ModuleFederationPlugin } = require('@module-federation/enhanced/rspack')
42
const HtmlWebpackPlugin = require('html-webpack-plugin');
53

64
const path = require('path');

dynamic-system-host/app3/rspack.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
const {
2-
container: { ModuleFederationPlugin },
3-
} = require('@rspack/core');
1+
const { ModuleFederationPlugin } = require('@module-federation/enhanced/rspack')
42
const HtmlWebpackPlugin = require('html-webpack-plugin');
53

64
const path = require('path');

dynamic-system-host/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"legacy:build": "pnpm --filter dynamic-system-host_app* legacy:build",
1111
"serve": "pnpm --filter dynamic-system-host_app* --parallel serve",
1212
"clean": "pnpm --filter dynamic-system-host_app* --parallel clean",
13-
"e2e:ci": "pnpm start & wait-on http-get://localhost:3001/ && npx cypress run --config-file ../cypress-e2e/config/cypress.config.ts --config '{\"supportFile\": \"../cypress-e2e/support/e2e.ts\"}' --spec \"./e2e/*.cy.ts\" --browser=chrome",
14-
"legacy:e2e:ci": "pnpm legacy:start & wait-on http-get://localhost:3001/ && npx cypress run --config-file ../cypress-e2e/config/cypress.config.ts --config '{\"supportFile\": \"../cypress-e2e/support/e2e.ts\"}' --spec \"./e2e/*.cy.ts\" --browser=chrome"
13+
"e2e:ci": "pnpm start & sleep 1 && wait-on tcp:3001 && npx cypress run --config-file ../cypress-e2e/config/cypress.config.ts --config '{\"supportFile\": \"../cypress-e2e/support/e2e.ts\"}' --spec \"./e2e/*.cy.ts\" --browser=chrome",
14+
"legacy:e2e:ci": "pnpm legacy:start & sleep 1 && wait-on tcp:3001 tcp:3002 && npx cypress run --config-file ../cypress-e2e/config/cypress.config.ts --config '{\"supportFile\": \"../cypress-e2e/support/e2e.ts\"}' --spec \"./e2e/*.cy.ts\" --browser=chrome"
1515
},
1616
"devDependencies": {
1717
"wait-on": "7.2.0"

0 commit comments

Comments
 (0)