web iframe结构实现
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
|
||||
// Windows temporarily needs this file, https://github.com/module-federation/vite/issues/68
|
||||
|
||||
import {loadShare} from "@module-federation/runtime";
|
||||
const importMap = {
|
||||
|
||||
"element-plus": async () => {
|
||||
let pkg = await import("__mf__virtual/workcase__prebuild__element_mf_2_plus__prebuild__.js");
|
||||
return pkg;
|
||||
}
|
||||
,
|
||||
"vue": async () => {
|
||||
let pkg = await import("__mf__virtual/workcase__prebuild__vue__prebuild__.js");
|
||||
return pkg;
|
||||
}
|
||||
,
|
||||
"vue-router": async () => {
|
||||
let pkg = await import("__mf__virtual/workcase__prebuild__vue_mf_2_router__prebuild__.js");
|
||||
return pkg;
|
||||
}
|
||||
|
||||
}
|
||||
const usedShared = {
|
||||
|
||||
"element-plus": {
|
||||
name: "element-plus",
|
||||
version: "2.12.0",
|
||||
scope: ["default"],
|
||||
loaded: false,
|
||||
from: "workcase",
|
||||
async get () {
|
||||
if (false) {
|
||||
throw new Error(`Shared module '${"element-plus"}' must be provided by host`);
|
||||
}
|
||||
usedShared["element-plus"].loaded = true
|
||||
const {"element-plus": pkgDynamicImport} = importMap
|
||||
const res = await pkgDynamicImport()
|
||||
const exportModule = {...res}
|
||||
// All npm packages pre-built by vite will be converted to esm
|
||||
Object.defineProperty(exportModule, "__esModule", {
|
||||
value: true,
|
||||
enumerable: false
|
||||
})
|
||||
return function () {
|
||||
return exportModule
|
||||
}
|
||||
},
|
||||
shareConfig: {
|
||||
singleton: false,
|
||||
requiredVersion: "^2.12.0",
|
||||
|
||||
}
|
||||
}
|
||||
,
|
||||
"vue": {
|
||||
name: "vue",
|
||||
version: "3.5.25",
|
||||
scope: ["default"],
|
||||
loaded: false,
|
||||
from: "workcase",
|
||||
async get () {
|
||||
if (false) {
|
||||
throw new Error(`Shared module '${"vue"}' must be provided by host`);
|
||||
}
|
||||
usedShared["vue"].loaded = true
|
||||
const {"vue": pkgDynamicImport} = importMap
|
||||
const res = await pkgDynamicImport()
|
||||
const exportModule = {...res}
|
||||
// All npm packages pre-built by vite will be converted to esm
|
||||
Object.defineProperty(exportModule, "__esModule", {
|
||||
value: true,
|
||||
enumerable: false
|
||||
})
|
||||
return function () {
|
||||
return exportModule
|
||||
}
|
||||
},
|
||||
shareConfig: {
|
||||
singleton: false,
|
||||
requiredVersion: "^3.5.25",
|
||||
|
||||
}
|
||||
}
|
||||
,
|
||||
"vue-router": {
|
||||
name: "vue-router",
|
||||
version: "4.6.3",
|
||||
scope: ["default"],
|
||||
loaded: false,
|
||||
from: "workcase",
|
||||
async get () {
|
||||
if (false) {
|
||||
throw new Error(`Shared module '${"vue-router"}' must be provided by host`);
|
||||
}
|
||||
usedShared["vue-router"].loaded = true
|
||||
const {"vue-router": pkgDynamicImport} = importMap
|
||||
const res = await pkgDynamicImport()
|
||||
const exportModule = {...res}
|
||||
// All npm packages pre-built by vite will be converted to esm
|
||||
Object.defineProperty(exportModule, "__esModule", {
|
||||
value: true,
|
||||
enumerable: false
|
||||
})
|
||||
return function () {
|
||||
return exportModule
|
||||
}
|
||||
},
|
||||
shareConfig: {
|
||||
singleton: false,
|
||||
requiredVersion: "^4.6.3",
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
const usedRemotes = [
|
||||
{
|
||||
entryGlobalName: "shared",
|
||||
name: "shared",
|
||||
type: "module",
|
||||
entry: "http://localhost:5000/remoteEntry.js",
|
||||
shareScope: "default",
|
||||
}
|
||||
|
||||
]
|
||||
export {
|
||||
usedShared,
|
||||
usedRemotes
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user