@module-federation/sdk
Advanced tools
Comparing version 0.0.0-next-20240228024935 to 0.0.0-next-20240228065321
@@ -32,3 +32,26 @@ 'use strict'; | ||
var SEPARATOR = ":"; | ||
var ManifestFileName = "mf-manifest.json"; | ||
var StatsFileName = "mf-stats.json"; | ||
exports.ModuleType = void 0; | ||
(function(ModuleType) { | ||
ModuleType["NPM"] = "npm"; | ||
ModuleType["APP"] = "app"; | ||
})(exports.ModuleType || (exports.ModuleType = {})); | ||
var ContainerPlugin = /*#__PURE__*/Object.freeze({ | ||
__proto__: null | ||
}); | ||
var ContainerReferencePlugin = /*#__PURE__*/Object.freeze({ | ||
__proto__: null | ||
}); | ||
var ModuleFederationPlugin = /*#__PURE__*/Object.freeze({ | ||
__proto__: null | ||
}); | ||
var SharePlugin = /*#__PURE__*/Object.freeze({ | ||
__proto__: null | ||
}); | ||
function isBrowserEnv() { | ||
@@ -112,12 +135,2 @@ return typeof window !== "undefined"; | ||
var DEBUG_LOG = "[ FEDERATION DEBUG ]"; | ||
function safeGetLocalStorageItem() { | ||
try { | ||
if (typeof window !== "undefined" && window.localStorage) { | ||
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE; | ||
} | ||
} catch (error) { | ||
return typeof document !== "undefined"; | ||
} | ||
return false; | ||
} | ||
var Logger = /*#__PURE__*/ function() { | ||
@@ -129,3 +142,3 @@ function Logger(identifier) { | ||
this.identifier = identifier || DEBUG_LOG; | ||
if (isBrowserEnv() && safeGetLocalStorageItem()) { | ||
if (isBrowserEnv() && localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE) { | ||
this.enable = true; | ||
@@ -229,3 +242,4 @@ } else if (isDebugMode()) { | ||
var parseEntry = function(str, devVerOrUrl) { | ||
var strSplit = str.split(SEPARATOR); | ||
var separator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : SEPARATOR; | ||
var strSplit = str.split(separator); | ||
var devVersionOrUrl = getProcessEnv()["NODE_ENV"] === "development" && devVerOrUrl; | ||
@@ -239,3 +253,3 @@ var defaultVersion = "*"; | ||
var _strSplit = _to_array(strSplit), name = _strSplit[0], versionOrEntryArr = _strSplit.slice(1); | ||
var versionOrEntry = devVersionOrUrl || versionOrEntryArr.join(SEPARATOR); | ||
var versionOrEntry = devVersionOrUrl || versionOrEntryArr.join(separator); | ||
if (isEntry(versionOrEntry)) { | ||
@@ -508,6 +522,7 @@ return { | ||
}; | ||
if ((_manifest_metaData = manifest.metaData) === null || _manifest_metaData === void 0 ? void 0 : _manifest_metaData.prefetchInterface) { | ||
var prefetchInterface = manifest.metaData.prefetchInterface; | ||
if ((_manifest_metaData = manifest.metaData) === null || _manifest_metaData === void 0 ? void 0 : _manifest_metaData.prefetchEntry) { | ||
var _manifest_metaData_prefetchEntry = manifest.metaData.prefetchEntry, path = _manifest_metaData_prefetchEntry.path, name = _manifest_metaData_prefetchEntry.name, type = _manifest_metaData_prefetchEntry.type; | ||
basicRemoteSnapshot = _object_spread_props(_object_spread({}, basicRemoteSnapshot), { | ||
prefetchInterface: prefetchInterface | ||
prefetchEntry: simpleJoinRemoteEntry(path, name), | ||
prefetchEntryType: type | ||
}); | ||
@@ -1158,7 +1173,11 @@ } | ||
exports.MANIFEST_EXT = MANIFEST_EXT; | ||
exports.ManifestFileName = ManifestFileName; | ||
exports.NameTransformMap = NameTransformMap; | ||
exports.NameTransformSymbol = NameTransformSymbol; | ||
exports.SEPARATOR = SEPARATOR; | ||
exports.StatsFileName = StatsFileName; | ||
exports.assert = assert; | ||
exports.composeKeyWithSeparator = composeKeyWithSeparator; | ||
exports.containerPlugin = ContainerPlugin; | ||
exports.containerReferencePlugin = ContainerReferencePlugin; | ||
exports.createLink = createLink; | ||
@@ -1182,5 +1201,7 @@ exports.createScript = createScript; | ||
exports.logger = logger; | ||
exports.moduleFederationPlugin = ModuleFederationPlugin; | ||
exports.parseEntry = parseEntry; | ||
exports.safeWrapper = safeWrapper; | ||
exports.sharePlugin = SharePlugin; | ||
exports.simpleJoinRemoteEntry = simpleJoinRemoteEntry; | ||
exports.warn = warn; |
@@ -28,3 +28,26 @@ function _define_property$2(obj, key, value) { | ||
var SEPARATOR = ":"; | ||
var ManifestFileName = "mf-manifest.json"; | ||
var StatsFileName = "mf-stats.json"; | ||
var ModuleType; | ||
(function(ModuleType) { | ||
ModuleType["NPM"] = "npm"; | ||
ModuleType["APP"] = "app"; | ||
})(ModuleType || (ModuleType = {})); | ||
var ContainerPlugin = /*#__PURE__*/Object.freeze({ | ||
__proto__: null | ||
}); | ||
var ContainerReferencePlugin = /*#__PURE__*/Object.freeze({ | ||
__proto__: null | ||
}); | ||
var ModuleFederationPlugin = /*#__PURE__*/Object.freeze({ | ||
__proto__: null | ||
}); | ||
var SharePlugin = /*#__PURE__*/Object.freeze({ | ||
__proto__: null | ||
}); | ||
function isBrowserEnv() { | ||
@@ -108,12 +131,2 @@ return typeof window !== "undefined"; | ||
var DEBUG_LOG = "[ FEDERATION DEBUG ]"; | ||
function safeGetLocalStorageItem() { | ||
try { | ||
if (typeof window !== "undefined" && window.localStorage) { | ||
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE; | ||
} | ||
} catch (error) { | ||
return typeof document !== "undefined"; | ||
} | ||
return false; | ||
} | ||
var Logger = /*#__PURE__*/ function() { | ||
@@ -125,3 +138,3 @@ function Logger(identifier) { | ||
this.identifier = identifier || DEBUG_LOG; | ||
if (isBrowserEnv() && safeGetLocalStorageItem()) { | ||
if (isBrowserEnv() && localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE) { | ||
this.enable = true; | ||
@@ -225,3 +238,4 @@ } else if (isDebugMode()) { | ||
var parseEntry = function(str, devVerOrUrl) { | ||
var strSplit = str.split(SEPARATOR); | ||
var separator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : SEPARATOR; | ||
var strSplit = str.split(separator); | ||
var devVersionOrUrl = getProcessEnv()["NODE_ENV"] === "development" && devVerOrUrl; | ||
@@ -235,3 +249,3 @@ var defaultVersion = "*"; | ||
var _strSplit = _to_array(strSplit), name = _strSplit[0], versionOrEntryArr = _strSplit.slice(1); | ||
var versionOrEntry = devVersionOrUrl || versionOrEntryArr.join(SEPARATOR); | ||
var versionOrEntry = devVersionOrUrl || versionOrEntryArr.join(separator); | ||
if (isEntry(versionOrEntry)) { | ||
@@ -504,6 +518,7 @@ return { | ||
}; | ||
if ((_manifest_metaData = manifest.metaData) === null || _manifest_metaData === void 0 ? void 0 : _manifest_metaData.prefetchInterface) { | ||
var prefetchInterface = manifest.metaData.prefetchInterface; | ||
if ((_manifest_metaData = manifest.metaData) === null || _manifest_metaData === void 0 ? void 0 : _manifest_metaData.prefetchEntry) { | ||
var _manifest_metaData_prefetchEntry = manifest.metaData.prefetchEntry, path = _manifest_metaData_prefetchEntry.path, name = _manifest_metaData_prefetchEntry.name, type = _manifest_metaData_prefetchEntry.type; | ||
basicRemoteSnapshot = _object_spread_props(_object_spread({}, basicRemoteSnapshot), { | ||
prefetchInterface: prefetchInterface | ||
prefetchEntry: simpleJoinRemoteEntry(path, name), | ||
prefetchEntryType: type | ||
}); | ||
@@ -1148,2 +1163,2 @@ } | ||
export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, NameTransformMap, NameTransformSymbol, SEPARATOR, assert, composeKeyWithSeparator, createLink, createScript, createScriptNode, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getProcessEnv, getResourceUrl, isBrowserEnv, isDebugMode, isManifestProvider, isStaticResourcesEqual, loadScript, loadScriptNode, logger, parseEntry, safeWrapper, simpleJoinRemoteEntry, warn }; | ||
export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, ManifestFileName, ModuleType, NameTransformMap, NameTransformSymbol, SEPARATOR, StatsFileName, assert, composeKeyWithSeparator, ContainerPlugin as containerPlugin, ContainerReferencePlugin as containerReferencePlugin, createLink, createScript, createScriptNode, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getProcessEnv, getResourceUrl, isBrowserEnv, isDebugMode, isManifestProvider, isStaticResourcesEqual, loadScript, loadScriptNode, logger, ModuleFederationPlugin as moduleFederationPlugin, parseEntry, safeWrapper, SharePlugin as sharePlugin, simpleJoinRemoteEntry, warn }; |
@@ -17,1 +17,7 @@ export declare const FederationModuleManifest = "federation-manifest.json"; | ||
export declare const SEPARATOR = ":"; | ||
export declare const ManifestFileName = "mf-manifest.json"; | ||
export declare const StatsFileName = "mf-stats.json"; | ||
export declare enum ModuleType { | ||
NPM = "npm", | ||
APP = "app" | ||
} |
@@ -5,1 +5,2 @@ export * from './common'; | ||
export * from './snapshot'; | ||
export * from './plugins'; |
@@ -30,3 +30,4 @@ import { RemoteEntryType, StatsAssets } from './stats'; | ||
}>; | ||
prefetchInterface?: boolean; | ||
prefetchEntry?: string; | ||
prefetchEntryType?: RemoteEntryType; | ||
} | ||
@@ -33,0 +34,0 @@ interface BasicProviderModuleInfoWithPublicPath extends BasicProviderModuleInfo { |
@@ -0,1 +1,2 @@ | ||
import { ModuleType } from '../constant'; | ||
import type { RemoteWithEntry, RemoteWithVersion } from './common'; | ||
@@ -17,4 +18,6 @@ export type RemoteEntryType = 'esm' | 'global'; | ||
remoteEntry: ResourceInfo; | ||
prefetchInterface: boolean; | ||
prefetchEntry?: ResourceInfo; | ||
types: Omit<ResourceInfo, 'type'>; | ||
type: ModuleType; | ||
pluginVersion: string; | ||
} | ||
@@ -59,3 +62,3 @@ type StatsMetaDataWithGetPublicPath<T = BasicStatsMetaData> = T & { | ||
name: string; | ||
file: string; | ||
file: string[]; | ||
} | ||
@@ -62,0 +65,0 @@ export interface ManifestModuleInfos { |
import { RemoteEntryInfo, ModuleInfo } from './types'; | ||
import { Logger } from './logger'; | ||
declare const parseEntry: (str: string, devVerOrUrl?: string) => RemoteEntryInfo; | ||
declare const parseEntry: (str: string, devVerOrUrl?: string, separator?: string) => RemoteEntryInfo; | ||
declare global { | ||
@@ -5,0 +5,0 @@ var FEDERATION_DEBUG: string | undefined; |
{ | ||
"name": "@module-federation/sdk", | ||
"version": "0.0.0-next-20240228024935", | ||
"version": "0.0.0-next-20240228065321", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "A sdk for support module federation", |
129689
30
3280