@module-federation/sdk
Advanced tools
Comparing version 0.0.0-next-20241014092946 to 0.0.0-next-20241015060033
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var polyfills = require('./polyfills.cjs.js'); | ||
@@ -72,9 +74,2 @@ | ||
const DEBUG_LOG = '[ FEDERATION DEBUG ]'; | ||
function safeToString$1(info) { | ||
try { | ||
return JSON.stringify(info, null, 2); | ||
} catch (e) { | ||
return ''; | ||
} | ||
} | ||
function safeGetLocalStorageItem() { | ||
@@ -93,3 +88,3 @@ try { | ||
if (this.enable) { | ||
const argsToString = safeToString$1(info) || ''; | ||
const argsToString = safeToString(info) || ''; | ||
if (isBrowserEnv()) { | ||
@@ -172,3 +167,3 @@ console.info(`%c ${this.identifier}: ${msg} ${argsToString}`, 'color:#3300CC'); | ||
const logger = new Logger(); | ||
const composeKeyWithSeparator = function(...args) { | ||
const composeKeyWithSeparator = function(...args) { | ||
if (!args.length) { | ||
@@ -187,3 +182,3 @@ return ''; | ||
}; | ||
const encodeName = function(name, prefix = '', withExt = false) { | ||
const encodeName = function(name, prefix = '', withExt = false) { | ||
try { | ||
@@ -196,3 +191,3 @@ const ext = withExt ? '.js' : ''; | ||
}; | ||
const decodeName = function(name, prefix, withExt) { | ||
const decodeName = function(name, prefix, withExt) { | ||
try { | ||
@@ -215,3 +210,3 @@ let decodedName = name; | ||
}; | ||
const generateExposeFilename = (exposeName, withExt)=>{ | ||
const generateExposeFilename = (exposeName, withExt)=>{ | ||
if (!exposeName) { | ||
@@ -229,3 +224,3 @@ return ''; | ||
}; | ||
const generateShareFilename = (pkgName, withExt)=>{ | ||
const generateShareFilename = (pkgName, withExt)=>{ | ||
if (!pkgName) { | ||
@@ -271,7 +266,2 @@ return ''; | ||
} | ||
// RegExp for version string | ||
const VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/; | ||
function isRequiredVersion(str) { | ||
return VERSION_PATTERN_REGEXP.test(str); | ||
} | ||
@@ -404,3 +394,3 @@ const simpleJoinRemoteEntry = (rPath, rName)=>{ | ||
remoteSnapshot.ssrRemoteEntry = fullSSRRemoteEntry; | ||
remoteSnapshot.ssrRemoteEntryType = ssrRemoteEntry.type || 'commonjs-module'; | ||
remoteSnapshot.ssrRemoteEntryType = 'commonjs-module'; | ||
} | ||
@@ -452,5 +442,5 @@ return remoteSnapshot; | ||
if (!script) { | ||
const attrs = info.attrs; | ||
script = document.createElement('script'); | ||
script.type = (attrs == null ? void 0 : attrs['type']) === 'module' ? 'module' : 'text/javascript'; | ||
script.type = 'text/javascript'; | ||
script.src = info.url; | ||
let createScriptRes = undefined; | ||
@@ -470,5 +460,3 @@ if (info.createScriptHook) { | ||
} | ||
if (!script.src) { | ||
script.src = info.url; | ||
} | ||
const attrs = info.attrs; | ||
if (attrs && !createScriptRes) { | ||
@@ -664,4 +652,3 @@ Object.keys(attrs).forEach((name)=>{ | ||
try { | ||
var //@ts-ignore | ||
_vm_constants; | ||
var _vm_constants; | ||
const res = await f(urlObj.href); | ||
@@ -698,16 +685,3 @@ const data = await res.text(); | ||
}; | ||
getFetch().then(async (f)=>{ | ||
if ((attrs == null ? void 0 : attrs['type']) === 'esm' || (attrs == null ? void 0 : attrs['type']) === 'module') { | ||
return loadModule(urlObj.href, { | ||
fetch: f, | ||
vm: await importNodeModule('vm') | ||
}).then(async (module)=>{ | ||
await module.evaluate(); | ||
cb(undefined, module.namespace); | ||
}).catch((e)=>{ | ||
cb(e instanceof Error ? e : new Error(`Script execution error: ${e}`)); | ||
}); | ||
} | ||
handleScriptFetch(f, urlObj); | ||
}).catch((err)=>{ | ||
getFetch().then((f)=>handleScriptFetch(f, urlObj)).catch((err)=>{ | ||
cb(err); | ||
@@ -730,20 +704,2 @@ }); | ||
} | ||
async function loadModule(url, options) { | ||
const { fetch: fetch1, vm } = options; | ||
const response = await fetch1(url); | ||
const code = await response.text(); | ||
const module = new vm.SourceTextModule(code, { | ||
// @ts-ignore | ||
importModuleDynamically: async (specifier, script)=>{ | ||
const resolvedUrl = new URL(specifier, url).href; | ||
return loadModule(resolvedUrl, options); | ||
} | ||
}); | ||
await module.link(async (specifier)=>{ | ||
const resolvedUrl = new URL(specifier, url).href; | ||
const module = await loadModule(resolvedUrl, options); | ||
return module; | ||
}); | ||
return module; | ||
} | ||
@@ -807,3 +763,2 @@ function normalizeOptions(enableDefault, defaultOptions, key) { | ||
exports.isManifestProvider = isManifestProvider; | ||
exports.isRequiredVersion = isRequiredVersion; | ||
exports.isStaticResourcesEqual = isStaticResourcesEqual; | ||
@@ -810,0 +765,0 @@ exports.loadScript = loadScript; |
@@ -70,9 +70,2 @@ import { _ as _extends } from './polyfills.esm.js'; | ||
const DEBUG_LOG = '[ FEDERATION DEBUG ]'; | ||
function safeToString$1(info) { | ||
try { | ||
return JSON.stringify(info, null, 2); | ||
} catch (e) { | ||
return ''; | ||
} | ||
} | ||
function safeGetLocalStorageItem() { | ||
@@ -91,3 +84,3 @@ try { | ||
if (this.enable) { | ||
const argsToString = safeToString$1(info) || ''; | ||
const argsToString = safeToString(info) || ''; | ||
if (isBrowserEnv()) { | ||
@@ -170,3 +163,3 @@ console.info(`%c ${this.identifier}: ${msg} ${argsToString}`, 'color:#3300CC'); | ||
const logger = new Logger(); | ||
const composeKeyWithSeparator = function(...args) { | ||
const composeKeyWithSeparator = function(...args) { | ||
if (!args.length) { | ||
@@ -185,3 +178,3 @@ return ''; | ||
}; | ||
const encodeName = function(name, prefix = '', withExt = false) { | ||
const encodeName = function(name, prefix = '', withExt = false) { | ||
try { | ||
@@ -194,3 +187,3 @@ const ext = withExt ? '.js' : ''; | ||
}; | ||
const decodeName = function(name, prefix, withExt) { | ||
const decodeName = function(name, prefix, withExt) { | ||
try { | ||
@@ -213,3 +206,3 @@ let decodedName = name; | ||
}; | ||
const generateExposeFilename = (exposeName, withExt)=>{ | ||
const generateExposeFilename = (exposeName, withExt)=>{ | ||
if (!exposeName) { | ||
@@ -227,3 +220,3 @@ return ''; | ||
}; | ||
const generateShareFilename = (pkgName, withExt)=>{ | ||
const generateShareFilename = (pkgName, withExt)=>{ | ||
if (!pkgName) { | ||
@@ -269,7 +262,2 @@ return ''; | ||
} | ||
// RegExp for version string | ||
const VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/; | ||
function isRequiredVersion(str) { | ||
return VERSION_PATTERN_REGEXP.test(str); | ||
} | ||
@@ -402,3 +390,3 @@ const simpleJoinRemoteEntry = (rPath, rName)=>{ | ||
remoteSnapshot.ssrRemoteEntry = fullSSRRemoteEntry; | ||
remoteSnapshot.ssrRemoteEntryType = ssrRemoteEntry.type || 'commonjs-module'; | ||
remoteSnapshot.ssrRemoteEntryType = 'commonjs-module'; | ||
} | ||
@@ -450,5 +438,5 @@ return remoteSnapshot; | ||
if (!script) { | ||
const attrs = info.attrs; | ||
script = document.createElement('script'); | ||
script.type = (attrs == null ? void 0 : attrs['type']) === 'module' ? 'module' : 'text/javascript'; | ||
script.type = 'text/javascript'; | ||
script.src = info.url; | ||
let createScriptRes = undefined; | ||
@@ -468,5 +456,3 @@ if (info.createScriptHook) { | ||
} | ||
if (!script.src) { | ||
script.src = info.url; | ||
} | ||
const attrs = info.attrs; | ||
if (attrs && !createScriptRes) { | ||
@@ -662,4 +648,3 @@ Object.keys(attrs).forEach((name)=>{ | ||
try { | ||
var //@ts-ignore | ||
_vm_constants; | ||
var _vm_constants; | ||
const res = await f(urlObj.href); | ||
@@ -696,16 +681,3 @@ const data = await res.text(); | ||
}; | ||
getFetch().then(async (f)=>{ | ||
if ((attrs == null ? void 0 : attrs['type']) === 'esm' || (attrs == null ? void 0 : attrs['type']) === 'module') { | ||
return loadModule(urlObj.href, { | ||
fetch: f, | ||
vm: await importNodeModule('vm') | ||
}).then(async (module)=>{ | ||
await module.evaluate(); | ||
cb(undefined, module.namespace); | ||
}).catch((e)=>{ | ||
cb(e instanceof Error ? e : new Error(`Script execution error: ${e}`)); | ||
}); | ||
} | ||
handleScriptFetch(f, urlObj); | ||
}).catch((err)=>{ | ||
getFetch().then((f)=>handleScriptFetch(f, urlObj)).catch((err)=>{ | ||
cb(err); | ||
@@ -728,20 +700,2 @@ }); | ||
} | ||
async function loadModule(url, options) { | ||
const { fetch: fetch1, vm } = options; | ||
const response = await fetch1(url); | ||
const code = await response.text(); | ||
const module = new vm.SourceTextModule(code, { | ||
// @ts-ignore | ||
importModuleDynamically: async (specifier, script)=>{ | ||
const resolvedUrl = new URL(specifier, url).href; | ||
return loadModule(resolvedUrl, options); | ||
} | ||
}); | ||
await module.link(async (specifier)=>{ | ||
const resolvedUrl = new URL(specifier, url).href; | ||
const module = await loadModule(resolvedUrl, options); | ||
return module; | ||
}); | ||
return module; | ||
} | ||
@@ -770,2 +724,2 @@ function normalizeOptions(enableDefault, defaultOptions, key) { | ||
export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, ENCODE_NAME_PREFIX, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, MFModuleType, MFPrefetchCommon, MODULE_DEVTOOL_IDENTIFIER, ManifestFileName, NameTransformMap, NameTransformSymbol, SEPARATOR, StatsFileName, TEMP_DIR, assert, composeKeyWithSeparator, ContainerPlugin as containerPlugin, ContainerReferencePlugin as containerReferencePlugin, createLink, createScript, createScriptNode, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getProcessEnv, getResourceUrl, inferAutoPublicPath, isBrowserEnv, isDebugMode, isManifestProvider, isRequiredVersion, isStaticResourcesEqual, loadScript, loadScriptNode, logger, ModuleFederationPlugin as moduleFederationPlugin, normalizeOptions, parseEntry, safeToString, safeWrapper, SharePlugin as sharePlugin, simpleJoinRemoteEntry, warn }; | ||
export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, ENCODE_NAME_PREFIX, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, MFModuleType, MFPrefetchCommon, MODULE_DEVTOOL_IDENTIFIER, ManifestFileName, NameTransformMap, NameTransformSymbol, SEPARATOR, StatsFileName, TEMP_DIR, assert, composeKeyWithSeparator, ContainerPlugin as containerPlugin, ContainerReferencePlugin as containerReferencePlugin, createLink, createScript, createScriptNode, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getProcessEnv, getResourceUrl, inferAutoPublicPath, isBrowserEnv, isDebugMode, isManifestProvider, isStaticResourcesEqual, loadScript, loadScriptNode, logger, ModuleFederationPlugin as moduleFederationPlugin, normalizeOptions, parseEntry, safeToString, safeWrapper, SharePlugin as sharePlugin, simpleJoinRemoteEntry, warn }; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var path = require('path'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var path__default = /*#__PURE__*/_interopDefaultLegacy(path); | ||
function getWebpackPath(compiler, options = { | ||
@@ -36,3 +42,3 @@ framework: 'other' | ||
if (process.env['FEDERATION_WEBPACK_PATH']) { | ||
return path.resolve(process.env['FEDERATION_WEBPACK_PATH'], fullPath.replace('webpack', '../../')); | ||
return path__default["default"].resolve(process.env['FEDERATION_WEBPACK_PATH'], fullPath.replace('webpack', '../../')); | ||
} | ||
@@ -39,0 +45,0 @@ return fullPath; |
{ | ||
"name": "@module-federation/sdk", | ||
"version": "0.6.10", | ||
"version": "0.6.6", | ||
"license": "MIT", | ||
@@ -44,2 +44,2 @@ "description": "A sdk for support module federation", | ||
} | ||
} | ||
} |
@@ -41,6 +41,2 @@ /** | ||
export type EntryRuntime = false | string; | ||
/** | ||
* Enable Data Prefetch | ||
*/ | ||
export type DataPrefetch = boolean; | ||
export interface ContainerPluginOptions { | ||
@@ -78,3 +74,2 @@ /** | ||
}; | ||
dataPrefetch?: DataPrefetch; | ||
} | ||
@@ -81,0 +76,0 @@ /** |
@@ -18,3 +18,2 @@ import { RemoteEntryInfo, ModuleInfo } from './types'; | ||
declare function safeToString(info: any): string; | ||
declare function isRequiredVersion(str: string): boolean; | ||
export { parseEntry, logger, decodeName, encodeName, composeKeyWithSeparator, generateExposeFilename, generateShareFilename, getResourceUrl, assert, error, warn, safeToString, isRequiredVersion, }; | ||
export { parseEntry, logger, decodeName, encodeName, composeKeyWithSeparator, generateExposeFilename, generateShareFilename, getResourceUrl, assert, error, warn, safeToString, }; |
{ | ||
"name": "@module-federation/sdk", | ||
"version": "0.0.0-next-20241014092946", | ||
"version": "0.0.0-next-20241015060033", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "A sdk for support module federation", |
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
101861
34
2535