Skip to content
Open
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
12 changes: 5 additions & 7 deletions app2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@
"build": "NODE_ENV=production rspack build"
},
"dependencies": {
"@module-federation/enhanced": "^0.1.7",
"@module-federation/runtime": "^0.1.7",
"@module-federation/sdk": "^0.1.7",
"@module-federation/enhanced": "^0.1.15",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@rspack/cli": "0.6.2",
"@rspack/core": "0.6.2",
"@rspack/plugin-react-refresh": "0.6.2",
"@rspack/cli": "0.6.5",
"@rspack/core": "0.6.5",
"@rspack/plugin-react-refresh": "0.6.5",
"@types/react": "^18.2.48",
"@types/react-dom": "^18.2.18",
"prettier": "^3.2.5",
"react-refresh": "^0.14.0"
}
}
}
4,076 changes: 2,297 additions & 1,779 deletions app2/pnpm-lock.yaml

Large diffs are not rendered by default.

44 changes: 28 additions & 16 deletions app2/rspack.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const rspack = require("@rspack/core");
const refreshPlugin = require("@rspack/plugin-react-refresh");
const isDev = process.env.NODE_ENV === "development";
const { ModuleFederationPlugin, } = require("@module-federation/enhanced/rspack");

const path = require("path");
const deps = require("./package.json").dependencies;
console.log({ deps });
const { ModuleFederationPlugin } = require("@module-federation/enhanced/rspack");
const HTTPS = process.env.HTTPS ?? null;

const name = "app_02";
const name1 = name + "1";
Expand All @@ -28,6 +28,9 @@ module.exports = {
devServer: {
port: 3001,
hot: true,
client: {
webSocketURL:`ws${HTTPS ? 's' : ''}://localhost:3001/ws`,
},
static: {
directory: path.join(__dirname, "build"),
},
Expand All @@ -42,10 +45,15 @@ module.exports = {
output: {
path: __dirname + "/dist",
uniqueName: name1,
publicPath: "http://localhost:3001/",
// publicPath: "http://localhost:3001/",
publicPath: "auto",
filename: "[name].js",
},
watch: true,
watchOptions: {
ignored: /node_modules/,
poll: 500,
},
module: {
rules: [
{
Expand Down Expand Up @@ -103,19 +111,23 @@ module.exports = {
"./Hello": "./src/Hello.tsx",
"./pi": "./src/pi.ts",
},
manifest: true,
// shared: {
// ...deps,
// "react-router-dom": {
// singleton: true,
// },
// "react-dom": {
// singleton: true,
// },
// react: {
// singleton: true,
// },
// },
manifest: {
fileName: "mf-manifest.json",
},
dts: false,
// runtimePlugins: [path.resolve(__dirname, "./src/myplugin.ts")],
shared: {
// ...deps,
// "react-router-dom": {
// singleton: true,
// },
"react-dom": {
singleton: true,
},
react: {
singleton: true,
},
},
}),
isDev ? new refreshPlugin() : null,
].filter(Boolean),
Expand Down
2 changes: 1 addition & 1 deletion app2/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function App() {
<div className="App">
<div></div>
<h1>App_02 :)</h1>
<Hello name="Frank!!!" />
<Hello name="app2" />
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion app2/src/Hello.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ interface Props {
}

export const Hello = ({ name }: Props) => {
return <div>Hello, from app_02, {name}!</div>;
return <div>Hello, 1, {name}!</div>;
};
23 changes: 23 additions & 0 deletions app2/src/myplugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { FederationRuntimePlugin } from '@module-federation/enhanced/runtime';

const publicPathPlugin: () => FederationRuntimePlugin = function () {
return {
name: 'public-path-plugin',
beforeInit(args) {
console.log('publicPathPlugin args: ', args);
let newPublicPath;
const snapshotManifestLoading = Object.keys(args.origin.snapshotHandler.manifestLoading)[0];
if (snapshotManifestLoading) {
newPublicPath = new URL(snapshotManifestLoading).origin + '/';
} else {
newPublicPath = window.location.origin + '/';
}
console.log('newPublicPath, ', newPublicPath);

__webpack_require__.p = newPublicPath;

return args;
},
};
};
export default publicPathPlugin;
4 changes: 4 additions & 0 deletions app2/src/pi.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export default function pi() {
return 3.141592653589793;
}

export const register = () => {
console.log("registering pi");
};
6 changes: 3 additions & 3 deletions runhost/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
}
"tabWidth": 2,
"useTabs": false,
}
12 changes: 5 additions & 7 deletions runhost/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@
"build": "NODE_ENV=production rspack build"
},
"dependencies": {
"@module-federation/enhanced": "^0.1.7",
"@module-federation/runtime": "^0.1.7",
"@module-federation/sdk": "^0.1.7",
"@module-federation/enhanced": "^0.1.15",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@rspack/cli": "0.6.2",
"@rspack/core": "0.6.2",
"@rspack/plugin-react-refresh": "0.6.2",
"@rspack/cli": "0.6.5",
"@rspack/core": "0.6.5",
"@rspack/plugin-react-refresh": "0.6.5",
"@types/react": "^18.2.48",
"@types/react-dom": "^18.2.18",
"prettier": "^3.2.5",
"react-refresh": "^0.14.0"
}
}
}
Loading