Skip to content

Commit 6748aaa

Browse files
committedJan 7, 2021
mfe work
1 parent f221038 commit 6748aaa

File tree

4 files changed

+41
-8
lines changed

4 files changed

+41
-8
lines changed
 

‎growlers/src/components/Cart.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const Cart = () => {
2929
</Box>
3030
))}
3131
<Box>
32-
<Button width="100%">Checkout</Button>
32+
<Button width="100%" onClick={() => (store.cart = [])}>Checkout</Button>
3333
</Box>
3434
</Box>
3535
);

‎growlers/webpack.config.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,15 @@ module.exports = {
4848

4949
plugins: [
5050
new ModuleFederationPlugin({
51-
name: "starter",
51+
name: "growlers",
5252
filename: "remoteEntry.js",
5353
remotes: {},
54-
exposes: {},
54+
exposes: {
55+
'./Cart': './src/components/Cart',
56+
'./Search': './src/components/Search',
57+
'./Taps': './src/components/Taps',
58+
'./store': './src/store',
59+
},
5560
shared: {
5661
...deps,
5762
react: {

‎host-react/src/App.tsx

+27-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,34 @@
11
import React from "react";
22
import ReactDOM from "react-dom";
3+
import { ChakraProvider } from '@chakra-ui/react'
34

45
import "./index.css";
56

6-
const App = () => <div>Hi there, I'm React from Webpack 5.</div>;
7+
import { load } from 'growlers/store'
8+
import Taps from 'growlers/Taps'
9+
import Search from 'growlers/Search'
10+
import Cart from 'growlers/Cart'
11+
12+
load('hv-taplist')
13+
14+
const App = () => (
15+
<ChakraProvider>
16+
<div
17+
style={{
18+
maxWidth: '960px',
19+
margin: 'auto',
20+
display: 'grid',
21+
gridTemplateColumns: '1fr 3fr',
22+
gridColumnGap: '1rem'
23+
}}
24+
>
25+
<div>
26+
<Search />
27+
<Cart />
28+
</div>
29+
<Taps />
30+
</div>
31+
</ChakraProvider>
32+
)
733

834
ReactDOM.render(<App />, document.getElementById("app"));

‎host-react/webpack.config.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPl
44
const deps = require("./package.json").dependencies;
55
module.exports = {
66
output: {
7-
publicPath: "http://localhost:8080/",
7+
publicPath: "http://localhost:8081/",
88
},
99

1010
resolve: {
1111
extensions: [".tsx", ".ts", ".jsx", ".js", ".json"],
1212
},
1313

1414
devServer: {
15-
port: 8080,
15+
port: 8081,
1616
},
1717

1818
module: {
@@ -40,9 +40,11 @@ module.exports = {
4040

4141
plugins: [
4242
new ModuleFederationPlugin({
43-
name: "starter",
43+
name: "reactHost",
4444
filename: "remoteEntry.js",
45-
remotes: {},
45+
remotes: {
46+
growlers: 'growlers@http://localhost:8080/remoteEntry.js'
47+
},
4648
exposes: {},
4749
shared: {
4850
...deps,

0 commit comments

Comments
 (0)