@rspack/core 1.0.0-beta.1 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ChunkGroup.d.ts +1 -0
- package/dist/ChunkGroup.js +3 -0
- package/dist/Compilation.d.ts +18 -0
- package/dist/Compiler.js +2 -2
- package/dist/ExecuteModulePlugin.d.ts +0 -1
- package/dist/ExecuteModulePlugin.js +0 -1
- package/dist/Module.d.ts +1 -2
- package/dist/Module.js +0 -1
- package/dist/MultiCompiler.js +1 -1
- package/dist/Resolver.d.ts +1 -2
- package/dist/RspackError.js +1 -1
- package/dist/Stats.js +22 -2
- package/dist/Template.js +2 -2
- package/dist/builtin-loader/lightningcss/index.js +1 -1
- package/dist/builtin-plugin/DefinePlugin.js +1 -1
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +2 -2
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +1 -1
- package/dist/builtin-plugin/EnableLibraryPlugin.js +1 -6
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +2 -2
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +1 -1
- package/dist/builtin-plugin/ExternalsPlugin.js +1 -1
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +0 -1
- package/dist/builtin-plugin/JavascriptModulesPlugin.js +1 -1
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -2
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +3 -5
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +7 -5
- package/dist/builtin-plugin/css-extract/loader.js +4 -10
- package/dist/builtin-plugin/lazy-compilation/backend.js +4 -4
- package/dist/config/adapter.js +1 -0
- package/dist/config/adapterRuleUse.d.ts +2 -6
- package/dist/config/adapterRuleUse.js +7 -6
- package/dist/config/defaults.js +21 -32
- package/dist/config/normalization.d.ts +1 -0
- package/dist/config/normalization.js +5 -2
- package/dist/config/zod.d.ts +440 -68
- package/dist/config/zod.js +21 -1
- package/dist/container/default.runtime.js +1 -1
- package/dist/lib/AbstractMethodError.js +2 -3
- package/dist/lib/Cache.d.ts +1 -1
- package/dist/lib/Dependency.d.ts +23 -0
- package/dist/lib/Dependency.js +11 -0
- package/dist/lib/EnvironmentPlugin.js +1 -3
- package/dist/lib/ModuleFilenameHelpers.js +1 -1
- package/dist/lib/WebpackError.d.ts +0 -6
- package/dist/lib/WebpackError.js +0 -8
- package/dist/lib/cache/MemoryCachePlugin.d.ts +5 -0
- package/dist/lib/cache/MemoryCachePlugin.js +40 -0
- package/dist/lib/formatLocation.d.ts +1 -1
- package/dist/loader-runner/index.js +6 -7
- package/dist/loader-runner/loadLoader.js +8 -11
- package/dist/logging/Logger.js +3 -3
- package/dist/logging/createConsoleLogger.d.ts +26 -6
- package/dist/logging/createConsoleLogger.js +21 -58
- package/dist/logging/runtime.d.ts +4 -10
- package/dist/logging/runtime.js +8 -23
- package/dist/logging/truncateArgs.d.ts +4 -4
- package/dist/logging/truncateArgs.js +5 -10
- package/dist/node/NodeEnvironmentPlugin.js +2 -2
- package/dist/node/NodeWatchFileSystem.js +6 -6
- package/dist/node/nodeConsole.d.ts +7 -21
- package/dist/node/nodeConsole.js +29 -36
- package/dist/rspackOptionsApply.d.ts +0 -1
- package/dist/rspackOptionsApply.js +8 -7
- package/dist/sharing/ProvideSharedPlugin.d.ts +20 -19
- package/dist/sharing/ProvideSharedPlugin.js +26 -17
- package/dist/sharing/SharePlugin.d.ts +3 -0
- package/dist/sharing/SharePlugin.js +4 -1
- package/dist/stats/DefaultStatsFactoryPlugin.js +187 -96
- package/dist/stats/DefaultStatsPresetPlugin.js +1 -2
- package/dist/stats/DefaultStatsPrinterPlugin.js +18 -19
- package/dist/stats/StatsFactory.d.ts +2 -1
- package/dist/stats/StatsFactory.js +2 -6
- package/dist/stats/statsFactoryUtils.d.ts +63 -23
- package/dist/util/SizeFormatHelpers.js +1 -1
- package/dist/util/bindingVersionCheck.js +3 -3
- package/dist/util/cleverMerge.js +3 -2
- package/dist/util/comparators.d.ts +1 -1
- package/dist/util/comparators.js +5 -4
- package/dist/util/createHash.js +1 -1
- package/dist/util/fs.js +2 -2
- package/dist/util/identifier.js +2 -2
- package/dist/util/index.js +1 -1
- package/dist/util/memoize.js +1 -4
- package/dist/util/smartGrouping.js +4 -6
- package/dist/util/webpack.d.ts +1 -1
- package/dist/util/webpack.js +2 -1
- package/module.d.ts +1 -1
- package/package.json +3 -3
package/dist/config/zod.js
CHANGED
|
@@ -184,6 +184,7 @@ const output = zod_1.z.strictObject({
|
|
|
184
184
|
chunkFilename: chunkFilename.optional(),
|
|
185
185
|
crossOriginLoading: crossOriginLoading.optional(),
|
|
186
186
|
cssFilename: cssFilename.optional(),
|
|
187
|
+
cssHeadDataCompression: zod_1.z.boolean().optional(),
|
|
187
188
|
cssChunkFilename: cssChunkFilename.optional(),
|
|
188
189
|
hotUpdateMainFilename: hotUpdateMainFilename.optional(),
|
|
189
190
|
hotUpdateChunkFilename: hotUpdateChunkFilename.optional(),
|
|
@@ -732,7 +733,9 @@ const statsOptions = zod_1.z.strictObject({
|
|
|
732
733
|
groupReasonsByOrigin: zod_1.z.boolean().optional(),
|
|
733
734
|
errorDetails: zod_1.z.boolean().optional(),
|
|
734
735
|
errorStack: zod_1.z.boolean().optional(),
|
|
735
|
-
moduleTrace: zod_1.z.boolean().optional()
|
|
736
|
+
moduleTrace: zod_1.z.boolean().optional(),
|
|
737
|
+
cachedModules: zod_1.z.boolean().optional(),
|
|
738
|
+
cached: zod_1.z.boolean().optional()
|
|
736
739
|
});
|
|
737
740
|
const statsValue = zod_1.z.boolean().or(statsPresets).or(statsOptions);
|
|
738
741
|
const plugin = zod_1.z.union([
|
|
@@ -851,7 +854,24 @@ const rspackFutureOptions = zod_1.z.strictObject({
|
|
|
851
854
|
})
|
|
852
855
|
.optional()
|
|
853
856
|
});
|
|
857
|
+
const listenOptions = zod_1.z.object({
|
|
858
|
+
port: zod_1.z.number().optional(),
|
|
859
|
+
host: zod_1.z.string().optional(),
|
|
860
|
+
backlog: zod_1.z.number().optional(),
|
|
861
|
+
path: zod_1.z.string().optional(),
|
|
862
|
+
exclusive: zod_1.z.boolean().optional(),
|
|
863
|
+
readableAll: zod_1.z.boolean().optional(),
|
|
864
|
+
writableAll: zod_1.z.boolean().optional(),
|
|
865
|
+
ipv6Only: zod_1.z.boolean().optional()
|
|
866
|
+
});
|
|
854
867
|
const lazyCompilationOptions = zod_1.z.object({
|
|
868
|
+
backend: zod_1.z
|
|
869
|
+
.object({
|
|
870
|
+
client: zod_1.z.string().optional(),
|
|
871
|
+
listen: zod_1.z.number().optional().or(listenOptions),
|
|
872
|
+
protocol: zod_1.z.enum(["http", "https"]).optional()
|
|
873
|
+
})
|
|
874
|
+
.optional(),
|
|
855
875
|
imports: zod_1.z.boolean().optional(),
|
|
856
876
|
entries: zod_1.z.boolean().optional(),
|
|
857
877
|
test: zod_1.z
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __module_federation_bundler_runtime__,__module_federation_runtime_plugins__,__module_federation_remote_infos__,__module_federation_container_name__;module.exports=function(){if((__webpack_require__.initializeSharingData||__webpack_require__.initializeExposesData)&&__webpack_require__.federation){var __webpack_require___remotesLoadingData,__webpack_require___remotesLoadingData1,__webpack_require___initializeSharingData,__webpack_require___consumesLoadingData,__webpack_require___consumesLoadingData1,__webpack_require___initializeExposesData,__webpack_require___consumesLoadingData2;const override=(obj,key,value)=>{if(!obj)return;if(obj[key])obj[key]=value};const merge=(obj,key,fn)=>{const value=fn();if(Array.isArray(value)){var _obj,_key;var _;(_=(_obj=obj)[_key=key])!==null&&_!==void 0?_:_obj[_key]=[];obj[key].push(...value)}else if(typeof value==="object"&&value!==null){var _obj1,_key1;var _1;(_1=(_obj1=obj)[_key1=key])!==null&&_1!==void 0?_1:_obj1[_key1]={};Object.assign(obj[key],value)}};const early=(obj,key,initial)=>{var _obj,_key;var _;(_=(_obj=obj)[_key=key])!==null&&_!==void 0?_:_obj[_key]=initial()};var __webpack_require___remotesLoadingData_chunkMapping;const remotesLoadingChunkMapping=(__webpack_require___remotesLoadingData_chunkMapping=(__webpack_require___remotesLoadingData=__webpack_require__.remotesLoadingData)===null||__webpack_require___remotesLoadingData===void 0?void 0:__webpack_require___remotesLoadingData.chunkMapping)!==null&&__webpack_require___remotesLoadingData_chunkMapping!==void 0?__webpack_require___remotesLoadingData_chunkMapping:{};var __webpack_require___remotesLoadingData_moduleIdToRemoteDataMapping;const remotesLoadingModuleIdToRemoteDataMapping=(__webpack_require___remotesLoadingData_moduleIdToRemoteDataMapping=(__webpack_require___remotesLoadingData1=__webpack_require__.remotesLoadingData)===null||__webpack_require___remotesLoadingData1===void 0?void 0:__webpack_require___remotesLoadingData1.moduleIdToRemoteDataMapping)!==null&&__webpack_require___remotesLoadingData_moduleIdToRemoteDataMapping!==void 0?__webpack_require___remotesLoadingData_moduleIdToRemoteDataMapping:{};var __webpack_require___initializeSharingData_scopeToSharingDataMapping;const initializeSharingScopeToInitDataMapping=(__webpack_require___initializeSharingData_scopeToSharingDataMapping=(__webpack_require___initializeSharingData=__webpack_require__.initializeSharingData)===null||__webpack_require___initializeSharingData===void 0?void 0:__webpack_require___initializeSharingData.scopeToSharingDataMapping)!==null&&__webpack_require___initializeSharingData_scopeToSharingDataMapping!==void 0?__webpack_require___initializeSharingData_scopeToSharingDataMapping:{};var __webpack_require___consumesLoadingData_chunkMapping;const consumesLoadingChunkMapping=(__webpack_require___consumesLoadingData_chunkMapping=(__webpack_require___consumesLoadingData=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData===void 0?void 0:__webpack_require___consumesLoadingData.chunkMapping)!==null&&__webpack_require___consumesLoadingData_chunkMapping!==void 0?__webpack_require___consumesLoadingData_chunkMapping:{};var __webpack_require___consumesLoadingData_moduleIdToConsumeDataMapping;const consumesLoadingModuleToConsumeDataMapping=(__webpack_require___consumesLoadingData_moduleIdToConsumeDataMapping=(__webpack_require___consumesLoadingData1=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData1===void 0?void 0:__webpack_require___consumesLoadingData1.moduleIdToConsumeDataMapping)!==null&&__webpack_require___consumesLoadingData_moduleIdToConsumeDataMapping!==void 0?__webpack_require___consumesLoadingData_moduleIdToConsumeDataMapping:{};const consumesLoadinginstalledModules={};const initializeSharingInitPromises=[];const initializeSharingInitTokens=[];const containerShareScope=(__webpack_require___initializeExposesData=__webpack_require__.initializeExposesData)===null||__webpack_require___initializeExposesData===void 0?void 0:__webpack_require___initializeExposesData.shareScope;for(const key in __module_federation_bundler_runtime__){__webpack_require__.federation[key]=__module_federation_bundler_runtime__[key]}early(__webpack_require__.federation,"consumesLoadingModuleToHandlerMapping",()=>{const consumesLoadingModuleToHandlerMapping={};for(let[moduleId,data]of Object.entries(consumesLoadingModuleToConsumeDataMapping)){consumesLoadingModuleToHandlerMapping[moduleId]={getter:data.fallback,shareInfo:{shareConfig:{fixedDependencies:false,requiredVersion:data.requiredVersion,strictVersion:data.strictVersion,singleton:data.singleton,eager:data.eager},scope:[data.shareScope]},shareKey:data.shareKey}}return consumesLoadingModuleToHandlerMapping});early(__webpack_require__.federation,"initOptions",()=>({}));early(__webpack_require__.federation.initOptions,"name",()=>__module_federation_container_name__);early(__webpack_require__.federation.initOptions,"shared",()=>{const shared={};for(let[scope,stages]of Object.entries(initializeSharingScopeToInitDataMapping)){for(let stage of stages){if(typeof stage==="object"&&stage!==null){const{name,version,factory,eager}=stage;const options={version,scope:[scope],get:factory};if(shared[name]){shared[name].push(options)}else{shared[name]=[options]}}}}return shared});merge(__webpack_require__.federation.initOptions,"remotes",()=>Object.values(__module_federation_remote_infos__).flat().filter(remote=>remote.externalType==="script"));merge(__webpack_require__.federation.initOptions,"plugins",()=>__module_federation_runtime_plugins__);early(__webpack_require__.federation,"bundlerRuntimeOptions",()=>({}));early(__webpack_require__.federation.bundlerRuntimeOptions,"remotes",()=>({}));early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"chunkMapping",()=>remotesLoadingChunkMapping);early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"idToExternalAndNameMapping",()=>{const remotesLoadingIdToExternalAndNameMappingMapping={};for(let[moduleId,data]of Object.entries(remotesLoadingModuleIdToRemoteDataMapping)){remotesLoadingIdToExternalAndNameMappingMapping[moduleId]=[data.shareScope,data.name,data.externalModuleId,data.remoteName]}return remotesLoadingIdToExternalAndNameMappingMapping});early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"webpackRequire",()=>__webpack_require__);merge(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"idToRemoteMap",()=>{const idToRemoteMap={};for(let[id,remoteData]of Object.entries(remotesLoadingModuleIdToRemoteDataMapping)){const info=__module_federation_remote_infos__[remoteData.remoteName];if(info)idToRemoteMap[id]=info}return idToRemoteMap});override(__webpack_require__,"S",__webpack_require__.federation.bundlerRuntime.S);if(__webpack_require__.federation.attachShareScopeMap){__webpack_require__.federation.attachShareScopeMap(__webpack_require__)}override(__webpack_require__.f,"remotes",(chunkId,promises)=>__webpack_require__.federation.bundlerRuntime.remotes({chunkId,promises,chunkMapping:remotesLoadingChunkMapping,idToExternalAndNameMapping:__webpack_require__.federation.bundlerRuntimeOptions.remotes.idToExternalAndNameMapping,idToRemoteMap:__webpack_require__.federation.bundlerRuntimeOptions.remotes.idToRemoteMap,webpackRequire:__webpack_require__}));override(__webpack_require__.f,"consumes",(chunkId,promises)=>__webpack_require__.federation.bundlerRuntime.consumes({chunkId,promises,chunkMapping:consumesLoadingChunkMapping,moduleToHandlerMapping:__webpack_require__.federation.consumesLoadingModuleToHandlerMapping,installedModules:consumesLoadinginstalledModules,webpackRequire:__webpack_require__}));override(__webpack_require__,"I",(name,initScope)=>__webpack_require__.federation.bundlerRuntime.I({shareScopeName:name,initScope,initPromises:initializeSharingInitPromises,initTokens:initializeSharingInitTokens,webpackRequire:__webpack_require__}));override(__webpack_require__,"initContainer",(shareScope,initScope,remoteEntryInitOptions)=>__webpack_require__.federation.bundlerRuntime.initContainerEntry({shareScope,initScope,remoteEntryInitOptions,shareScopeKey:containerShareScope,webpackRequire:__webpack_require__}));override(__webpack_require__,"getContainer",(module1,getScope)=>{var moduleMap=__webpack_require__.initializeExposesData.moduleMap;__webpack_require__.R=getScope;getScope=Object.prototype.hasOwnProperty.call(moduleMap,module1)?moduleMap[module1]():Promise.resolve().then(()=>{throw new Error('Module "'+module1+'" does not exist in container.')});__webpack_require__.R=undefined;return getScope});__webpack_require__.federation.instance=__webpack_require__.federation.runtime.init(__webpack_require__.federation.initOptions);if((__webpack_require___consumesLoadingData2=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData2===void 0?void 0:__webpack_require___consumesLoadingData2.initialConsumes){__webpack_require__.federation.bundlerRuntime.installInitialConsumes({webpackRequire:__webpack_require__,installedModules:consumesLoadinginstalledModules,initialConsumes:__webpack_require__.consumesLoadingData.initialConsumes,moduleToHandlerMapping:__webpack_require__.federation.consumesLoadingModuleToHandlerMapping})}}};
|
|
1
|
+
var __module_federation_bundler_runtime__,__module_federation_runtime_plugins__,__module_federation_remote_infos__,__module_federation_container_name__;module.exports=function(){if((__webpack_require__.initializeSharingData||__webpack_require__.initializeExposesData)&&__webpack_require__.federation){var __webpack_require___remotesLoadingData,__webpack_require___remotesLoadingData1,__webpack_require___initializeSharingData,__webpack_require___consumesLoadingData,__webpack_require___consumesLoadingData1,__webpack_require___initializeExposesData,__webpack_require___consumesLoadingData2;const override=(obj,key,value)=>{if(!obj)return;if(obj[key])obj[key]=value};const merge=(obj,key,fn)=>{const value=fn();if(Array.isArray(value)){var _obj,_key;var _;(_=(_obj=obj)[_key=key])!==null&&_!==void 0?_:_obj[_key]=[];obj[key].push(...value)}else if(typeof value==="object"&&value!==null){var _obj1,_key1;var _1;(_1=(_obj1=obj)[_key1=key])!==null&&_1!==void 0?_1:_obj1[_key1]={};Object.assign(obj[key],value)}};const early=(obj,key,initial)=>{var _obj,_key;var _;(_=(_obj=obj)[_key=key])!==null&&_!==void 0?_:_obj[_key]=initial()};var __webpack_require___remotesLoadingData_chunkMapping;const remotesLoadingChunkMapping=(__webpack_require___remotesLoadingData_chunkMapping=(__webpack_require___remotesLoadingData=__webpack_require__.remotesLoadingData)===null||__webpack_require___remotesLoadingData===void 0?void 0:__webpack_require___remotesLoadingData.chunkMapping)!==null&&__webpack_require___remotesLoadingData_chunkMapping!==void 0?__webpack_require___remotesLoadingData_chunkMapping:{};var __webpack_require___remotesLoadingData_moduleIdToRemoteDataMapping;const remotesLoadingModuleIdToRemoteDataMapping=(__webpack_require___remotesLoadingData_moduleIdToRemoteDataMapping=(__webpack_require___remotesLoadingData1=__webpack_require__.remotesLoadingData)===null||__webpack_require___remotesLoadingData1===void 0?void 0:__webpack_require___remotesLoadingData1.moduleIdToRemoteDataMapping)!==null&&__webpack_require___remotesLoadingData_moduleIdToRemoteDataMapping!==void 0?__webpack_require___remotesLoadingData_moduleIdToRemoteDataMapping:{};var __webpack_require___initializeSharingData_scopeToSharingDataMapping;const initializeSharingScopeToInitDataMapping=(__webpack_require___initializeSharingData_scopeToSharingDataMapping=(__webpack_require___initializeSharingData=__webpack_require__.initializeSharingData)===null||__webpack_require___initializeSharingData===void 0?void 0:__webpack_require___initializeSharingData.scopeToSharingDataMapping)!==null&&__webpack_require___initializeSharingData_scopeToSharingDataMapping!==void 0?__webpack_require___initializeSharingData_scopeToSharingDataMapping:{};var __webpack_require___consumesLoadingData_chunkMapping;const consumesLoadingChunkMapping=(__webpack_require___consumesLoadingData_chunkMapping=(__webpack_require___consumesLoadingData=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData===void 0?void 0:__webpack_require___consumesLoadingData.chunkMapping)!==null&&__webpack_require___consumesLoadingData_chunkMapping!==void 0?__webpack_require___consumesLoadingData_chunkMapping:{};var __webpack_require___consumesLoadingData_moduleIdToConsumeDataMapping;const consumesLoadingModuleToConsumeDataMapping=(__webpack_require___consumesLoadingData_moduleIdToConsumeDataMapping=(__webpack_require___consumesLoadingData1=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData1===void 0?void 0:__webpack_require___consumesLoadingData1.moduleIdToConsumeDataMapping)!==null&&__webpack_require___consumesLoadingData_moduleIdToConsumeDataMapping!==void 0?__webpack_require___consumesLoadingData_moduleIdToConsumeDataMapping:{};const consumesLoadinginstalledModules={};const initializeSharingInitPromises=[];const initializeSharingInitTokens=[];const containerShareScope=(__webpack_require___initializeExposesData=__webpack_require__.initializeExposesData)===null||__webpack_require___initializeExposesData===void 0?void 0:__webpack_require___initializeExposesData.shareScope;for(const key in __module_federation_bundler_runtime__){__webpack_require__.federation[key]=__module_federation_bundler_runtime__[key]}early(__webpack_require__.federation,"consumesLoadingModuleToHandlerMapping",()=>{const consumesLoadingModuleToHandlerMapping={};for(let[moduleId,data]of Object.entries(consumesLoadingModuleToConsumeDataMapping)){consumesLoadingModuleToHandlerMapping[moduleId]={getter:data.fallback,shareInfo:{shareConfig:{fixedDependencies:false,requiredVersion:data.requiredVersion,strictVersion:data.strictVersion,singleton:data.singleton,eager:data.eager},scope:[data.shareScope]},shareKey:data.shareKey}}return consumesLoadingModuleToHandlerMapping});early(__webpack_require__.federation,"initOptions",()=>({}));early(__webpack_require__.federation.initOptions,"name",()=>__module_federation_container_name__);early(__webpack_require__.federation.initOptions,"shared",()=>{const shared={};for(let[scope,stages]of Object.entries(initializeSharingScopeToInitDataMapping)){for(let stage of stages){if(typeof stage==="object"&&stage!==null){const{name,version,factory,eager,singleton,requiredVersion,strictVersion}=stage;const options={version,scope:[scope],eager,singleton,requiredVersion,strictVersion,get:factory};if(shared[name]){shared[name].push(options)}else{shared[name]=[options]}}}}return shared});merge(__webpack_require__.federation.initOptions,"remotes",()=>Object.values(__module_federation_remote_infos__).flat().filter(remote=>remote.externalType==="script"));merge(__webpack_require__.federation.initOptions,"plugins",()=>__module_federation_runtime_plugins__);early(__webpack_require__.federation,"bundlerRuntimeOptions",()=>({}));early(__webpack_require__.federation.bundlerRuntimeOptions,"remotes",()=>({}));early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"chunkMapping",()=>remotesLoadingChunkMapping);early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"idToExternalAndNameMapping",()=>{const remotesLoadingIdToExternalAndNameMappingMapping={};for(let[moduleId,data]of Object.entries(remotesLoadingModuleIdToRemoteDataMapping)){remotesLoadingIdToExternalAndNameMappingMapping[moduleId]=[data.shareScope,data.name,data.externalModuleId,data.remoteName]}return remotesLoadingIdToExternalAndNameMappingMapping});early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"webpackRequire",()=>__webpack_require__);merge(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"idToRemoteMap",()=>{const idToRemoteMap={};for(let[id,remoteData]of Object.entries(remotesLoadingModuleIdToRemoteDataMapping)){const info=__module_federation_remote_infos__[remoteData.remoteName];if(info)idToRemoteMap[id]=info}return idToRemoteMap});override(__webpack_require__,"S",__webpack_require__.federation.bundlerRuntime.S);if(__webpack_require__.federation.attachShareScopeMap){__webpack_require__.federation.attachShareScopeMap(__webpack_require__)}override(__webpack_require__.f,"remotes",(chunkId,promises)=>__webpack_require__.federation.bundlerRuntime.remotes({chunkId,promises,chunkMapping:remotesLoadingChunkMapping,idToExternalAndNameMapping:__webpack_require__.federation.bundlerRuntimeOptions.remotes.idToExternalAndNameMapping,idToRemoteMap:__webpack_require__.federation.bundlerRuntimeOptions.remotes.idToRemoteMap,webpackRequire:__webpack_require__}));override(__webpack_require__.f,"consumes",(chunkId,promises)=>__webpack_require__.federation.bundlerRuntime.consumes({chunkId,promises,chunkMapping:consumesLoadingChunkMapping,moduleToHandlerMapping:__webpack_require__.federation.consumesLoadingModuleToHandlerMapping,installedModules:consumesLoadinginstalledModules,webpackRequire:__webpack_require__}));override(__webpack_require__,"I",(name,initScope)=>__webpack_require__.federation.bundlerRuntime.I({shareScopeName:name,initScope,initPromises:initializeSharingInitPromises,initTokens:initializeSharingInitTokens,webpackRequire:__webpack_require__}));override(__webpack_require__,"initContainer",(shareScope,initScope,remoteEntryInitOptions)=>__webpack_require__.federation.bundlerRuntime.initContainerEntry({shareScope,initScope,remoteEntryInitOptions,shareScopeKey:containerShareScope,webpackRequire:__webpack_require__}));override(__webpack_require__,"getContainer",(module1,getScope)=>{var moduleMap=__webpack_require__.initializeExposesData.moduleMap;__webpack_require__.R=getScope;getScope=Object.prototype.hasOwnProperty.call(moduleMap,module1)?moduleMap[module1]():Promise.resolve().then(()=>{throw new Error('Module "'+module1+'" does not exist in container.')});__webpack_require__.R=undefined;return getScope});__webpack_require__.federation.instance=__webpack_require__.federation.runtime.init(__webpack_require__.federation.initOptions);if((__webpack_require___consumesLoadingData2=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData2===void 0?void 0:__webpack_require___consumesLoadingData2.initialConsumes){__webpack_require__.federation.bundlerRuntime.installInitialConsumes({webpackRequire:__webpack_require__,installedModules:consumesLoadinginstalledModules,initialConsumes:__webpack_require__.consumesLoadingData.initialConsumes,moduleToHandlerMapping:__webpack_require__.federation.consumesLoadingModuleToHandlerMapping})}}};
|
|
@@ -20,7 +20,7 @@ const CURRENT_METHOD_REGEXP = /at ([a-zA-Z0-9_.]*)/;
|
|
|
20
20
|
* @returns message
|
|
21
21
|
*/
|
|
22
22
|
function createMessage(method) {
|
|
23
|
-
return `Abstract method${method ?
|
|
23
|
+
return `Abstract method${method ? ` ${method}` : ""}. Must be overridden.`;
|
|
24
24
|
}
|
|
25
25
|
class Message extends Error {
|
|
26
26
|
constructor() {
|
|
@@ -28,8 +28,7 @@ class Message extends Error {
|
|
|
28
28
|
this.stack = undefined;
|
|
29
29
|
Error.captureStackTrace(this);
|
|
30
30
|
const match = this.stack.split("\n")[3].match(CURRENT_METHOD_REGEXP);
|
|
31
|
-
this.message =
|
|
32
|
-
match && match[1] ? createMessage(match[1]) : createMessage();
|
|
31
|
+
this.message = match?.[1] ? createMessage(match[1]) : createMessage();
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
/**
|
package/dist/lib/Cache.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface Etag {
|
|
|
13
13
|
toString(): string;
|
|
14
14
|
}
|
|
15
15
|
export type CallbackCache<T> = (err?: WebpackError | null, result?: T) => void;
|
|
16
|
-
type GotHandler<T = any> = (result: any | null, callback: (error: Error) => void) => void;
|
|
16
|
+
type GotHandler<T = any> = (result: any | null, callback: (error: Error | null) => void) => void;
|
|
17
17
|
export declare class Cache {
|
|
18
18
|
static STAGE_DISK: number;
|
|
19
19
|
static STAGE_MEMORY: number;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The following code is modified based on
|
|
3
|
+
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/Dependency.js
|
|
4
|
+
*
|
|
5
|
+
* MIT Licensed
|
|
6
|
+
* Author Tobias Koppers @sokra
|
|
7
|
+
* Copyright (c) JS Foundation and other contributors
|
|
8
|
+
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
9
|
+
*/
|
|
10
|
+
export type SourcePosition = {
|
|
11
|
+
line: number;
|
|
12
|
+
column?: number;
|
|
13
|
+
};
|
|
14
|
+
export type RealDependencyLocation = {
|
|
15
|
+
start: SourcePosition;
|
|
16
|
+
end?: SourcePosition;
|
|
17
|
+
index?: number;
|
|
18
|
+
};
|
|
19
|
+
export type SyntheticDependencyLocation = {
|
|
20
|
+
name: string;
|
|
21
|
+
index?: number;
|
|
22
|
+
};
|
|
23
|
+
export type DependencyLocation = SyntheticDependencyLocation | RealDependencyLocation;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The following code is modified based on
|
|
4
|
+
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/Dependency.js
|
|
5
|
+
*
|
|
6
|
+
* MIT Licensed
|
|
7
|
+
* Author Tobias Koppers @sokra
|
|
8
|
+
* Copyright (c) JS Foundation and other contributors
|
|
9
|
+
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -43,9 +43,7 @@ class EnvironmentPlugin {
|
|
|
43
43
|
: this.defaultValues[key];
|
|
44
44
|
if (value === undefined) {
|
|
45
45
|
compiler.hooks.thisCompilation.tap("EnvironmentPlugin", compilation => {
|
|
46
|
-
const error = new WebpackError_1.default(`EnvironmentPlugin - ${key} environment variable is undefined.\n\
|
|
47
|
-
"You can pass an object with default values to suppress this warning.\n" +
|
|
48
|
-
"See https://webpack.js.org/plugins/environment-plugin for example.");
|
|
46
|
+
const error = new WebpackError_1.default(`EnvironmentPlugin - ${key} environment variable is undefined.\n\nYou can pass an object with default values to suppress this warning.\nSee https://webpack.js.org/plugins/environment-plugin for example.`);
|
|
49
47
|
error.name = "EnvVariableNotDefinedError";
|
|
50
48
|
compilation.errors.push(error);
|
|
51
49
|
});
|
|
@@ -25,7 +25,7 @@ const asRegExp = (test) => {
|
|
|
25
25
|
if (typeof test === "string") {
|
|
26
26
|
// Escape special characters in the string to prevent them from being interpreted as special characters in a regular expression. Do this by
|
|
27
27
|
// adding a backslash before each special character
|
|
28
|
-
return new RegExp(
|
|
28
|
+
return new RegExp(`^${test.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")}`);
|
|
29
29
|
}
|
|
30
30
|
return test;
|
|
31
31
|
};
|
|
@@ -19,12 +19,6 @@ export declare class WebpackError extends Error {
|
|
|
19
19
|
module?: Module;
|
|
20
20
|
details?: string;
|
|
21
21
|
hideStack?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Creates an instance of WebpackError.
|
|
24
|
-
* @param message error message
|
|
25
|
-
* @returns
|
|
26
|
-
*/
|
|
27
|
-
constructor(message?: string);
|
|
28
22
|
[inspect.custom](): string;
|
|
29
23
|
}
|
|
30
24
|
export default WebpackError;
|
package/dist/lib/WebpackError.js
CHANGED
|
@@ -12,14 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.WebpackError = void 0;
|
|
13
13
|
const node_util_1 = require("node:util");
|
|
14
14
|
class WebpackError extends Error {
|
|
15
|
-
/**
|
|
16
|
-
* Creates an instance of WebpackError.
|
|
17
|
-
* @param message error message
|
|
18
|
-
* @returns
|
|
19
|
-
*/
|
|
20
|
-
constructor(message) {
|
|
21
|
-
super(message);
|
|
22
|
-
}
|
|
23
15
|
[node_util_1.inspect.custom]() {
|
|
24
16
|
return this.stack + (this.details ? `\n${this.details}` : "");
|
|
25
17
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Cache_1 = require("../Cache");
|
|
4
|
+
class MemoryCachePlugin {
|
|
5
|
+
apply(compiler) {
|
|
6
|
+
const cache = new Map();
|
|
7
|
+
compiler.cache.hooks.store.tap({ name: MemoryCachePlugin.PLUGIN_NAME, stage: Cache_1.Cache.STAGE_MEMORY }, (identifier, etag, data) => {
|
|
8
|
+
const dataEtag = typeof etag?.toString === "function"
|
|
9
|
+
? etag.toString()
|
|
10
|
+
: etag;
|
|
11
|
+
cache.set(identifier, { etag: dataEtag, data });
|
|
12
|
+
});
|
|
13
|
+
compiler.cache.hooks.get.tap({ name: MemoryCachePlugin.PLUGIN_NAME, stage: Cache_1.Cache.STAGE_MEMORY }, (identifier, etag, gotHandlers) => {
|
|
14
|
+
const cacheEntry = cache.get(identifier);
|
|
15
|
+
const dataEtag = typeof etag?.toString === "function"
|
|
16
|
+
? etag.toString()
|
|
17
|
+
: etag;
|
|
18
|
+
if (cacheEntry === null) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
if (cacheEntry !== undefined) {
|
|
22
|
+
return cacheEntry.etag === dataEtag ? cacheEntry.data : null;
|
|
23
|
+
}
|
|
24
|
+
gotHandlers.push((result, callback) => {
|
|
25
|
+
if (result === undefined) {
|
|
26
|
+
cache.set(identifier, null);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
cache.set(identifier, { etag: dataEtag, data: result });
|
|
30
|
+
}
|
|
31
|
+
return callback(null);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
compiler.cache.hooks.shutdown.tap({ name: MemoryCachePlugin.PLUGIN_NAME, stage: Cache_1.Cache.STAGE_MEMORY }, () => {
|
|
35
|
+
cache.clear();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
MemoryCachePlugin.PLUGIN_NAME = "MemoryCachePlugin";
|
|
40
|
+
exports.default = MemoryCachePlugin;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Copyright (c) JS Foundation and other contributors
|
|
8
8
|
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
9
9
|
*/
|
|
10
|
-
type DependencyLocation
|
|
10
|
+
import type { DependencyLocation } from "./Dependency";
|
|
11
11
|
/**
|
|
12
12
|
* @param loc location
|
|
13
13
|
* @returns formatted location
|
|
@@ -40,7 +40,7 @@ const identifier_1 = require("../util/identifier");
|
|
|
40
40
|
const memoize_1 = require("../util/memoize");
|
|
41
41
|
const loadLoader_1 = __importDefault(require("./loadLoader"));
|
|
42
42
|
function createLoaderObject(loader, compiler) {
|
|
43
|
-
|
|
43
|
+
const obj = {
|
|
44
44
|
path: null,
|
|
45
45
|
query: null,
|
|
46
46
|
fragment: null,
|
|
@@ -88,13 +88,13 @@ function createLoaderObject(loader, compiler) {
|
|
|
88
88
|
else if (obj.options === undefined)
|
|
89
89
|
obj.query = "";
|
|
90
90
|
else if (typeof obj.options === "string")
|
|
91
|
-
obj.query =
|
|
91
|
+
obj.query = `?${obj.options}`;
|
|
92
92
|
else if (obj.ident)
|
|
93
|
-
obj.query =
|
|
93
|
+
obj.query = `??${obj.ident}`;
|
|
94
94
|
else if (typeof obj.options === "object" && obj.options.ident)
|
|
95
|
-
obj.query =
|
|
95
|
+
obj.query = `??${obj.options.ident}`;
|
|
96
96
|
else
|
|
97
|
-
obj.query =
|
|
97
|
+
obj.query = `?${JSON.stringify(obj.options)}`;
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
obj.request = loader;
|
|
@@ -268,8 +268,7 @@ function dirname(path) {
|
|
|
268
268
|
return path.slice(0, idx);
|
|
269
269
|
}
|
|
270
270
|
function getCurrentLoader(loaderContext, index = loaderContext.loaderIndex) {
|
|
271
|
-
if (loaderContext.loaders &&
|
|
272
|
-
loaderContext.loaders.length &&
|
|
271
|
+
if (loaderContext.loaders?.length &&
|
|
273
272
|
index < loaderContext.loaders.length &&
|
|
274
273
|
index >= 0 &&
|
|
275
274
|
loaderContext.loaders[index]) {
|
|
@@ -13,14 +13,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const LoaderLoadingError_1 = __importDefault(require("./LoaderLoadingError"));
|
|
16
|
-
|
|
16
|
+
let url = undefined;
|
|
17
17
|
function loadLoader(loader, callback) {
|
|
18
18
|
if (loader.type === "module") {
|
|
19
19
|
try {
|
|
20
20
|
if (url === undefined)
|
|
21
21
|
url = require("node:url");
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const loaderUrl = url.pathToFileURL(loader.path);
|
|
23
|
+
const modulePromise = eval(`import(${JSON.stringify(loaderUrl.toString())})`);
|
|
24
24
|
modulePromise.then((module) => {
|
|
25
25
|
handleResult(loader, module, callback);
|
|
26
26
|
}, callback);
|
|
@@ -31,15 +31,16 @@ function loadLoader(loader, callback) {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
34
|
+
let module;
|
|
34
35
|
try {
|
|
35
|
-
|
|
36
|
+
module = require(loader.path);
|
|
36
37
|
}
|
|
37
38
|
catch (e) {
|
|
38
39
|
// it is possible for node to choke on a require if the FD descriptor
|
|
39
40
|
// limit has been reached. give it a chance to recover.
|
|
40
41
|
if (e instanceof Error &&
|
|
41
42
|
e.code === "EMFILE") {
|
|
42
|
-
|
|
43
|
+
const retry = loadLoader.bind(null, loader, callback);
|
|
43
44
|
if (typeof setImmediate === "function") {
|
|
44
45
|
// node >= 0.9.0
|
|
45
46
|
return void setImmediate(retry);
|
|
@@ -55,18 +56,14 @@ function loadLoader(loader, callback) {
|
|
|
55
56
|
exports.default = loadLoader;
|
|
56
57
|
function handleResult(loader, module, callback) {
|
|
57
58
|
if (typeof module !== "function" && typeof module !== "object") {
|
|
58
|
-
return callback(new LoaderLoadingError_1.default(
|
|
59
|
-
loader.path +
|
|
60
|
-
"' is not a loader (export function or es6 module)"));
|
|
59
|
+
return callback(new LoaderLoadingError_1.default(`Module '${loader.path}' is not a loader (export function or es6 module)`));
|
|
61
60
|
}
|
|
62
61
|
loader.normal = typeof module === "function" ? module : module.default;
|
|
63
62
|
loader.pitch = module.pitch;
|
|
64
63
|
loader.raw = module.raw;
|
|
65
64
|
if (typeof loader.normal !== "function" &&
|
|
66
65
|
typeof loader.pitch !== "function") {
|
|
67
|
-
return callback(new LoaderLoadingError_1.default(
|
|
68
|
-
loader.path +
|
|
69
|
-
"' is not a loader (must have normal or pitch function)"));
|
|
66
|
+
return callback(new LoaderLoadingError_1.default(`Module '${loader.path}' is not a loader (must have normal or pitch function)`));
|
|
70
67
|
}
|
|
71
68
|
callback();
|
|
72
69
|
}
|
package/dist/logging/Logger.js
CHANGED
|
@@ -92,7 +92,7 @@ class Logger {
|
|
|
92
92
|
this[TIMERS_SYMBOL].set(label, process.hrtime());
|
|
93
93
|
}
|
|
94
94
|
timeLog(label) {
|
|
95
|
-
const prev = this[TIMERS_SYMBOL]
|
|
95
|
+
const prev = this[TIMERS_SYMBOL]?.get(label);
|
|
96
96
|
if (!prev) {
|
|
97
97
|
throw new Error(`No such label '${label}' for WebpackLogger.timeLog()`);
|
|
98
98
|
}
|
|
@@ -100,7 +100,7 @@ class Logger {
|
|
|
100
100
|
this[LOG_SYMBOL](exports.LogType.time, [label, ...time]);
|
|
101
101
|
}
|
|
102
102
|
timeEnd(label) {
|
|
103
|
-
const prev = this[TIMERS_SYMBOL]
|
|
103
|
+
const prev = this[TIMERS_SYMBOL]?.get(label);
|
|
104
104
|
if (!prev) {
|
|
105
105
|
throw new Error(`No such label '${label}' for WebpackLogger.timeEnd()`);
|
|
106
106
|
}
|
|
@@ -109,7 +109,7 @@ class Logger {
|
|
|
109
109
|
this[LOG_SYMBOL](exports.LogType.time, [label, ...time]);
|
|
110
110
|
}
|
|
111
111
|
timeAggregate(label) {
|
|
112
|
-
const prev = this[TIMERS_SYMBOL]
|
|
112
|
+
const prev = this[TIMERS_SYMBOL]?.get(label);
|
|
113
113
|
if (!prev) {
|
|
114
114
|
throw new Error(`No such label '${label}' for WebpackLogger.timeAggregate()`);
|
|
115
115
|
}
|
|
@@ -7,9 +7,29 @@
|
|
|
7
7
|
* Copyright (c) JS Foundation and other contributors
|
|
8
8
|
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
import type { FilterTypes } from "../config";
|
|
11
|
+
import { type LogTypeEnum } from "./Logger";
|
|
12
|
+
export type FilterFunction = (ident: string) => boolean;
|
|
13
|
+
export type LoggerConsole = {
|
|
14
|
+
clear: () => void;
|
|
15
|
+
trace: () => void;
|
|
16
|
+
info: (...args: any[]) => void;
|
|
17
|
+
log: (...args: any[]) => void;
|
|
18
|
+
warn: (...args: any[]) => void;
|
|
19
|
+
error: (...args: any[]) => void;
|
|
20
|
+
debug?: (...args: any[]) => void;
|
|
21
|
+
group?: (...args: any[]) => void;
|
|
22
|
+
groupCollapsed?: (...args: any[]) => void;
|
|
23
|
+
groupEnd?: (...args: any[]) => void;
|
|
24
|
+
status?: (...args: any[]) => void;
|
|
25
|
+
profile?: (...args: any[]) => void;
|
|
26
|
+
profileEnd?: (...args: any[]) => void;
|
|
27
|
+
logTime?: (...args: any[]) => void;
|
|
28
|
+
};
|
|
29
|
+
export type LoggerOptions = {
|
|
30
|
+
level: "none" | "error" | "warn" | "info" | "log" | "verbose" | boolean;
|
|
31
|
+
debug: FilterTypes | boolean;
|
|
32
|
+
console: LoggerConsole;
|
|
33
|
+
};
|
|
34
|
+
declare const createConsoleLogger: ({ level, debug, console }: LoggerOptions) => (name: string, type: LogTypeEnum, args: any[]) => void;
|
|
35
|
+
export { createConsoleLogger };
|
|
@@ -8,38 +8,10 @@
|
|
|
8
8
|
* Copyright (c) JS Foundation and other contributors
|
|
9
9
|
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @typedef {Object} LoggerConsole
|
|
17
|
-
* @property {function(): void} clear
|
|
18
|
-
* @property {function(): void} trace
|
|
19
|
-
* @property {(...args: any[]) => void} info
|
|
20
|
-
* @property {(...args: any[]) => void} log
|
|
21
|
-
* @property {(...args: any[]) => void} warn
|
|
22
|
-
* @property {(...args: any[]) => void} error
|
|
23
|
-
* @property {(...args: any[]) => void=} debug
|
|
24
|
-
* @property {(...args: any[]) => void=} group
|
|
25
|
-
* @property {(...args: any[]) => void=} groupCollapsed
|
|
26
|
-
* @property {(...args: any[]) => void=} groupEnd
|
|
27
|
-
* @property {(...args: any[]) => void=} status
|
|
28
|
-
* @property {(...args: any[]) => void=} profile
|
|
29
|
-
* @property {(...args: any[]) => void=} profileEnd
|
|
30
|
-
* @property {(...args: any[]) => void=} logTime
|
|
31
|
-
*/
|
|
32
|
-
/**
|
|
33
|
-
* @typedef {Object} LoggerOptions
|
|
34
|
-
* @property {false|true|"none"|"error"|"warn"|"info"|"log"|"verbose"} level loglevel
|
|
35
|
-
* @property {FilterTypes|boolean} debug filter for debug logging
|
|
36
|
-
* @property {LoggerConsole} console the console to log to
|
|
37
|
-
*/
|
|
38
|
-
/**
|
|
39
|
-
* @param {FilterItemTypes} item an input item
|
|
40
|
-
* @returns {FilterFunction} filter function
|
|
41
|
-
*/
|
|
42
|
-
const filterToFunction = item => {
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createConsoleLogger = void 0;
|
|
13
|
+
const Logger_1 = require("./Logger");
|
|
14
|
+
const filterToFunction = (item) => {
|
|
43
15
|
if (typeof item === "string") {
|
|
44
16
|
const regExp = new RegExp(`[\\\\/]${item.replace(
|
|
45
17
|
// eslint-disable-next-line no-useless-escape
|
|
@@ -56,9 +28,6 @@ const filterToFunction = item => {
|
|
|
56
28
|
return () => item;
|
|
57
29
|
}
|
|
58
30
|
};
|
|
59
|
-
/**
|
|
60
|
-
* @enum {number}
|
|
61
|
-
*/
|
|
62
31
|
const LogLevel = {
|
|
63
32
|
none: 6,
|
|
64
33
|
false: 6,
|
|
@@ -69,18 +38,11 @@ const LogLevel = {
|
|
|
69
38
|
true: 2,
|
|
70
39
|
verbose: 1
|
|
71
40
|
};
|
|
72
|
-
|
|
41
|
+
const createConsoleLogger = ({ level = "info", debug = false, console }) => {
|
|
73
42
|
const debugFilters = typeof debug === "boolean"
|
|
74
43
|
? [() => debug]
|
|
75
|
-
:
|
|
76
|
-
/** @type {number} */
|
|
44
|
+
: [].concat(debug).map(filterToFunction);
|
|
77
45
|
const loglevel = LogLevel[`${level}`] || 0;
|
|
78
|
-
/**
|
|
79
|
-
* @param {string} name name of the logger
|
|
80
|
-
* @param {LogTypeEnum} type type of the log entry
|
|
81
|
-
* @param {any[]} args arguments of the log entry
|
|
82
|
-
* @returns {void}
|
|
83
|
-
*/
|
|
84
46
|
const logger = (name, type, args) => {
|
|
85
47
|
const labeledArgs = () => {
|
|
86
48
|
if (Array.isArray(args)) {
|
|
@@ -93,7 +55,7 @@ module.exports = ({ level = "info", debug = false, console }) => {
|
|
|
93
55
|
};
|
|
94
56
|
const debug = debugFilters.some(f => f(name));
|
|
95
57
|
switch (type) {
|
|
96
|
-
case LogType.debug:
|
|
58
|
+
case Logger_1.LogType.debug:
|
|
97
59
|
if (!debug)
|
|
98
60
|
return;
|
|
99
61
|
if (typeof console.debug === "function") {
|
|
@@ -103,32 +65,32 @@ module.exports = ({ level = "info", debug = false, console }) => {
|
|
|
103
65
|
console.log(...labeledArgs());
|
|
104
66
|
}
|
|
105
67
|
break;
|
|
106
|
-
case LogType.log:
|
|
68
|
+
case Logger_1.LogType.log:
|
|
107
69
|
if (!debug && loglevel > LogLevel.log)
|
|
108
70
|
return;
|
|
109
71
|
console.log(...labeledArgs());
|
|
110
72
|
break;
|
|
111
|
-
case LogType.info:
|
|
73
|
+
case Logger_1.LogType.info:
|
|
112
74
|
if (!debug && loglevel > LogLevel.info)
|
|
113
75
|
return;
|
|
114
76
|
console.info(...labeledArgs());
|
|
115
77
|
break;
|
|
116
|
-
case LogType.warn:
|
|
78
|
+
case Logger_1.LogType.warn:
|
|
117
79
|
if (!debug && loglevel > LogLevel.warn)
|
|
118
80
|
return;
|
|
119
81
|
console.warn(...labeledArgs());
|
|
120
82
|
break;
|
|
121
|
-
case LogType.error:
|
|
83
|
+
case Logger_1.LogType.error:
|
|
122
84
|
if (!debug && loglevel > LogLevel.error)
|
|
123
85
|
return;
|
|
124
86
|
console.error(...labeledArgs());
|
|
125
87
|
break;
|
|
126
|
-
case LogType.trace:
|
|
88
|
+
case Logger_1.LogType.trace:
|
|
127
89
|
if (!debug)
|
|
128
90
|
return;
|
|
129
91
|
console.trace();
|
|
130
92
|
break;
|
|
131
|
-
case LogType.groupCollapsed:
|
|
93
|
+
case Logger_1.LogType.groupCollapsed:
|
|
132
94
|
if (!debug && loglevel > LogLevel.log)
|
|
133
95
|
return;
|
|
134
96
|
if (!debug && loglevel > LogLevel.verbose) {
|
|
@@ -141,7 +103,7 @@ module.exports = ({ level = "info", debug = false, console }) => {
|
|
|
141
103
|
break;
|
|
142
104
|
}
|
|
143
105
|
// falls through
|
|
144
|
-
case LogType.group:
|
|
106
|
+
case Logger_1.LogType.group:
|
|
145
107
|
if (!debug && loglevel > LogLevel.log)
|
|
146
108
|
return;
|
|
147
109
|
if (typeof console.group === "function") {
|
|
@@ -151,14 +113,14 @@ module.exports = ({ level = "info", debug = false, console }) => {
|
|
|
151
113
|
console.log(...labeledArgs());
|
|
152
114
|
}
|
|
153
115
|
break;
|
|
154
|
-
case LogType.groupEnd:
|
|
116
|
+
case Logger_1.LogType.groupEnd:
|
|
155
117
|
if (!debug && loglevel > LogLevel.log)
|
|
156
118
|
return;
|
|
157
119
|
if (typeof console.groupEnd === "function") {
|
|
158
120
|
console.groupEnd();
|
|
159
121
|
}
|
|
160
122
|
break;
|
|
161
|
-
case LogType.time: {
|
|
123
|
+
case Logger_1.LogType.time: {
|
|
162
124
|
if (!debug && loglevel > LogLevel.log)
|
|
163
125
|
return;
|
|
164
126
|
const ms = args[1] * 1000 + args[2] / 1000000;
|
|
@@ -171,24 +133,24 @@ module.exports = ({ level = "info", debug = false, console }) => {
|
|
|
171
133
|
}
|
|
172
134
|
break;
|
|
173
135
|
}
|
|
174
|
-
case LogType.profile:
|
|
136
|
+
case Logger_1.LogType.profile:
|
|
175
137
|
if (typeof console.profile === "function") {
|
|
176
138
|
console.profile(...labeledArgs());
|
|
177
139
|
}
|
|
178
140
|
break;
|
|
179
|
-
case LogType.profileEnd:
|
|
141
|
+
case Logger_1.LogType.profileEnd:
|
|
180
142
|
if (typeof console.profileEnd === "function") {
|
|
181
143
|
console.profileEnd(...labeledArgs());
|
|
182
144
|
}
|
|
183
145
|
break;
|
|
184
|
-
case LogType.clear:
|
|
146
|
+
case Logger_1.LogType.clear:
|
|
185
147
|
if (!debug && loglevel > LogLevel.log)
|
|
186
148
|
return;
|
|
187
149
|
if (typeof console.clear === "function") {
|
|
188
150
|
console.clear();
|
|
189
151
|
}
|
|
190
152
|
break;
|
|
191
|
-
case LogType.status:
|
|
153
|
+
case Logger_1.LogType.status:
|
|
192
154
|
if (!debug && loglevel > LogLevel.info)
|
|
193
155
|
return;
|
|
194
156
|
if (typeof console.status === "function") {
|
|
@@ -211,3 +173,4 @@ module.exports = ({ level = "info", debug = false, console }) => {
|
|
|
211
173
|
};
|
|
212
174
|
return logger;
|
|
213
175
|
};
|
|
176
|
+
exports.createConsoleLogger = createConsoleLogger;
|
|
@@ -7,16 +7,10 @@
|
|
|
7
7
|
* Copyright (c) JS Foundation and other contributors
|
|
8
8
|
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export declare const getLogger: (name: any) => any;
|
|
15
|
-
/**
|
|
16
|
-
* @param {createConsoleLogger.LoggerOptions} options new options, merge with old options
|
|
17
|
-
* @returns {void}
|
|
18
|
-
*/
|
|
19
|
-
export declare const configureDefaultLogger: (options: any) => void;
|
|
10
|
+
import { Logger } from "./Logger";
|
|
11
|
+
import { type LoggerOptions } from "./createConsoleLogger";
|
|
12
|
+
export declare const getLogger: (name: string) => Logger;
|
|
13
|
+
export declare const configureDefaultLogger: (options: LoggerOptions) => void;
|
|
20
14
|
export declare const hooks: {
|
|
21
15
|
log: any;
|
|
22
16
|
};
|