@module-federation/sdk
Advanced tools
Comparing version 0.0.0-next-20241104032754 to 0.0.0-next-20241104073605
'use strict'; | ||
var isomorphicRslog = require('isomorphic-rslog'); | ||
var polyfills = require('./polyfills.cjs.js'); | ||
@@ -62,12 +61,2 @@ | ||
} | ||
function isBrowserDebug() { | ||
try { | ||
if (isBrowserEnv() && window.localStorage) { | ||
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE; | ||
} | ||
} catch (error) { | ||
return false; | ||
} | ||
return false; | ||
} | ||
function isDebugMode() { | ||
@@ -77,6 +66,3 @@ if (typeof process !== 'undefined' && process.env && process.env['FEDERATION_DEBUG']) { | ||
} | ||
if (typeof FEDERATION_DEBUG !== 'undefined' && Boolean(FEDERATION_DEBUG)) { | ||
return true; | ||
} | ||
return isBrowserDebug(); | ||
return typeof FEDERATION_DEBUG !== 'undefined' && Boolean(FEDERATION_DEBUG); | ||
} | ||
@@ -87,34 +73,52 @@ const getProcessEnv = function() { | ||
const PREFIX = '[ Module Federation ]'; | ||
function setDebug(loggerInstance) { | ||
if (isDebugMode()) { | ||
loggerInstance.level = 'verbose'; | ||
const DEBUG_LOG = '[ FEDERATION DEBUG ]'; | ||
function safeToString$1(info) { | ||
try { | ||
return JSON.stringify(info, null, 2); | ||
} catch (e) { | ||
return ''; | ||
} | ||
} | ||
function setPrefix(loggerInstance, prefix) { | ||
loggerInstance.labels = { | ||
warn: `${prefix} Warn`, | ||
error: `${prefix} Error`, | ||
success: `${prefix} Success`, | ||
info: `${prefix} Info`, | ||
ready: `${prefix} Ready`, | ||
debug: `${prefix} 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; | ||
} | ||
function createLogger(prefix) { | ||
const loggerInstance = isomorphicRslog.createLogger({ | ||
labels: { | ||
warn: `${PREFIX} Warn`, | ||
error: `${PREFIX} Error`, | ||
success: `${PREFIX} Success`, | ||
info: `${PREFIX} Info`, | ||
ready: `${PREFIX} Ready`, | ||
debug: `${PREFIX} Debug` | ||
let Logger = class Logger { | ||
info(msg, info) { | ||
if (this.enable) { | ||
const argsToString = safeToString$1(info) || ''; | ||
if (isBrowserEnv()) { | ||
console.info(`%c ${this.identifier}: ${msg} ${argsToString}`, 'color:#3300CC'); | ||
} else { | ||
console.info('\x1b[34m%s', `${this.identifier}: ${msg} ${argsToString ? `\n${argsToString}` : ''}`); | ||
} | ||
} | ||
}); | ||
setDebug(loggerInstance); | ||
setPrefix(loggerInstance, prefix); | ||
return loggerInstance; | ||
} | ||
const logger = createLogger(PREFIX); | ||
} | ||
logOriginalInfo(...args) { | ||
if (this.enable) { | ||
if (isBrowserEnv()) { | ||
console.info(`%c ${this.identifier}: OriginalInfo`, 'color:#3300CC'); | ||
console.log(...args); | ||
} else { | ||
console.info(`%c ${this.identifier}: OriginalInfo`, 'color:#3300CC'); | ||
console.log(...args); | ||
} | ||
} | ||
} | ||
constructor(identifier){ | ||
this.enable = false; | ||
this.identifier = identifier || DEBUG_LOG; | ||
if (isBrowserEnv() && safeGetLocalStorageItem()) { | ||
this.enable = true; | ||
} else if (isDebugMode()) { | ||
this.enable = true; | ||
} | ||
} | ||
}; | ||
@@ -168,2 +172,3 @@ const LOG_CATEGORY = '[ Federation Runtime ]'; | ||
}; | ||
const logger = new Logger(); | ||
const composeKeyWithSeparator = function(...args) { | ||
@@ -762,2 +767,3 @@ if (!args.length) { | ||
exports.FederationModuleManifest = FederationModuleManifest; | ||
exports.Logger = Logger; | ||
exports.MANIFEST_EXT = MANIFEST_EXT; | ||
@@ -778,3 +784,2 @@ exports.MFModuleType = MFModuleType; | ||
exports.createLink = createLink; | ||
exports.createLogger = createLogger; | ||
exports.createScript = createScript; | ||
@@ -781,0 +786,0 @@ exports.createScriptNode = createScriptNode; |
@@ -1,2 +0,1 @@ | ||
import { createLogger as createLogger$1 } from 'isomorphic-rslog'; | ||
import { _ as _extends } from './polyfills.esm.js'; | ||
@@ -60,12 +59,2 @@ | ||
} | ||
function isBrowserDebug() { | ||
try { | ||
if (isBrowserEnv() && window.localStorage) { | ||
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE; | ||
} | ||
} catch (error) { | ||
return false; | ||
} | ||
return false; | ||
} | ||
function isDebugMode() { | ||
@@ -75,6 +64,3 @@ if (typeof process !== 'undefined' && process.env && process.env['FEDERATION_DEBUG']) { | ||
} | ||
if (typeof FEDERATION_DEBUG !== 'undefined' && Boolean(FEDERATION_DEBUG)) { | ||
return true; | ||
} | ||
return isBrowserDebug(); | ||
return typeof FEDERATION_DEBUG !== 'undefined' && Boolean(FEDERATION_DEBUG); | ||
} | ||
@@ -85,34 +71,52 @@ const getProcessEnv = function() { | ||
const PREFIX = '[ Module Federation ]'; | ||
function setDebug(loggerInstance) { | ||
if (isDebugMode()) { | ||
loggerInstance.level = 'verbose'; | ||
const DEBUG_LOG = '[ FEDERATION DEBUG ]'; | ||
function safeToString$1(info) { | ||
try { | ||
return JSON.stringify(info, null, 2); | ||
} catch (e) { | ||
return ''; | ||
} | ||
} | ||
function setPrefix(loggerInstance, prefix) { | ||
loggerInstance.labels = { | ||
warn: `${prefix} Warn`, | ||
error: `${prefix} Error`, | ||
success: `${prefix} Success`, | ||
info: `${prefix} Info`, | ||
ready: `${prefix} Ready`, | ||
debug: `${prefix} 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; | ||
} | ||
function createLogger(prefix) { | ||
const loggerInstance = createLogger$1({ | ||
labels: { | ||
warn: `${PREFIX} Warn`, | ||
error: `${PREFIX} Error`, | ||
success: `${PREFIX} Success`, | ||
info: `${PREFIX} Info`, | ||
ready: `${PREFIX} Ready`, | ||
debug: `${PREFIX} Debug` | ||
let Logger = class Logger { | ||
info(msg, info) { | ||
if (this.enable) { | ||
const argsToString = safeToString$1(info) || ''; | ||
if (isBrowserEnv()) { | ||
console.info(`%c ${this.identifier}: ${msg} ${argsToString}`, 'color:#3300CC'); | ||
} else { | ||
console.info('\x1b[34m%s', `${this.identifier}: ${msg} ${argsToString ? `\n${argsToString}` : ''}`); | ||
} | ||
} | ||
}); | ||
setDebug(loggerInstance); | ||
setPrefix(loggerInstance, prefix); | ||
return loggerInstance; | ||
} | ||
const logger = createLogger(PREFIX); | ||
} | ||
logOriginalInfo(...args) { | ||
if (this.enable) { | ||
if (isBrowserEnv()) { | ||
console.info(`%c ${this.identifier}: OriginalInfo`, 'color:#3300CC'); | ||
console.log(...args); | ||
} else { | ||
console.info(`%c ${this.identifier}: OriginalInfo`, 'color:#3300CC'); | ||
console.log(...args); | ||
} | ||
} | ||
} | ||
constructor(identifier){ | ||
this.enable = false; | ||
this.identifier = identifier || DEBUG_LOG; | ||
if (isBrowserEnv() && safeGetLocalStorageItem()) { | ||
this.enable = true; | ||
} else if (isDebugMode()) { | ||
this.enable = true; | ||
} | ||
} | ||
}; | ||
@@ -166,2 +170,3 @@ const LOG_CATEGORY = '[ Federation Runtime ]'; | ||
}; | ||
const logger = new Logger(); | ||
const composeKeyWithSeparator = function(...args) { | ||
@@ -755,2 +760,2 @@ if (!args.length) { | ||
export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, ENCODE_NAME_PREFIX, EncodedNameTransformMap, FederationModuleManifest, MANIFEST_EXT, MFModuleType, MFPrefetchCommon, MODULE_DEVTOOL_IDENTIFIER, ManifestFileName, NameTransformMap, NameTransformSymbol, SEPARATOR, StatsFileName, TEMP_DIR, assert, composeKeyWithSeparator, ContainerPlugin as containerPlugin, ContainerReferencePlugin as containerReferencePlugin, createLink, createLogger, 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, isRequiredVersion, isStaticResourcesEqual, loadScript, loadScriptNode, logger, ModuleFederationPlugin as moduleFederationPlugin, normalizeOptions, parseEntry, safeToString, safeWrapper, SharePlugin as sharePlugin, simpleJoinRemoteEntry, warn }; |
{ | ||
"name": "@module-federation/sdk", | ||
"version": "0.6.14", | ||
"version": "0.6.11", | ||
"license": "MIT", | ||
@@ -43,6 +43,3 @@ "description": "A sdk for support module federation", | ||
} | ||
}, | ||
"dependencies": { | ||
"isomorphic-rslog": "0.0.5" | ||
} | ||
} |
@@ -1,5 +0,8 @@ | ||
import { type Logger } from 'isomorphic-rslog'; | ||
declare function createLogger(prefix: string): Logger; | ||
declare const logger: Logger; | ||
export { logger, createLogger }; | ||
export type { Logger }; | ||
declare class Logger { | ||
enable: boolean; | ||
identifier: string; | ||
constructor(identifier?: string); | ||
info(msg: string, info?: any): void; | ||
logOriginalInfo(...args: unknown[]): void; | ||
} | ||
export { Logger }; |
import { RemoteEntryInfo, ModuleInfo } from './types'; | ||
import { logger } from './logger'; | ||
import { Logger } from './logger'; | ||
declare const parseEntry: (str: string, devVerOrUrl?: string, separator?: string) => RemoteEntryInfo; | ||
@@ -7,2 +7,3 @@ declare global { | ||
} | ||
declare const logger: Logger; | ||
declare const composeKeyWithSeparator: (...args: (string | undefined)[]) => string; | ||
@@ -9,0 +10,0 @@ declare const encodeName: (name: string, prefix?: string, withExt?: boolean) => string; |
{ | ||
"name": "@module-federation/sdk", | ||
"version": "0.0.0-next-20241104032754", | ||
"version": "0.0.0-next-20241104073605", | ||
"license": "MIT", | ||
@@ -43,6 +43,3 @@ "description": "A sdk for support module federation", | ||
} | ||
}, | ||
"dependencies": { | ||
"isomorphic-rslog": "0.0.5" | ||
} | ||
} |
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
105125
0
2632
- Removedisomorphic-rslog@0.0.5
- Removedisomorphic-rslog@0.0.5(transitive)