@originjs/vite-plugin-federation
Advanced tools
Comparing version 1.3.3 to 1.3.4
@@ -210,3 +210,4 @@ "use strict"; | ||
import: item, | ||
name: void 0 | ||
name: void 0, | ||
dontAppendStylesToHead: false | ||
}; | ||
@@ -216,3 +217,4 @@ }, | ||
import: item.import, | ||
name: item.name || void 0 | ||
name: item.name || void 0, | ||
dontAppendStylesToHead: item.dontAppendStylesToHead || false | ||
}) | ||
@@ -327,2 +329,3 @@ ); | ||
} | ||
const shareScope = options.shareScope || "default"; | ||
return { | ||
@@ -350,7 +353,17 @@ name: "originjs:remote-production", | ||
} | ||
function merge(obj1, obj2) { | ||
const mergedObj = Object.assign(obj1, obj2); | ||
for (const key of Object.keys(mergedObj)) { | ||
if (typeof mergedObj[key] === 'object' && typeof obj2[key] === 'object') { | ||
mergedObj[key] = merge(mergedObj[key], obj2[key]); | ||
} | ||
} | ||
return mergedObj; | ||
} | ||
const wrapShareModule = ${REMOTE_FROM_PARAMETER} => { | ||
return { | ||
${getModuleMarker("shareScope")} | ||
} | ||
return merge({ | ||
${getModuleMarker("shareScope")} | ||
}, (globalThis.__federation_shared__ || {})['${shareScope}'] || {}); | ||
} | ||
@@ -387,3 +400,3 @@ | ||
if (!remote.inited) { | ||
const shareScope = wrapShareModule(remote.from) | ||
const shareScope = wrapShareModule(remote.from); | ||
lib.init(shareScope); | ||
@@ -885,3 +898,3 @@ remote.lib = lib; | ||
"${item[0]}":()=>{ | ||
${DYNAMIC_LOADING_CSS}('${DYNAMIC_LOADING_CSS_PREFIX}${exposeFilepath}') | ||
${DYNAMIC_LOADING_CSS}('${DYNAMIC_LOADING_CSS_PREFIX}${exposeFilepath}', ${item[1].dontAppendStylesToHead}, '${item[0]}') | ||
return __federation_import('\${__federation_expose_${item[0]}}').then(module =>Object.keys(module).every(item => exportSet.has(item)) ? () => module.default : () => module)},`; | ||
@@ -896,3 +909,3 @@ } | ||
const seen = {} | ||
export const ${DYNAMIC_LOADING_CSS} = (cssFilePaths) => { | ||
export const ${DYNAMIC_LOADING_CSS} = (cssFilePaths, dontAppendStylesToHead, exposeItemName) => { | ||
const metaUrl = import.meta.url | ||
@@ -909,5 +922,11 @@ if (typeof metaUrl == 'undefined') { | ||
seen[href] = true | ||
const element = document.head.appendChild(document.createElement('link')) | ||
element.href = href | ||
element.rel = 'stylesheet' | ||
if (dontAppendStylesToHead) { | ||
const key = 'css__${options.name}__' + exposeItemName; | ||
if (window[key] == null) window[key] = [] | ||
window[key].push(href); | ||
} else { | ||
const element = document.head.appendChild(document.createElement('link')) | ||
element.href = href | ||
element.rel = 'stylesheet' | ||
} | ||
}) | ||
@@ -914,0 +933,0 @@ }; |
{ | ||
"name": "@originjs/vite-plugin-federation", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "A Vite plugin which support Module Federation.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -124,2 +124,9 @@ /** | ||
name?: string | ||
/** | ||
* If false, the link element with styles is put in <head> element. If true, the href argument of all links objects | ||
* are put under global window object and can be retrieved by the component. It's for using with ShadowDOM, when | ||
* the component must place the styles inside the ShadowDOM instead of the <head> element. | ||
*/ | ||
dontAppendStylesToHead?: boolean | ||
} | ||
@@ -126,0 +133,0 @@ |
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
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
170045
4123