@originjs/vite-plugin-federation
Advanced tools
Comparing version 1.3.2 to 1.3.3
@@ -698,3 +698,3 @@ "use strict"; | ||
} | ||
const federation_fn_import = "import { satisfy } from '__federation_fn_satisfy'\n\n// eslint-disable-next-line no-undef\nconst moduleMap = __rf_var__moduleMap\nconst moduleCache = Object.create(null)\nasync function importShared(name, shareScope = 'default') {\n return moduleCache[name]\n ? new Promise((r) => r(moduleCache[name]))\n : (await getSharedFromRuntime(name, shareScope)) || getSharedFromLocal(name)\n}\n// eslint-disable-next-line\nasync function __federation_import(name) {\n return import(name)\n}\nasync function getSharedFromRuntime(name, shareScope) {\n let module = null\n if (globalThis?.__federation_shared__?.[shareScope]?.[name]) {\n const versionObj = globalThis.__federation_shared__[shareScope][name]\n const versionKey = Object.keys(versionObj)[0]\n const versionValue = Object.values(versionObj)[0]\n if (moduleMap[name]?.requiredVersion) {\n // judge version satisfy\n if (satisfy(versionKey, moduleMap[name].requiredVersion)) {\n module = await (await versionValue.get())()\n } else {\n console.log(\n `provider support ${name}(${versionKey}) is not satisfied requiredVersion(\\${moduleMap[name].requiredVersion})`\n )\n }\n } else {\n module = await (await versionValue.get())()\n }\n }\n if (module) {\n return flattenModule(module, name)\n }\n}\nasync function getSharedFromLocal(name) {\n if (moduleMap[name]?.import) {\n let module = await (await moduleMap[name].get())()\n return flattenModule(module, name)\n } else {\n console.error(\n `consumer config import=false,so cant use callback shared module`\n )\n }\n}\nfunction flattenModule(module, name) {\n if (module.default) module = Object.assign({}, module.default, module)\n moduleCache[name] = module\n return module\n}\nexport {\n importShared,\n getSharedFromRuntime as importSharedRuntime,\n getSharedFromLocal as importSharedLocal\n}\n"; | ||
const federation_fn_import = "import { satisfy } from '__federation_fn_satisfy'\n\n// eslint-disable-next-line no-undef\nconst moduleMap = __rf_var__moduleMap\nconst moduleCache = Object.create(null)\nasync function importShared(name, shareScope = 'default') {\n return moduleCache[name]\n ? new Promise((r) => r(moduleCache[name]))\n : (await getSharedFromRuntime(name, shareScope)) || getSharedFromLocal(name)\n}\n// eslint-disable-next-line\nasync function __federation_import(name) {\n return import(name)\n}\nasync function getSharedFromRuntime(name, shareScope) {\n let module = null\n if (globalThis?.__federation_shared__?.[shareScope]?.[name]) {\n const versionObj = globalThis.__federation_shared__[shareScope][name]\n const versionKey = Object.keys(versionObj)[0]\n const versionValue = Object.values(versionObj)[0]\n if (moduleMap[name]?.requiredVersion) {\n // judge version satisfy\n if (satisfy(versionKey, moduleMap[name].requiredVersion)) {\n module = await (await versionValue.get())()\n } else {\n console.log(\n `provider support ${name}(${versionKey}) is not satisfied requiredVersion(\\${moduleMap[name].requiredVersion})`\n )\n }\n } else {\n module = await (await versionValue.get())()\n }\n }\n if (module) {\n return flattenModule(module, name)\n }\n}\nasync function getSharedFromLocal(name) {\n if (moduleMap[name]?.import) {\n let module = await (await moduleMap[name].get())()\n return flattenModule(module, name)\n } else {\n console.error(\n `consumer config import=false,so cant use callback shared module`\n )\n }\n}\nfunction flattenModule(module, name) {\n // use a shared module which export default a function will getting error 'TypeError: xxx is not a function'\n if (typeof module.default === 'function') {\n Object.keys(module).forEach((key) => {\n if (key !== 'default') {\n module.default[key] = module[key]\n }\n })\n moduleCache[name] = module.default\n return module.default\n }\n if (module.default) module = Object.assign({}, module.default, module)\n moduleCache[name] = module\n return module\n}\nexport {\n importShared,\n getSharedFromRuntime as importSharedRuntime,\n getSharedFromLocal as importSharedLocal\n}\n"; | ||
const sharedFilePathReg = /__federation_shared_(.+)\.js$/; | ||
@@ -732,3 +732,3 @@ function prodSharedPlugin(options) { | ||
this.emitFile({ | ||
fileName: `${builderInfo.assetsDir ? builderInfo.assetsDir + "/" : ""}__federation_fn_import.js`, | ||
name: "__federation_fn_import", | ||
type: "chunk", | ||
@@ -913,3 +913,4 @@ id: "__federation_fn_import", | ||
export const get =(module) => { | ||
return moduleMap[module](); | ||
if(!moduleMap[module]) throw new Error('Can not find remote module ' + module) | ||
return moduleMap[module](); | ||
}; | ||
@@ -916,0 +917,0 @@ export const init =(shareScope) => { |
{ | ||
"name": "@originjs/vite-plugin-federation", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"description": "A Vite plugin which support Module Federation.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
167693
4081