@originjs/vite-plugin-federation
Advanced tools
+30
-11
@@ -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 @@ }; |
+30
-11
@@ -193,3 +193,4 @@ import * as path from "path"; | ||
| import: item, | ||
| name: void 0 | ||
| name: void 0, | ||
| dontAppendStylesToHead: false | ||
| }; | ||
@@ -199,3 +200,4 @@ }, | ||
| import: item.import, | ||
| name: item.name || void 0 | ||
| name: item.name || void 0, | ||
| dontAppendStylesToHead: item.dontAppendStylesToHead || false | ||
| }) | ||
@@ -310,2 +312,3 @@ ); | ||
| } | ||
| const shareScope = options.shareScope || "default"; | ||
| return { | ||
@@ -333,7 +336,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}'] || {}); | ||
| } | ||
@@ -370,3 +383,3 @@ | ||
| if (!remote.inited) { | ||
| const shareScope = wrapShareModule(remote.from) | ||
| const shareScope = wrapShareModule(remote.from); | ||
| lib.init(shareScope); | ||
@@ -868,3 +881,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)},`; | ||
@@ -879,3 +892,3 @@ } | ||
| const seen = {} | ||
| export const ${DYNAMIC_LOADING_CSS} = (cssFilePaths) => { | ||
| export const ${DYNAMIC_LOADING_CSS} = (cssFilePaths, dontAppendStylesToHead, exposeItemName) => { | ||
| const metaUrl = import.meta.url | ||
@@ -892,5 +905,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' | ||
| } | ||
| }) | ||
@@ -897,0 +916,0 @@ }; |
+1
-1
| { | ||
| "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", |
+7
-0
@@ -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 @@ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
170045
1.4%4123
1.03%19
5.56%