Skip to content

Commit 23ef6a1

Browse files
authored
feat(example): improve design (#116)
1 parent f2ba0dd commit 23ef6a1

Some content is hidden

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

49 files changed

+645
-406
lines changed

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"editor.codeActionsOnSave": {
3-
"source.organizeImports": "explicit",
4-
"source.fixAll": "explicit"
3+
"source.organizeImports": "always",
4+
"source.fixAll": "always"
55
},
66
"editor.formatOnSave": true
77
}

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ This plugin makes Module Federation work together with [Vite](https://vitejs.dev
1919

2020
## Try this crazy example with all these bundlers together
2121

22+
<img src="./docs/multi-example.png"/>
23+
2224
<p float="left">
2325
<img src="./docs/vite.webp" width="150" />
2426
<img src="./docs/webpack.webp" width="160" />

docs/multi-example.png

292 KB
Loading

examples/vite-webpack-rspack/host/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13+
"@module-federation/vite": "workspace:*",
1314
"react": "^18.3.1",
14-
"react-dom": "^18.3.1",
15-
"@module-federation/vite": "workspace:*"
15+
"react-dom": "^18.3.1"
1616
},
1717
"devDependencies": {
1818
"@eslint/js": "^9.9.0",
1919
"@types/react": "^18.3.3",
2020
"@types/react-dom": "^18.3.0",
2121
"@vitejs/plugin-react": "^4.3.1",
2222
"globals": "^15.9.0",
23+
"tailwindcss": "^3.4.13",
2324
"vite": "^5.4.1"
2425
}
2526
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
};

examples/vite-webpack-rspack/host/src/App.css

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

examples/vite-webpack-rspack/host/src/App.jsx

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import React, { lazy, StrictMode, Suspense } from 'react';
2+
import { createRoot } from 'react-dom/client';
3+
import { Footer } from './components/Footer';
4+
import { Header } from './components/Header';
5+
import './index.css';
6+
7+
const RemoteProduct = lazy(
8+
() =>
9+
// @ts-ignore
10+
import('remote/Product')
11+
);
12+
const RspackReviews = lazy(
13+
() =>
14+
// @ts-ignore
15+
import('rspack/Reviews')
16+
);
17+
const WebpackRelated = lazy(
18+
() =>
19+
// @ts-ignore
20+
import('webpack/Related')
21+
);
22+
23+
const App = () => {
24+
return (
25+
<div className="bg-white">
26+
<Header />
27+
<main className="mx-auto mt-8 max-w-2xl px-4 pb-16 sm:px-6 sm:pb-24 lg:max-w-7xl lg:px-8">
28+
<Suspense fallback="Loading...">
29+
<RemoteProduct />
30+
</Suspense>
31+
<Suspense fallback="Loading...">
32+
<RspackReviews />
33+
</Suspense>
34+
<Suspense fallback="Loading...">
35+
<WebpackRelated />
36+
</Suspense>
37+
</main>
38+
<Footer />
39+
</div>
40+
);
41+
};
42+
43+
createRoot(document.getElementById('root')!).render(
44+
<StrictMode>
45+
<App />
46+
</StrictMode>
47+
);

examples/vite-webpack-rspack/host/src/assets/react.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from 'react';
2+
3+
export default () => (
4+
<a href="#" className="p-2 text-gray-400 hover:text-gray-500 lg:ml-4">
5+
<span className="sr-only">Account</span>
6+
<svg
7+
xmlns="http://www.w3.org/2000/svg"
8+
fill="none"
9+
viewBox="0 0 24 24"
10+
strokeWidth="1.5"
11+
stroke="currentColor"
12+
aria-hidden="true"
13+
data-slot="icon"
14+
className="h-6 w-6"
15+
>
16+
<path
17+
strokeLinecap="round"
18+
strokeLinejoin="round"
19+
d="M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z"
20+
></path>
21+
</svg>
22+
</a>
23+
);

0 commit comments

Comments
 (0)