Skip to content

Modernjs to enhanced #4005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions bi-directional/app1/modern.config.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
import appTools, { defineConfig } from '@modern-js/app-tools';

import { ModuleFederationPlugin } from '@module-federation/enhanced/webpack';
// https://modernjs.dev/en/configure/app/usage
export default defineConfig({
server: {
port: 3001,
},
// dev: {
// // set publicPath
// assetPrefix: 'http://localhost:3001/',
// },
runtime: {
router: true,
},
source: {
// automatically generated asynchronous boundary via Dynamic Import, allowing the page code to consume remote modules generated by the module federation.
enableAsyncEntry: true,
enableAsyncEntry: true, // Enable async entry for module federation
},
tools: {
webpack: (config, { webpack, appendPlugins }) => {
// Remove splitChunks optimization
delete config.optimization.splitChunks;
config.output.publicPath = 'auto';
config.output.uniqueName = 'app1';

// Add Module Federation Plugin
appendPlugins([
new webpack.container.ModuleFederationPlugin({
new ModuleFederationPlugin({
name: 'app1',
runtime: false,
filename: 'static/js/remoteEntry.js',
Expand Down
13 changes: 7 additions & 6 deletions bi-directional/app1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,20 @@
"dist/"
],
"dependencies": {
"@modern-js/runtime": "2.50.0",
"@modern-js/runtime": "2.51.0",
"react": "~18.2.0",
"react-dom": "~18.2.0"
},
"devDependencies": {
"@modern-js/app-tools": "2.50.0",
"@modern-js/eslint-config": "2.50.0",
"@modern-js/tsconfig": "2.50.0",
"@modern-js-app/eslint-config": "2.50.0",
"@modern-js/app-tools": "2.51.0",
"@modern-js/eslint-config": "2.51.0",
"@modern-js/tsconfig": "2.51.0",
"@modern-js-app/eslint-config": "2.51.0",
"@module-federation/enhanced": "0.1.16",
"@modern-js/builder-rspack-provider": "2.46.1",
"lint-staged": "15.0.2",
"prettier": "3.0.3",
"husky": "8.0.3",
"rimraf": "5.0.5"
}
}
}
4 changes: 1 addition & 3 deletions bi-directional/app1/src/routes/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ const Index = () => (
<p className="description">
FEDERATED: <Button />
</p>
<p className="description">
go to http://localhost:3002
</p>
<p className="description">go to http://localhost:3002</p>

<div className="grid">
<a
Expand Down
6 changes: 4 additions & 2 deletions bi-directional/app2/modern.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import appTools, { defineConfig } from '@modern-js/app-tools';
import { ModuleFederationPlugin } from '@module-federation/enhanced/webpack';

// https://modernjs.dev/en/configure/app/usage
export default defineConfig({
Expand All @@ -20,14 +21,15 @@ export default defineConfig({
webpack: (config, { webpack, appendPlugins }) => {
delete config.optimization.splitChunks;
config.output.publicPath = 'auto';
config.output.uniqueName = 'app2';

appendPlugins([
new webpack.container.ModuleFederationPlugin({
new ModuleFederationPlugin({
name: 'app2',
runtime: false,
filename: 'static/js/remoteEntry.js',
remotes: {
app1: 'app1@http://localhost:3001/static/js/remoteEntry.js',
app1: 'app1@http://localhost:3001/static/js/app1_partial.js',
},
exposes: {
'./Button': './src/components/button.js',
Expand Down
13 changes: 7 additions & 6 deletions bi-directional/app2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,20 @@
"dist/"
],
"dependencies": {
"@modern-js/runtime": "2.50.0",
"@modern-js/runtime": "2.51.0",
"react": "~18.2.0",
"react-dom": "~18.2.0"
},
"devDependencies": {
"@modern-js/app-tools": "2.50.0",
"@modern-js/eslint-config": "2.50.0",
"@modern-js/tsconfig": "2.50.0",
"@modern-js-app/eslint-config": "2.50.0",
"@modern-js/app-tools": "2.51.0",
"@modern-js/eslint-config": "2.51.0",
"@modern-js/tsconfig": "2.51.0",
"@modern-js-app/eslint-config": "2.51.0",
"@modern-js/builder-rspack-provider": "2.46.1",
"@module-federation/enhanced": "0.1.16",
"lint-staged": "15.0.2",
"prettier": "3.0.3",
"husky": "8.0.3",
"rimraf": "5.0.5"
}
}
}
Loading
Loading