-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
224 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const assert = require("assert"); | ||
const { parseBuildResult } = require("../../../scripts/test-utils"); | ||
const { files } = parseBuildResult(__dirname); | ||
|
||
const manifest = JSON.parse(files["mf-manifest.json"]); | ||
|
||
assert( | ||
manifest.remotes[0].alias === 'producer' | ||
&& manifest.remotes[0].federationContainerName === 'producer' | ||
&& manifest.remotes[0].moduleName === 'App', | ||
"should include mf remotes info" | ||
) | ||
|
||
assert( | ||
manifest.shared.map(s => s.name).sort().join(",") === "react,react-dom", | ||
"should include mf shared dependencies" | ||
) | ||
|
||
assert( | ||
manifest.shared.every(s => s.assets.js.sync.length !== 0), | ||
"should include mf shared assets" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"entry": { | ||
"app1": "./src/index.ts" | ||
}, | ||
"minify": false, | ||
"moduleFederation": { | ||
"name": "consumer", | ||
"remotes": { | ||
"producer": "producer@http://localhost:3000/remoteEntry.js" | ||
}, | ||
"shared": { "react": { "eager": true }, "react-dom": { "eager": true } }, | ||
"manifest": true, | ||
"implementation": "../../../../../packages/mako/node_modules/@module-federation/webpack-bundler-runtime" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "mf-consumer", | ||
"version": "0.0.1", | ||
"dependencies": { | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"@types/react": "18.2.0", | ||
"@types/react-dom": "18.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<body> | ||
<div id="root"></div> | ||
<script src="app1.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
|
||
// @ts-ignore | ||
const RemoteComp = React.lazy(() => import('producer/App')); | ||
|
||
const App = () => { | ||
return ( | ||
<div style={{ display: 'flex', flexDirection: 'column' }}> | ||
<div | ||
style={{ | ||
margin: '10px', | ||
padding: '10px', | ||
textAlign: 'center', | ||
backgroundColor: 'greenyellow', | ||
}} | ||
> | ||
<h1>Consumer App</h1> | ||
</div> | ||
<React.Suspense> | ||
<RemoteComp /> | ||
</React.Suspense> | ||
</div> | ||
); | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import App from './App'; | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './bootstrap'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const assert = require("assert"); | ||
const { parseBuildResult } = require("../../../scripts/test-utils"); | ||
const { files } = parseBuildResult(__dirname); | ||
|
||
const manifest = JSON.parse(files["mf-manifest.json"]); | ||
|
||
assert( | ||
manifest.metaData.remoteEntry.name === 'remoteEntry.js', | ||
"should generate mf contanier entry" | ||
) | ||
|
||
assert( | ||
manifest.exposes[0].name === 'App', | ||
"should include mf exposes" | ||
) | ||
|
||
assert( | ||
manifest.exposes[0].assets.js.sync.length !== 0, | ||
"should include mf exposes assets" | ||
) | ||
|
||
assert( | ||
manifest.shared.map(s => s.name).sort().join(",") === "react,react-dom", | ||
"should include mf shared dependencies" | ||
) | ||
|
||
assert( | ||
manifest.shared.every(s => s.assets.js.sync.length !== 0), | ||
"should include mf shared assets" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"entry": { | ||
"app2": "./src/index.ts" | ||
}, | ||
"publicPath": "auto", | ||
"moduleFederation": { | ||
"name": "producer", | ||
"filename": "remoteEntry.js", | ||
"exposes": { | ||
"./App": "./src/App.tsx" | ||
}, | ||
"shared": { "react": {}, "react-dom": {} }, | ||
"manifest": true, | ||
"implementation": "../../../../../packages/mako/node_modules/@module-federation/webpack-bundler-runtime" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "mf-producer", | ||
"version": "0.0.1", | ||
"dependencies": { | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"@types/react": "18.2.0", | ||
"@types/react-dom": "18.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<body> | ||
<div id="root"></div> | ||
<script src="app2.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
|
||
const App = () => { | ||
return ( | ||
<div | ||
style={{ | ||
margin: '10px', | ||
padding: '10px', | ||
textAlign: 'center', | ||
backgroundColor: 'cyan', | ||
}} | ||
> | ||
<h1>Widget App2</h1> | ||
</div> | ||
); | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
import App from './App'; | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import('./bootstrap'); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters