Last active
September 12, 2020 08:42
-
-
Save tsukhu/6be034460f92651dddefb6858f4e727a to your computer and use it in GitHub Desktop.
WP5 dynamically load VueJS remote in a React JS Host
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
// Dynamically mount | |
// loadComponent('myvueapp','./FullApp','myid') | |
function loadComponent(scope, module,divId ) { | |
window[scope].get(module).then((m) => { | |
m().default(`#${scope}-app-${divId}`); | |
}); | |
} |
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
// Expose FullApp | |
.... | |
new ModuleFederationPlugin({ | |
name: "myvueapp", | |
library: { type: "var", name: "myvueapp" }, | |
filename: "remoteEntry.js", | |
remotes: {}, | |
exposes: { | |
"./FullApp": "./src/FullApp" | |
} | |
shared: {} // Need to relook at using this ... require("./package.json").dependencies, | |
}), |
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
import { createApp } from "vue"; | |
import App from "./App.vue"; | |
const FullApp = (id) => { | |
const app = createApp(App); | |
app.mount(id); | |
} | |
export default FullApp; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment