-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
956c5f4
commit a53eaa1
Showing
25 changed files
with
129 additions
and
57 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
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
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -1,6 +1,25 @@ | ||
import { setup } from "@shared/loader"; | ||
import "./style.css"; | ||
|
||
import("red/product-page").then(({ renderProductPage }) => { | ||
setup({ | ||
name: "host", | ||
remotes: [ | ||
{ | ||
name: "red", | ||
entry: "http://localhost:2001/remoteEntry.js", | ||
}, | ||
{ | ||
name: "blue", | ||
entry: "http://localhost:2002/remoteEntry.js", | ||
}, | ||
{ | ||
name: "green", | ||
entry: "http://localhost:2003/remoteEntry.js", | ||
}, | ||
], | ||
}); | ||
|
||
window.loadRemote("red/product-page").then(({ renderProductPage }) => { | ||
const root = document.querySelector("#app"); | ||
renderProductPage(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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
import "./style.css"; | ||
import { init, loadRemote } from "@module-federation/runtime"; | ||
import { setup } from "@shared/loader"; | ||
|
||
fetch("http://localhost:9000/api/v1/pilet/microfrontends") | ||
fetch("https://module-demo.my.dev.piral.cloud/api/v1/importmap") | ||
.then((res) => res.json()) | ||
.then(async ({ remotes }) => { | ||
init({ | ||
.then(async ({ imports }) => { | ||
const remotes = Object.entries(imports).map( | ||
([name, entry]: [string, string]) => ({ name, entry }) | ||
); | ||
|
||
setup({ | ||
name: "host", | ||
remotes, // array of objects: { name, entry } | ||
}); | ||
|
||
const { renderProductPage }: any = await loadRemote("red/product-page"); | ||
const { renderProductPage }: any = await window.loadRemote("red/product-page"); | ||
const root = document.querySelector("#app"); | ||
renderProductPage(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
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
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
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 |
---|---|---|
@@ -1,6 +1,21 @@ | ||
import { setup } from "@shared/loader"; | ||
import { renderProductPage } from "./product-page"; | ||
|
||
const app = document.querySelector('#app'); | ||
const page = app.appendChild(document.createElement('div')); | ||
setup({ | ||
name: "red", | ||
remotes: [ | ||
{ | ||
name: "blue", | ||
entry: "http://localhost:2002/remoteEntry.js", | ||
}, | ||
{ | ||
name: "green", | ||
entry: "http://localhost:2003/remoteEntry.js", | ||
}, | ||
], | ||
}); | ||
|
||
const app = document.querySelector("#app"); | ||
const page = app.appendChild(document.createElement("div")); | ||
|
||
renderProductPage(page); |
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
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
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 @@ | ||
import { init, loadRemote } from "@module-federation/runtime"; | ||
|
||
export type SetupOptions = Parameters<typeof init>["0"]; | ||
|
||
export function setup(options?: SetupOptions) { | ||
init(options); | ||
|
||
window.loadRemote = (moduleId) => loadRemote(moduleId); | ||
} | ||
|
||
declare global { | ||
interface Window { | ||
loadRemote(moduleId: string): Promise<any>; | ||
} | ||
} |
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 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": false, | ||
"target": "ESNext", | ||
"useDefineForClassFields": true, | ||
"module": "ESNext", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"esModuleInterop": true, | ||
"jsx": "react", | ||
"allowJs": true, | ||
"checkJs": true | ||
}, | ||
"include": ["*.ts", "*.tsx"] | ||
} |