@rspack/core
Advanced tools
Comparing version 1.0.0-beta.1 to 1.0.0-beta.2
@@ -144,3 +144,3 @@ "use strict"; | ||
.map(v => Number.parseInt(v, 10)); | ||
if (isNaN(major) || isNaN(minor) || isNaN(patch)) { | ||
if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch)) { | ||
return null; | ||
@@ -147,0 +147,0 @@ } |
@@ -10,6 +10,4 @@ "use strict"; | ||
let timeout = 0; | ||
return function () { | ||
// @ts-ignore | ||
return function (...args) { | ||
const self = this; | ||
const args = arguments; | ||
const functionCall = function functionCall() { | ||
@@ -38,3 +36,3 @@ return fn.apply(self, args); | ||
} | ||
return function (fileMap) { | ||
return (fileMap) => { | ||
if (!src) { | ||
@@ -44,3 +42,3 @@ return null; | ||
const splitResult = src.split(/([^\\/]+)\.js$/); | ||
const filename = splitResult && splitResult[1]; | ||
const filename = splitResult?.[1]; | ||
if (!filename) { | ||
@@ -47,0 +45,0 @@ return [src.replace(".js", ".css")]; |
@@ -9,8 +9,10 @@ "use strict"; | ||
} | ||
var protocol = urlString.indexOf("//") !== -1 ? urlString.split("//")[0] + "//" : ""; | ||
var components = urlString.replace(new RegExp(protocol, "i"), "").split("/"); | ||
var host = components[0].toLowerCase().replace(/\.$/, ""); | ||
const protocol = urlString.indexOf("//") !== -1 ? `${urlString.split("//")[0]}//` : ""; | ||
const components = urlString | ||
.replace(new RegExp(protocol, "i"), "") | ||
.split("/"); | ||
const host = components[0].toLowerCase().replace(/\.$/, ""); | ||
components[0] = ""; | ||
var path = components | ||
.reduce(function (accumulator, item) { | ||
const path = components | ||
.reduce((accumulator, item) => { | ||
switch (item) { | ||
@@ -17,0 +19,0 @@ case "..": |
@@ -14,3 +14,3 @@ "use strict"; | ||
exports.AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__"; | ||
exports.ABSOLUTE_PUBLIC_PATH = exports.BASE_URI + "/mini-css-extract-plugin/"; | ||
exports.ABSOLUTE_PUBLIC_PATH = `${exports.BASE_URI}/mini-css-extract-plugin/`; | ||
exports.SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__"; | ||
@@ -46,6 +46,3 @@ const SERIALIZE_SEP = "__RSPACK_CSS_EXTRACT_SEP__"; | ||
const loader = function loader(content) { | ||
if (this._compiler && | ||
this._compiler.options && | ||
this._compiler.options.experiments && | ||
this._compiler.options.experiments.css && | ||
if (this._compiler?.options?.experiments?.css && | ||
this._module && | ||
@@ -60,6 +57,3 @@ (this._module.type === "css" || | ||
const pitch = function (request, _, data) { | ||
if (this._compiler && | ||
this._compiler.options && | ||
this._compiler.options.experiments && | ||
this._compiler.options.experiments.css && | ||
if (this._compiler?.options?.experiments?.css && | ||
this._module && | ||
@@ -128,3 +122,3 @@ (this._module.type === "css" || | ||
else { | ||
locals = exports && exports.locals; | ||
locals = exports?.locals; | ||
} | ||
@@ -131,0 +125,0 @@ if (Array.isArray(exports) && emit) { |
@@ -22,3 +22,3 @@ "use strict"; | ||
if (typeof p === "function") { | ||
return "(" + p.toString() + ")"; | ||
return `(${p.toString()})`; | ||
} | ||
@@ -25,0 +25,0 @@ if (typeof p === "bigint") { |
import { BuiltinPluginName } from "@rspack/binding"; | ||
export declare const EnableChunkLoadingPlugin: { | ||
new (type: any): { | ||
new (type: string): { | ||
name: BuiltinPluginName; | ||
_args: [type: any]; | ||
_args: [type: string]; | ||
affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; | ||
@@ -7,0 +7,0 @@ raw(compiler: import("../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin; |
@@ -6,2 +6,2 @@ "use strict"; | ||
const base_1 = require("./base"); | ||
exports.EnableChunkLoadingPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.EnableChunkLoadingPlugin, type => type); | ||
exports.EnableChunkLoadingPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.EnableChunkLoadingPlugin, (type) => type); |
@@ -26,8 +26,3 @@ "use strict"; | ||
if (!getEnabledTypes(compiler).has(type)) { | ||
throw new Error(`Library type "${type}" is not enabled. ` + | ||
"EnableLibraryPlugin need to be used to enable this type of library. " + | ||
'This usually happens through the "output.enabledLibraryTypes" option. ' + | ||
'If you are using a function as entry which sets "library", you need to add all potential library types to "output.enabledLibraryTypes". ' + | ||
"These types are enabled: " + | ||
Array.from(getEnabledTypes(compiler)).join(", ")); | ||
throw new Error(`Library type "${type}" is not enabled. EnableLibraryPlugin need to be used to enable this type of library. This usually happens through the "output.enabledLibraryTypes" option. If you are using a function as entry which sets "library", you need to add all potential library types to "output.enabledLibraryTypes". These types are enabled: ${Array.from(getEnabledTypes(compiler)).join(", ")}`); | ||
} | ||
@@ -34,0 +29,0 @@ } |
import { BuiltinPluginName } from "@rspack/binding"; | ||
export declare const EnableWasmLoadingPlugin: { | ||
new (type: any): { | ||
new (type: string): { | ||
name: BuiltinPluginName; | ||
_args: [type: any]; | ||
_args: [type: string]; | ||
affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; | ||
@@ -7,0 +7,0 @@ raw(compiler: import("../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin; |
@@ -6,2 +6,2 @@ "use strict"; | ||
const base_1 = require("./base"); | ||
exports.EnableWasmLoadingPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.EnableWasmLoadingPlugin, type => type); | ||
exports.EnableWasmLoadingPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.EnableWasmLoadingPlugin, (type) => type); |
@@ -29,3 +29,3 @@ "use strict"; | ||
}); | ||
if (promise && promise.then) { | ||
if (promise?.then) { | ||
promise.then(result => resolve({ | ||
@@ -32,0 +32,0 @@ result: getRawExternalItemValueFormFnResult(result), |
@@ -13,5 +13,4 @@ import { type BuiltinPlugin, BuiltinPluginName } from "@rspack/binding"; | ||
affectedHooks: "compilation"; | ||
constructor(); | ||
raw(): BuiltinPlugin; | ||
static getCompilationHooks(compilation: Compilation): CompilationHooks; | ||
} |
@@ -34,3 +34,3 @@ "use strict"; | ||
constructor() { | ||
super(); | ||
super(...arguments); | ||
this.name = binding_1.BuiltinPluginName.JavascriptModulesPlugin; | ||
@@ -37,0 +37,0 @@ this.affectedHooks = "compilation"; |
@@ -0,6 +1,6 @@ | ||
"use strict"; | ||
/* | ||
MIT License http://www.opensource.org/licenses/mit-license.php | ||
Author Tobias Koppers @sokra | ||
*/ | ||
"use strict"; | ||
* MIT License http://www.opensource.org/licenses/mit-license.php | ||
* Author Tobias Koppers @sokra | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -7,0 +7,0 @@ exports.moduleImpl = exports.dispose = void 0; |
@@ -201,4 +201,3 @@ import { BuiltinPluginName } from "@rspack/binding"; | ||
} | ||
export interface TerserManglePropertiesOptions { | ||
} | ||
export type TerserManglePropertiesOptions = {}; | ||
export declare const SwcJsMinimizerRspackPlugin: { | ||
@@ -205,0 +204,0 @@ new (options?: SwcJsMinimizerRspackPluginOptions | undefined): { |
@@ -9,2 +9,3 @@ import { type JsChunkGroup, type JsCompilation } from "@rspack/binding"; | ||
getParents(): ReadonlyArray<ChunkGroup>; | ||
isInitial(): boolean; | ||
get chunks(): ReadonlyArray<Chunk>; | ||
@@ -11,0 +12,0 @@ get index(): Readonly<number | undefined>; |
@@ -43,2 +43,5 @@ "use strict"; | ||
} | ||
isInitial() { | ||
return __classPrivateFieldGet(this, _ChunkGroup_inner, "f").isInitial; | ||
} | ||
get chunks() { | ||
@@ -45,0 +48,0 @@ return __classPrivateFieldGet(this, _ChunkGroup_inner, "f").chunks.map(c => Chunk_1.Chunk.__from_binding(c, __classPrivateFieldGet(this, _ChunkGroup_innerCompilation, "f"))); |
@@ -105,2 +105,20 @@ /** | ||
loggingTrace: boolean; | ||
chunkModules: boolean; | ||
chunkRelations: boolean; | ||
reasons: boolean; | ||
moduleAssets: boolean; | ||
nestedModules: boolean; | ||
source: boolean; | ||
usedExports: boolean; | ||
providedExports: boolean; | ||
optimizationBailout: boolean; | ||
depth: boolean; | ||
assets: boolean; | ||
chunks: boolean; | ||
errors: boolean; | ||
errorsCount: boolean; | ||
hash: boolean; | ||
modules: boolean; | ||
warnings: boolean; | ||
warningsCount: boolean; | ||
} | ||
@@ -107,0 +125,0 @@ export type CreateStatsOptionsContext = KnownCreateStatsOptionsContext & Record<string, any>; |
@@ -371,3 +371,3 @@ "use strict"; | ||
purgeInputFileSystem() { | ||
if (this.inputFileSystem && this.inputFileSystem.purge) { | ||
if (this.inputFileSystem?.purge) { | ||
this.inputFileSystem.purge(); | ||
@@ -618,3 +618,3 @@ } | ||
} | ||
var execOptions = { | ||
const execOptions = { | ||
id, | ||
@@ -621,0 +621,0 @@ module: { |
@@ -132,2 +132,3 @@ "use strict"; | ||
cssChunkFilename: output.cssChunkFilename, | ||
cssHeadDataCompression: output.cssHeadDataCompression, | ||
hotUpdateChunkFilename: output.hotUpdateChunkFilename, | ||
@@ -134,0 +135,0 @@ hotUpdateMainFilename: output.hotUpdateMainFilename, |
@@ -105,8 +105,4 @@ /// <reference types="node" /> | ||
} | ||
export interface LoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> { | ||
(this: LoaderContext<OptionsType> & ContextAdditions, content: string, sourceMap?: string | SourceMap, additionalData?: AdditionalData): string | void | Buffer | Promise<string | Buffer>; | ||
} | ||
export interface PitchLoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> { | ||
(this: LoaderContext<OptionsType> & ContextAdditions, remainingRequest: string, previousRequest: string, data: object): string | void | Buffer | Promise<string | Buffer>; | ||
} | ||
export type LoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> = (this: LoaderContext<OptionsType> & ContextAdditions, content: string, sourceMap?: string | SourceMap, additionalData?: AdditionalData) => string | void | Buffer | Promise<string | Buffer>; | ||
export type PitchLoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> = (this: LoaderContext<OptionsType> & ContextAdditions, remainingRequest: string, previousRequest: string, data: object) => string | void | Buffer | Promise<string | Buffer>; | ||
export type LoaderDefinition<OptionsType = {}, ContextAdditions = {}> = LoaderDefinitionFunction<OptionsType, ContextAdditions> & { | ||
@@ -113,0 +109,0 @@ raw?: false; |
@@ -58,3 +58,4 @@ "use strict"; | ||
return uses.map((use, index) => { | ||
let o, isBuiltin = false; | ||
let o; | ||
let isBuiltin = false; | ||
if (use.loader.startsWith(exports.BUILTIN_LOADER_PREFIX)) { | ||
@@ -79,11 +80,11 @@ o = getBuiltinLoaderOptions(use.loader, use.options, options); | ||
else if (typeof use.options === "string") | ||
obj.query = "?" + use.options; | ||
obj.query = `?${use.options}`; | ||
else if (use.ident) | ||
obj.query = "??" + (ident = use.ident); | ||
obj.query = `??${(ident = use.ident)}`; | ||
else if (typeof use.options === "object" && use.options.ident) | ||
obj.query = "??" + (ident = use.options.ident); | ||
obj.query = `??${(ident = use.options.ident)}`; | ||
else if (typeof use.options === "object") | ||
obj.query = "??" + (ident = path); | ||
obj.query = `??${(ident = path)}`; | ||
else | ||
obj.query = "?" + JSON.stringify(use.options); | ||
obj.query = `?${JSON.stringify(use.options)}`; | ||
if (use.options && typeof use.options === "object") { | ||
@@ -90,0 +91,0 @@ if (!ident) |
@@ -406,4 +406,5 @@ "use strict"; | ||
const uniqueNameId = Template_1.Template.toIdentifier(output.uniqueName); | ||
F(output, "hotUpdateGlobal", () => "webpackHotUpdate" + uniqueNameId); | ||
F(output, "chunkLoadingGlobal", () => "webpackChunk" + uniqueNameId); | ||
F(output, "hotUpdateGlobal", () => `webpackHotUpdate${uniqueNameId}`); | ||
F(output, "chunkLoadingGlobal", () => `webpackChunk${uniqueNameId}`); | ||
D(output, "cssHeadDataCompression", !development); | ||
D(output, "assetModuleFilename", "[hash][ext][query]"); | ||
@@ -431,6 +432,3 @@ D(output, "webassemblyModuleFilename", "[hash].module.wasm"); | ||
return "array-push"; | ||
throw new Error("For the selected environment is no default ESM chunk format available:\n" + | ||
"ESM exports can be chosen when 'import()' is available.\n" + | ||
"JSONP Array push can be chosen when 'document' is available.\n" + | ||
helpMessage); | ||
throw new Error(`For the selected environment is no default ESM chunk format available:\nESM exports can be chosen when 'import()' is available.\nJSONP Array push can be chosen when 'document' is available.\n${helpMessage}`); | ||
} | ||
@@ -445,6 +443,3 @@ if (tp.document) | ||
return "array-push"; | ||
throw new Error("For the selected environment is no default script chunk format available:\n" + | ||
"JSONP Array push can be chosen when 'document' or 'importScripts' is available.\n" + | ||
"CommonJs exports can be chosen when 'require' or node builtins are available.\n" + | ||
helpMessage); | ||
throw new Error(`For the selected environment is no default script chunk format available:\nJSONP Array push can be chosen when 'document' or 'importScripts' is available.\nCommonJs exports can be chosen when 'require' or node builtins are available.\n${helpMessage}`); | ||
} | ||
@@ -598,4 +593,4 @@ throw new Error("Chunk format can't be selected by default when no target is specified"); | ||
const conditionallyOptimistic = (v, c) => (v === undefined && c) || v; | ||
F(environment, "globalThis", () => tp && tp.globalThis); | ||
F(environment, "bigIntLiteral", () => tp && tp.bigIntLiteral); | ||
F(environment, "globalThis", () => tp?.globalThis); | ||
F(environment, "bigIntLiteral", () => tp?.bigIntLiteral); | ||
F(environment, "const", () => tp && optimistic(tp.const)); | ||
@@ -609,21 +604,15 @@ F(environment, "arrowFunction", () => tp && optimistic(tp.arrowFunction)); | ||
F(environment, "templateLiteral", () => tp && optimistic(tp.templateLiteral)); | ||
F(environment, "dynamicImport", () => conditionallyOptimistic(tp && tp.dynamicImport, output.module)); | ||
F(environment, "dynamicImportInWorker", () => conditionallyOptimistic(tp && tp.dynamicImportInWorker, output.module)); | ||
F(environment, "module", () => conditionallyOptimistic(tp && tp.module, output.module)); | ||
F(environment, "dynamicImport", () => conditionallyOptimistic(tp?.dynamicImport, output.module)); | ||
F(environment, "dynamicImportInWorker", () => conditionallyOptimistic(tp?.dynamicImportInWorker, output.module)); | ||
F(environment, "module", () => conditionallyOptimistic(tp?.module, output.module)); | ||
F(environment, "document", () => tp && optimistic(tp.document)); | ||
}; | ||
const applyExternalsPresetsDefaults = (externalsPresets, { targetProperties }) => { | ||
D(externalsPresets, "web", targetProperties && targetProperties.web); | ||
D(externalsPresets, "node", targetProperties && targetProperties.node); | ||
D(externalsPresets, "electron", targetProperties && targetProperties.electron); | ||
D(externalsPresets, "electronMain", targetProperties && | ||
targetProperties.electron && | ||
targetProperties.electronMain); | ||
D(externalsPresets, "electronPreload", targetProperties && | ||
targetProperties.electron && | ||
targetProperties.electronPreload); | ||
D(externalsPresets, "electronRenderer", targetProperties && | ||
targetProperties.electron && | ||
targetProperties.electronRenderer); | ||
D(externalsPresets, "nwjs", targetProperties && targetProperties.nwjs); | ||
D(externalsPresets, "web", targetProperties?.web); | ||
D(externalsPresets, "node", targetProperties?.node); | ||
D(externalsPresets, "electron", targetProperties?.electron); | ||
D(externalsPresets, "electronMain", targetProperties?.electron && targetProperties.electronMain); | ||
D(externalsPresets, "electronPreload", targetProperties?.electron && targetProperties.electronPreload); | ||
D(externalsPresets, "electronRenderer", targetProperties?.electron && targetProperties.electronRenderer); | ||
D(externalsPresets, "nwjs", targetProperties?.nwjs); | ||
}; | ||
@@ -657,3 +646,3 @@ const applyLoaderDefaults = (loader, { targetProperties, environment }) => { | ||
F(node, "global", () => { | ||
if (targetProperties && targetProperties.global) | ||
if (targetProperties?.global) | ||
return false; | ||
@@ -664,3 +653,3 @@ return "warn"; | ||
F(node, "__dirname", () => { | ||
if (targetProperties && targetProperties.node) | ||
if (targetProperties?.node) | ||
return "eval-only"; | ||
@@ -671,3 +660,3 @@ return "warn-mock"; | ||
F(node, "__filename", () => { | ||
if (targetProperties && targetProperties.node) | ||
if (targetProperties?.node) | ||
return "eval-only"; | ||
@@ -783,3 +772,3 @@ return "warn-mock"; | ||
const tp = targetProperties; | ||
const browserField = tp && tp.web && (!tp.node || (tp.electron && tp.electronRenderer)); | ||
const browserField = tp?.web && (!tp.node || (tp.electron && tp.electronRenderer)); | ||
const aliasFields = browserField ? ["browser"] : []; | ||
@@ -786,0 +775,0 @@ const mainFields = browserField |
@@ -77,2 +77,3 @@ /** | ||
chunkLoadTimeout?: number; | ||
cssHeadDataCompression?: boolean; | ||
} | ||
@@ -79,0 +80,0 @@ export interface ModuleOptionsNormalized { |
@@ -57,2 +57,3 @@ "use strict"; | ||
crossOriginLoading: output.crossOriginLoading, | ||
cssHeadDataCompression: output.cssHeadDataCompression, | ||
cssFilename: output.cssFilename, | ||
@@ -286,4 +287,6 @@ cssChunkFilename: output.cssChunkFilename, | ||
? {} | ||
: Object.keys(value).reduce((obj, key) => ((obj[key] = (customKeys && key in customKeys ? customKeys[key] : fn)(value[key])), | ||
obj), {}); | ||
: Object.keys(value).reduce((obj, key) => { | ||
obj[key] = (customKeys && key in customKeys ? customKeys[key] : fn)(value[key]); | ||
return obj; | ||
}, {}); | ||
if (customKeys) { | ||
@@ -290,0 +293,0 @@ for (const key of Object.keys(customKeys)) { |
@@ -187,2 +187,3 @@ "use strict"; | ||
cssFilename: cssFilename.optional(), | ||
cssHeadDataCompression: zod_1.z.boolean().optional(), | ||
cssChunkFilename: cssChunkFilename.optional(), | ||
@@ -736,3 +737,5 @@ hotUpdateMainFilename: hotUpdateMainFilename.optional(), | ||
errorStack: zod_1.z.boolean().optional(), | ||
moduleTrace: zod_1.z.boolean().optional() | ||
moduleTrace: zod_1.z.boolean().optional(), | ||
cachedModules: zod_1.z.boolean().optional(), | ||
cached: zod_1.z.boolean().optional() | ||
}); | ||
@@ -856,3 +859,20 @@ const statsValue = zod_1.z.boolean().or(statsPresets).or(statsOptions); | ||
}); | ||
const listenOptions = zod_1.z.object({ | ||
port: zod_1.z.number().optional(), | ||
host: zod_1.z.string().optional(), | ||
backlog: zod_1.z.number().optional(), | ||
path: zod_1.z.string().optional(), | ||
exclusive: zod_1.z.boolean().optional(), | ||
readableAll: zod_1.z.boolean().optional(), | ||
writableAll: zod_1.z.boolean().optional(), | ||
ipv6Only: zod_1.z.boolean().optional() | ||
}); | ||
const lazyCompilationOptions = zod_1.z.object({ | ||
backend: zod_1.z | ||
.object({ | ||
client: zod_1.z.string().optional(), | ||
listen: zod_1.z.number().optional().or(listenOptions), | ||
protocol: zod_1.z.enum(["http", "https"]).optional() | ||
}) | ||
.optional(), | ||
imports: zod_1.z.boolean().optional(), | ||
@@ -859,0 +879,0 @@ entries: zod_1.z.boolean().optional(), |
@@ -1,1 +0,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})}}}; | ||
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})}}}; |
import type { Compiler } from "./Compiler"; | ||
export default class ExecuteModulePlugin { | ||
constructor(); | ||
apply(compiler: Compiler): void; | ||
} |
@@ -9,3 +9,2 @@ "use strict"; | ||
class ExecuteModulePlugin { | ||
constructor() { } | ||
apply(compiler) { | ||
@@ -12,0 +11,0 @@ compiler.hooks.compilation.tap("executeModule", compilation => { |
@@ -23,3 +23,3 @@ "use strict"; | ||
function createMessage(method) { | ||
return `Abstract method${method ? " " + method : ""}. Must be overridden.`; | ||
return `Abstract method${method ? ` ${method}` : ""}. Must be overridden.`; | ||
} | ||
@@ -32,4 +32,3 @@ class Message extends Error { | ||
const match = this.stack.split("\n")[3].match(CURRENT_METHOD_REGEXP); | ||
this.message = | ||
match && match[1] ? createMessage(match[1]) : createMessage(); | ||
this.message = match?.[1] ? createMessage(match[1]) : createMessage(); | ||
} | ||
@@ -36,0 +35,0 @@ } |
@@ -16,3 +16,3 @@ /** | ||
export type CallbackCache<T> = (err?: WebpackError | null, result?: T) => void; | ||
type GotHandler<T = any> = (result: any | null, callback: (error: Error) => void) => void; | ||
type GotHandler<T = any> = (result: any | null, callback: (error: Error | null) => void) => void; | ||
export declare class Cache { | ||
@@ -19,0 +19,0 @@ static STAGE_DISK: number; |
@@ -46,5 +46,3 @@ "use strict"; | ||
compiler.hooks.thisCompilation.tap("EnvironmentPlugin", compilation => { | ||
const error = new WebpackError_1.default(`EnvironmentPlugin - ${key} environment variable is undefined.\n\n` + | ||
"You can pass an object with default values to suppress this warning.\n" + | ||
"See https://webpack.js.org/plugins/environment-plugin for example."); | ||
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.`); | ||
error.name = "EnvVariableNotDefinedError"; | ||
@@ -51,0 +49,0 @@ compilation.errors.push(error); |
@@ -10,3 +10,3 @@ /** | ||
*/ | ||
type DependencyLocation = any; | ||
import type { DependencyLocation } from "./Dependency"; | ||
/** | ||
@@ -13,0 +13,0 @@ * @param loc location |
@@ -28,3 +28,3 @@ "use strict"; | ||
// adding a backslash before each special character | ||
return new RegExp("^" + test.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")); | ||
return new RegExp(`^${test.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")}`); | ||
} | ||
@@ -31,0 +31,0 @@ return test; |
@@ -22,10 +22,4 @@ /** | ||
hideStack?: boolean; | ||
/** | ||
* Creates an instance of WebpackError. | ||
* @param message error message | ||
* @returns | ||
*/ | ||
constructor(message?: string); | ||
[inspect.custom](): string; | ||
} | ||
export default WebpackError; |
@@ -15,10 +15,2 @@ "use strict"; | ||
class WebpackError extends Error { | ||
/** | ||
* Creates an instance of WebpackError. | ||
* @param message error message | ||
* @returns | ||
*/ | ||
constructor(message) { | ||
super(message); | ||
} | ||
[node_util_1.inspect.custom]() { | ||
@@ -25,0 +17,0 @@ return this.stack + (this.details ? `\n${this.details}` : ""); |
@@ -43,3 +43,3 @@ "use strict"; | ||
function createLoaderObject(loader, compiler) { | ||
var obj = { | ||
const obj = { | ||
path: null, | ||
@@ -92,9 +92,9 @@ query: null, | ||
else if (typeof obj.options === "string") | ||
obj.query = "?" + obj.options; | ||
obj.query = `?${obj.options}`; | ||
else if (obj.ident) | ||
obj.query = "??" + obj.ident; | ||
obj.query = `??${obj.ident}`; | ||
else if (typeof obj.options === "object" && obj.options.ident) | ||
obj.query = "??" + obj.options.ident; | ||
obj.query = `??${obj.options.ident}`; | ||
else | ||
obj.query = "?" + JSON.stringify(obj.options); | ||
obj.query = `?${JSON.stringify(obj.options)}`; | ||
} | ||
@@ -273,4 +273,3 @@ }); | ||
function getCurrentLoader(loaderContext, index = loaderContext.loaderIndex) { | ||
if (loaderContext.loaders && | ||
loaderContext.loaders.length && | ||
if (loaderContext.loaders?.length && | ||
index < loaderContext.loaders.length && | ||
@@ -277,0 +276,0 @@ index >= 0 && |
@@ -16,3 +16,3 @@ "use strict"; | ||
const LoaderLoadingError_1 = __importDefault(require("./LoaderLoadingError")); | ||
var url = undefined; | ||
let url = undefined; | ||
function loadLoader(loader, callback) { | ||
@@ -23,4 +23,4 @@ if (loader.type === "module") { | ||
url = require("node:url"); | ||
var loaderUrl = url.pathToFileURL(loader.path); | ||
var modulePromise = eval("import(" + JSON.stringify(loaderUrl.toString()) + ")"); | ||
const loaderUrl = url.pathToFileURL(loader.path); | ||
const modulePromise = eval(`import(${JSON.stringify(loaderUrl.toString())})`); | ||
modulePromise.then((module) => { | ||
@@ -36,4 +36,5 @@ handleResult(loader, module, callback); | ||
else { | ||
let module; | ||
try { | ||
var module = require(loader.path); | ||
module = require(loader.path); | ||
} | ||
@@ -45,3 +46,3 @@ catch (e) { | ||
e.code === "EMFILE") { | ||
var retry = loadLoader.bind(null, loader, callback); | ||
const retry = loadLoader.bind(null, loader, callback); | ||
if (typeof setImmediate === "function") { | ||
@@ -62,5 +63,3 @@ // node >= 0.9.0 | ||
if (typeof module !== "function" && typeof module !== "object") { | ||
return callback(new LoaderLoadingError_1.default("Module '" + | ||
loader.path + | ||
"' is not a loader (export function or es6 module)")); | ||
return callback(new LoaderLoadingError_1.default(`Module '${loader.path}' is not a loader (export function or es6 module)`)); | ||
} | ||
@@ -72,7 +71,5 @@ loader.normal = typeof module === "function" ? module : module.default; | ||
typeof loader.pitch !== "function") { | ||
return callback(new LoaderLoadingError_1.default("Module '" + | ||
loader.path + | ||
"' is not a loader (must have normal or pitch function)")); | ||
return callback(new LoaderLoadingError_1.default(`Module '${loader.path}' is not a loader (must have normal or pitch function)`)); | ||
} | ||
callback(); | ||
} |
@@ -10,7 +10,27 @@ /** | ||
*/ | ||
/** | ||
* @param {LoggerOptions} options options object | ||
* @returns {function(string, LogTypeEnum, any[]): void} logging function | ||
*/ | ||
declare const _default: ({ level, debug, console }: any) => (name: any, type: any, args: any) => void; | ||
export = _default; | ||
import type { FilterTypes } from "../config"; | ||
import { type LogTypeEnum } from "./Logger"; | ||
export type FilterFunction = (ident: string) => boolean; | ||
export type LoggerConsole = { | ||
clear: () => void; | ||
trace: () => void; | ||
info: (...args: any[]) => void; | ||
log: (...args: any[]) => void; | ||
warn: (...args: any[]) => void; | ||
error: (...args: any[]) => void; | ||
debug?: (...args: any[]) => void; | ||
group?: (...args: any[]) => void; | ||
groupCollapsed?: (...args: any[]) => void; | ||
groupEnd?: (...args: any[]) => void; | ||
status?: (...args: any[]) => void; | ||
profile?: (...args: any[]) => void; | ||
profileEnd?: (...args: any[]) => void; | ||
logTime?: (...args: any[]) => void; | ||
}; | ||
export type LoggerOptions = { | ||
level: "none" | "error" | "warn" | "info" | "log" | "verbose" | boolean; | ||
debug: FilterTypes | boolean; | ||
console: LoggerConsole; | ||
}; | ||
declare const createConsoleLogger: ({ level, debug, console }: LoggerOptions) => (name: string, type: LogTypeEnum, args: any[]) => void; | ||
export { createConsoleLogger }; |
@@ -11,34 +11,6 @@ "use strict"; | ||
*/ | ||
// @ts-nocheck | ||
const { LogType } = require("./Logger"); | ||
/** @typedef {import("./Logger").LogTypeEnum} LogTypeEnum */ | ||
/** @typedef {function(string): boolean} FilterFunction */ | ||
/** | ||
* @typedef {Object} LoggerConsole | ||
* @property {function(): void} clear | ||
* @property {function(): void} trace | ||
* @property {(...args: any[]) => void} info | ||
* @property {(...args: any[]) => void} log | ||
* @property {(...args: any[]) => void} warn | ||
* @property {(...args: any[]) => void} error | ||
* @property {(...args: any[]) => void=} debug | ||
* @property {(...args: any[]) => void=} group | ||
* @property {(...args: any[]) => void=} groupCollapsed | ||
* @property {(...args: any[]) => void=} groupEnd | ||
* @property {(...args: any[]) => void=} status | ||
* @property {(...args: any[]) => void=} profile | ||
* @property {(...args: any[]) => void=} profileEnd | ||
* @property {(...args: any[]) => void=} logTime | ||
*/ | ||
/** | ||
* @typedef {Object} LoggerOptions | ||
* @property {false|true|"none"|"error"|"warn"|"info"|"log"|"verbose"} level loglevel | ||
* @property {FilterTypes|boolean} debug filter for debug logging | ||
* @property {LoggerConsole} console the console to log to | ||
*/ | ||
/** | ||
* @param {FilterItemTypes} item an input item | ||
* @returns {FilterFunction} filter function | ||
*/ | ||
const filterToFunction = item => { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createConsoleLogger = void 0; | ||
const Logger_1 = require("./Logger"); | ||
const filterToFunction = (item) => { | ||
if (typeof item === "string") { | ||
@@ -60,5 +32,2 @@ const regExp = new RegExp(`[\\\\/]${item.replace( | ||
}; | ||
/** | ||
* @enum {number} | ||
*/ | ||
const LogLevel = { | ||
@@ -74,14 +43,7 @@ none: 6, | ||
}; | ||
module.exports = ({ level = "info", debug = false, console }) => { | ||
const createConsoleLogger = ({ level = "info", debug = false, console }) => { | ||
const debugFilters = typeof debug === "boolean" | ||
? [() => debug] | ||
: /** @type {FilterItemTypes[]} */ [].concat(debug).map(filterToFunction); | ||
/** @type {number} */ | ||
: [].concat(debug).map(filterToFunction); | ||
const loglevel = LogLevel[`${level}`] || 0; | ||
/** | ||
* @param {string} name name of the logger | ||
* @param {LogTypeEnum} type type of the log entry | ||
* @param {any[]} args arguments of the log entry | ||
* @returns {void} | ||
*/ | ||
const logger = (name, type, args) => { | ||
@@ -99,3 +61,3 @@ const labeledArgs = () => { | ||
switch (type) { | ||
case LogType.debug: | ||
case Logger_1.LogType.debug: | ||
if (!debug) | ||
@@ -110,3 +72,3 @@ return; | ||
break; | ||
case LogType.log: | ||
case Logger_1.LogType.log: | ||
if (!debug && loglevel > LogLevel.log) | ||
@@ -116,3 +78,3 @@ return; | ||
break; | ||
case LogType.info: | ||
case Logger_1.LogType.info: | ||
if (!debug && loglevel > LogLevel.info) | ||
@@ -122,3 +84,3 @@ return; | ||
break; | ||
case LogType.warn: | ||
case Logger_1.LogType.warn: | ||
if (!debug && loglevel > LogLevel.warn) | ||
@@ -128,3 +90,3 @@ return; | ||
break; | ||
case LogType.error: | ||
case Logger_1.LogType.error: | ||
if (!debug && loglevel > LogLevel.error) | ||
@@ -134,3 +96,3 @@ return; | ||
break; | ||
case LogType.trace: | ||
case Logger_1.LogType.trace: | ||
if (!debug) | ||
@@ -140,3 +102,3 @@ return; | ||
break; | ||
case LogType.groupCollapsed: | ||
case Logger_1.LogType.groupCollapsed: | ||
if (!debug && loglevel > LogLevel.log) | ||
@@ -154,3 +116,3 @@ return; | ||
// falls through | ||
case LogType.group: | ||
case Logger_1.LogType.group: | ||
if (!debug && loglevel > LogLevel.log) | ||
@@ -165,3 +127,3 @@ return; | ||
break; | ||
case LogType.groupEnd: | ||
case Logger_1.LogType.groupEnd: | ||
if (!debug && loglevel > LogLevel.log) | ||
@@ -173,3 +135,3 @@ return; | ||
break; | ||
case LogType.time: { | ||
case Logger_1.LogType.time: { | ||
if (!debug && loglevel > LogLevel.log) | ||
@@ -187,3 +149,3 @@ return; | ||
} | ||
case LogType.profile: | ||
case Logger_1.LogType.profile: | ||
if (typeof console.profile === "function") { | ||
@@ -193,3 +155,3 @@ console.profile(...labeledArgs()); | ||
break; | ||
case LogType.profileEnd: | ||
case Logger_1.LogType.profileEnd: | ||
if (typeof console.profileEnd === "function") { | ||
@@ -199,3 +161,3 @@ console.profileEnd(...labeledArgs()); | ||
break; | ||
case LogType.clear: | ||
case Logger_1.LogType.clear: | ||
if (!debug && loglevel > LogLevel.log) | ||
@@ -207,3 +169,3 @@ return; | ||
break; | ||
case LogType.status: | ||
case Logger_1.LogType.status: | ||
if (!debug && loglevel > LogLevel.info) | ||
@@ -231,1 +193,2 @@ return; | ||
}; | ||
exports.createConsoleLogger = createConsoleLogger; |
@@ -95,3 +95,3 @@ "use strict"; | ||
timeLog(label) { | ||
const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label); | ||
const prev = this[TIMERS_SYMBOL]?.get(label); | ||
if (!prev) { | ||
@@ -104,3 +104,3 @@ throw new Error(`No such label '${label}' for WebpackLogger.timeLog()`); | ||
timeEnd(label) { | ||
const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label); | ||
const prev = this[TIMERS_SYMBOL]?.get(label); | ||
if (!prev) { | ||
@@ -114,3 +114,3 @@ throw new Error(`No such label '${label}' for WebpackLogger.timeEnd()`); | ||
timeAggregate(label) { | ||
const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label); | ||
const prev = this[TIMERS_SYMBOL]?.get(label); | ||
if (!prev) { | ||
@@ -117,0 +117,0 @@ throw new Error(`No such label '${label}' for WebpackLogger.timeAggregate()`); |
@@ -10,14 +10,8 @@ /** | ||
*/ | ||
/** | ||
* @param {string} name name of the logger | ||
* @returns {Logger} a logger | ||
*/ | ||
export declare const getLogger: (name: any) => any; | ||
/** | ||
* @param {createConsoleLogger.LoggerOptions} options new options, merge with old options | ||
* @returns {void} | ||
*/ | ||
export declare const configureDefaultLogger: (options: any) => void; | ||
import { Logger } from "./Logger"; | ||
import { type LoggerOptions } from "./createConsoleLogger"; | ||
export declare const getLogger: (name: string) => Logger; | ||
export declare const configureDefaultLogger: (options: LoggerOptions) => void; | ||
export declare const hooks: { | ||
log: any; | ||
}; |
@@ -14,5 +14,4 @@ "use strict"; | ||
const SyncBailHook = require("tapable/lib/SyncBailHook"); | ||
const { Logger } = require("./Logger"); | ||
const createConsoleLogger = require("./createConsoleLogger"); | ||
/** @type {createConsoleLogger.LoggerOptions} */ | ||
const Logger_1 = require("./Logger"); | ||
const createConsoleLogger_1 = require("./createConsoleLogger"); | ||
const currentDefaultLoggerOptions = { | ||
@@ -23,28 +22,14 @@ level: "info", | ||
}; | ||
let currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions); | ||
/** | ||
* @param {string} name name of the logger | ||
* @returns {Logger} a logger | ||
*/ | ||
// @ts-expect-error | ||
const getLogger = name => { | ||
return new Logger( | ||
// @ts-expect-error | ||
(type, args) => { | ||
let currentDefaultLogger = (0, createConsoleLogger_1.createConsoleLogger)(currentDefaultLoggerOptions); | ||
const getLogger = (name) => { | ||
return new Logger_1.Logger((type, args) => { | ||
if (exports.hooks.log.call(name, type, args) === undefined) { | ||
currentDefaultLogger(name, type, args); | ||
} | ||
}, | ||
// @ts-expect-error | ||
childName => exports.getLogger(`${name}/${childName}`)); | ||
}, childName => exports.getLogger(`${name}/${childName}`)); | ||
}; | ||
exports.getLogger = getLogger; | ||
/** | ||
* @param {createConsoleLogger.LoggerOptions} options new options, merge with old options | ||
* @returns {void} | ||
*/ | ||
// @ts-expect-error | ||
const configureDefaultLogger = options => { | ||
const configureDefaultLogger = (options) => { | ||
Object.assign(currentDefaultLoggerOptions, options); | ||
currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions); | ||
currentDefaultLogger = (0, createConsoleLogger_1.createConsoleLogger)(currentDefaultLoggerOptions); | ||
}; | ||
@@ -51,0 +36,0 @@ exports.configureDefaultLogger = configureDefaultLogger; |
@@ -11,7 +11,7 @@ /** | ||
/** | ||
* @param {any[]} args items to be truncated | ||
* @param {number} maxLength maximum length of args including spaces between | ||
* @returns {string[]} truncated args | ||
* @param args items to be truncated | ||
* @param maxLength maximum length of args including spaces between | ||
* @returns truncated args | ||
*/ | ||
declare const truncateArgs: (args: any, maxLength: any) => any; | ||
declare const truncateArgs: (args: any[], maxLength: number) => string[]; | ||
export { truncateArgs }; |
@@ -20,9 +20,7 @@ "use strict"; | ||
/** | ||
* @param {any[]} args items to be truncated | ||
* @param {number} maxLength maximum length of args including spaces between | ||
* @returns {string[]} truncated args | ||
* @param args items to be truncated | ||
* @param maxLength maximum length of args including spaces between | ||
* @returns truncated args | ||
*/ | ||
// @ts-expect-error | ||
const truncateArgs = (args, maxLength) => { | ||
// @ts-expect-error | ||
const lengths = args.map(a => `${a}`.length); | ||
@@ -35,3 +33,3 @@ const availableLength = maxLength - lengths.length + 1; | ||
if (availableLength > 3) { | ||
return ["..." + args[0].slice(-availableLength + 3)]; | ||
return [`...${args[0].slice(-availableLength + 3)}`]; | ||
} | ||
@@ -41,3 +39,2 @@ return [args[0].slice(-availableLength)]; | ||
// Check if there is space for at least 4 chars per arg | ||
// @ts-expect-error | ||
if (availableLength < arraySum(lengths.map(i => Math.min(i, 6)))) { | ||
@@ -56,3 +53,2 @@ // remove args | ||
const maxLength = Math.max(...lengths); | ||
// @ts-expect-error | ||
const shorterItems = lengths.filter(l => l !== maxLength); | ||
@@ -74,3 +70,2 @@ const nextToMaxLength = shorterItems.length > 0 ? Math.max(...shorterItems) : 0; | ||
// Return args reduced to length in lengths | ||
// @ts-expect-error | ||
return args.map((a, i) => { | ||
@@ -83,3 +78,3 @@ const str = `${a}`; | ||
if (length > 5) { | ||
return "..." + str.slice(-length + 3); | ||
return `...${str.slice(-length + 3)}`; | ||
} | ||
@@ -86,0 +81,0 @@ if (length > 0) { |
@@ -1,2 +0,2 @@ | ||
import type { JsCodegenerationResult, JsCodegenerationResults, JsCreateData, JsFactoryMeta, JsModule } from "@rspack/binding"; | ||
import type { JsCodegenerationResult, JsCreateData, JsFactoryMeta, JsModule } from "@rspack/binding"; | ||
import type { Source } from "../compiled/webpack-sources"; | ||
@@ -71,3 +71,2 @@ import type { Compilation } from "./Compilation"; | ||
export declare class CodeGenerationResults { | ||
constructor(_result: JsCodegenerationResults); | ||
} |
@@ -70,4 +70,3 @@ "use strict"; | ||
class CodeGenerationResults { | ||
constructor(_result) { } | ||
} | ||
exports.CodeGenerationResults = CodeGenerationResults; |
@@ -274,3 +274,3 @@ "use strict"; | ||
for (const compiler of this.compilers) { | ||
if (compiler.inputFileSystem && compiler.inputFileSystem.purge) { | ||
if (compiler.inputFileSystem?.purge) { | ||
compiler.inputFileSystem.purge(); | ||
@@ -277,0 +277,0 @@ } |
@@ -10,22 +10,8 @@ /** | ||
*/ | ||
declare const _default: ({ colors, appendOnly, stream }: { | ||
colors: any; | ||
appendOnly: any; | ||
stream: any; | ||
}) => { | ||
log: (...args: any[]) => void; | ||
debug: (...args: any[]) => void; | ||
trace: (...args: any[]) => void; | ||
info: (...args: any[]) => void; | ||
warn: (...args: any[]) => void; | ||
error: (...args: any[]) => void; | ||
logTime: (...args: any[]) => void; | ||
group: (...args: any[]) => void; | ||
groupCollapsed: (...args: any[]) => void; | ||
groupEnd: () => void; | ||
profile: (name: any) => void; | ||
profileEnd: (name: any) => void; | ||
clear: false | (() => void); | ||
status: (...args: any[]) => void; | ||
}; | ||
export = _default; | ||
/// <reference types="node" /> | ||
import type { LoggerConsole } from "../logging/createConsoleLogger"; | ||
export default function ({ colors, appendOnly, stream }: { | ||
colors?: boolean; | ||
appendOnly?: boolean; | ||
stream: NodeJS.WritableStream; | ||
}): LoggerConsole; |
@@ -34,6 +34,6 @@ "use strict"; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const util = __importStar(require("node:util")); | ||
const truncateArgs_1 = require("../logging/truncateArgs"); | ||
module.exports = ({ colors, appendOnly, stream }) => { | ||
// @ts-expect-error | ||
function default_1({ colors, appendOnly, stream }) { | ||
let currentStatusMessage = undefined; | ||
@@ -43,3 +43,2 @@ let hasStatusMessage = false; | ||
let currentCollapsed = 0; | ||
// @ts-expect-error | ||
const indent = (str, prefix, colorPrefix, colorSuffix) => { | ||
@@ -52,6 +51,6 @@ if (str === "") | ||
colorPrefix + | ||
str.replace(/\n/g, colorSuffix + "\n" + prefix + colorPrefix) + | ||
str.replace(/\n/g, `${colorSuffix}\n${prefix}${colorPrefix}`) + | ||
colorSuffix); | ||
} | ||
return prefix + str.replace(/\n/g, "\n" + prefix); | ||
return prefix + str.replace(/\n/g, `\n${prefix}`); | ||
}; | ||
@@ -65,5 +64,5 @@ const clearStatusMessage = () => { | ||
const writeStatusMessage = () => { | ||
// @ts-expect-error | ||
if (!currentStatusMessage) | ||
return; | ||
//@ts-expect-error Property 'columns' does not exist on type 'WritableStream'.ts(2339) | ||
const l = stream.columns; | ||
@@ -78,5 +77,3 @@ const args = l | ||
}; | ||
// @ts-expect-error | ||
const writeColored = (prefix, colorPrefix, colorSuffix) => { | ||
// @ts-expect-error | ||
return (...args) => { | ||
@@ -87,3 +84,3 @@ if (currentCollapsed > 0) | ||
const str = indent(util.format(...args), prefix, colorPrefix, colorSuffix); | ||
stream.write(str + "\n"); | ||
stream.write(`${str}\n`); | ||
writeStatusMessage(); | ||
@@ -102,3 +99,2 @@ }; | ||
logTime: writeColored("<t> ", "\u001b[1m\u001b[35m", "\u001b[39m\u001b[22m"), | ||
// @ts-expect-error | ||
group: (...args) => { | ||
@@ -113,3 +109,2 @@ writeGroupMessage(...args); | ||
}, | ||
// @ts-expect-error | ||
groupCollapsed: (...args) => { | ||
@@ -125,7 +120,5 @@ writeGroupCollapsedMessage(...args); | ||
}, | ||
// @ts-expect-error | ||
profile: console.profile && (name => console.profile(name)), | ||
// @ts-expect-error | ||
profileEnd: console.profileEnd && (name => console.profileEnd(name)), | ||
clear: !appendOnly && | ||
clear: (!appendOnly && | ||
console.clear && | ||
@@ -136,27 +129,27 @@ (() => { | ||
writeStatusMessage(); | ||
}), | ||
})), | ||
status: appendOnly | ||
? writeColored("<s> ", "", "") | ||
: // @ts-expect-error | ||
(name, ...args) => { | ||
args = args.filter(Boolean); | ||
if (name === undefined && args.length === 0) { | ||
clearStatusMessage(); | ||
currentStatusMessage = undefined; | ||
} | ||
else if (typeof name === "string" && | ||
name.startsWith("[webpack.Progress] ")) { | ||
currentStatusMessage = [name.slice(19), ...args]; | ||
writeStatusMessage(); | ||
} | ||
else if (name === "[webpack.Progress]") { | ||
currentStatusMessage = [...args]; | ||
writeStatusMessage(); | ||
} | ||
else { | ||
currentStatusMessage = [name, ...args]; | ||
writeStatusMessage(); | ||
} | ||
: (name, ...args) => { | ||
args = args.filter(Boolean); | ||
if (name === undefined && args.length === 0) { | ||
clearStatusMessage(); | ||
currentStatusMessage = undefined; | ||
} | ||
else if (typeof name === "string" && | ||
name.startsWith("[webpack.Progress] ")) { | ||
currentStatusMessage = [name.slice(19), ...args]; | ||
writeStatusMessage(); | ||
} | ||
else if (name === "[webpack.Progress]") { | ||
currentStatusMessage = [...args]; | ||
writeStatusMessage(); | ||
} | ||
else { | ||
currentStatusMessage = [name, ...args]; | ||
writeStatusMessage(); | ||
} | ||
} | ||
}; | ||
}; | ||
} | ||
exports.default = default_1; |
@@ -18,3 +18,3 @@ "use strict"; | ||
const graceful_fs_1 = __importDefault(require("../../compiled/graceful-fs")); | ||
const createConsoleLogger_1 = __importDefault(require("../logging/createConsoleLogger")); | ||
const createConsoleLogger_1 = require("../logging/createConsoleLogger"); | ||
const NodeWatchFileSystem_1 = __importDefault(require("./NodeWatchFileSystem")); | ||
@@ -28,3 +28,3 @@ const nodeConsole_1 = __importDefault(require("./nodeConsole")); | ||
const { infrastructureLogging } = this.options; | ||
compiler.infrastructureLogger = (0, createConsoleLogger_1.default)({ | ||
compiler.infrastructureLogger = (0, createConsoleLogger_1.createConsoleLogger)({ | ||
level: infrastructureLogging.level || "info", | ||
@@ -31,0 +31,0 @@ debug: infrastructureLogging.debug || false, |
@@ -63,3 +63,3 @@ "use strict"; | ||
this.watcher.pause(); | ||
if (this.inputFileSystem && this.inputFileSystem.purge) { | ||
if (this.inputFileSystem?.purge) { | ||
const fs = this.inputFileSystem; | ||
@@ -96,3 +96,3 @@ for (const item of changes) { | ||
getAggregatedRemovals: node_util_1.default.deprecate(() => { | ||
const items = this.watcher && this.watcher.aggregatedRemovals; | ||
const items = this.watcher?.aggregatedRemovals; | ||
if (items && this.inputFileSystem && this.inputFileSystem.purge) { | ||
@@ -107,3 +107,3 @@ const fs = this.inputFileSystem; | ||
getAggregatedChanges: node_util_1.default.deprecate(() => { | ||
const items = this.watcher && this.watcher.aggregatedChanges; | ||
const items = this.watcher?.aggregatedChanges; | ||
if (items && this.inputFileSystem && this.inputFileSystem.purge) { | ||
@@ -124,5 +124,5 @@ const fs = this.inputFileSystem; | ||
getInfo: () => { | ||
const removals = this.watcher && this.watcher.aggregatedRemovals; | ||
const changes = this.watcher && this.watcher.aggregatedChanges; | ||
if (this.inputFileSystem && this.inputFileSystem.purge) { | ||
const removals = this.watcher?.aggregatedRemovals; | ||
const changes = this.watcher?.aggregatedChanges; | ||
if (this.inputFileSystem?.purge) { | ||
const fs = this.inputFileSystem; | ||
@@ -129,0 +129,0 @@ if (removals) { |
import type * as binding from "@rspack/binding"; | ||
import { type Resolve } from "./config"; | ||
interface ResolveContext { | ||
} | ||
type ResolveContext = {}; | ||
type ErrorWithDetail = Error & { | ||
@@ -6,0 +5,0 @@ details?: string; |
@@ -18,5 +18,5 @@ "use strict"; | ||
this.name = "NonErrorEmittedError"; | ||
this.message = "(Emitted value instead of an instance of Error) " + error; | ||
this.message = `(Emitted value instead of an instance of Error) ${error}`; | ||
} | ||
} | ||
exports.NonErrorEmittedError = NonErrorEmittedError; |
import type { Compiler, RspackOptionsNormalized } from "."; | ||
export declare class RspackOptionsApply { | ||
constructor(); | ||
process(options: RspackOptionsNormalized, compiler: Compiler): void; | ||
} |
@@ -22,2 +22,3 @@ "use strict"; | ||
const IgnoreWarningsPlugin_1 = __importDefault(require("./lib/IgnoreWarningsPlugin")); | ||
const MemoryCachePlugin_1 = __importDefault(require("./lib/cache/MemoryCachePlugin")); | ||
const DefaultStatsFactoryPlugin_1 = require("./stats/DefaultStatsFactoryPlugin"); | ||
@@ -28,3 +29,2 @@ const DefaultStatsPresetPlugin_1 = require("./stats/DefaultStatsPresetPlugin"); | ||
class RspackOptionsApply { | ||
constructor() { } | ||
process(options, compiler) { | ||
@@ -81,3 +81,3 @@ (0, node_assert_1.default)(options.output.path, "options.output.path should have value after `applyRspackOptionsDefaults`"); | ||
default: | ||
throw new Error("Unsupported chunk format '" + options.output.chunkFormat + "'."); | ||
throw new Error(`Unsupported chunk format '${options.output.chunkFormat}'.`); | ||
} | ||
@@ -118,4 +118,4 @@ } | ||
append: hidden ? false : undefined, | ||
module: moduleMaps ? true : cheap ? false : true, | ||
columns: cheap ? false : true, | ||
module: moduleMaps ? true : !cheap, | ||
columns: !cheap, | ||
noSources: noSources, | ||
@@ -183,5 +183,3 @@ namespace: options.output.devtoolNamespace | ||
} | ||
: undefined, | ||
// @ts-expect-error backend is hide | ||
lazyOptions.backend).apply(compiler); | ||
: undefined, lazyOptions.backend).apply(compiler); | ||
} | ||
@@ -261,2 +259,5 @@ if (options.output.enabledLibraryTypes && | ||
new builtin_plugin_1.WarnCaseSensitiveModulesPlugin().apply(compiler); | ||
if (options.cache) { | ||
new MemoryCachePlugin_1.default().apply(compiler); | ||
} | ||
new builtin_plugin_1.WorkerPlugin(options.output.workerChunkLoading, options.output.workerWasmLoading, options.output.module, options.output.workerPublicPath).apply(compiler); | ||
@@ -263,0 +264,0 @@ new DefaultStatsFactoryPlugin_1.DefaultStatsFactoryPlugin().apply(compiler); |
@@ -1,15 +0,16 @@ | ||
import { type BuiltinPlugin, BuiltinPluginName } from "@rspack/binding"; | ||
import { type BuiltinPlugin, BuiltinPluginName, type RawProvideOptions } from "@rspack/binding"; | ||
import type { Compiler } from "../Compiler"; | ||
import { RspackBuiltinPlugin } from "../builtin-plugin/base"; | ||
export type ProvideSharedPluginOptions = { | ||
provides: Provides; | ||
export type ProvideSharedPluginOptions<Enhanced extends boolean = false> = { | ||
provides: Provides<Enhanced>; | ||
shareScope?: string; | ||
enhanced?: boolean; | ||
enhanced?: Enhanced; | ||
}; | ||
export type Provides = (ProvidesItem | ProvidesObject)[] | ProvidesObject; | ||
export type Provides<Enhanced extends boolean> = (ProvidesItem | ProvidesObject<Enhanced>)[] | ProvidesObject<Enhanced>; | ||
export type ProvidesItem = string; | ||
export type ProvidesObject = { | ||
[k: string]: ProvidesConfig | ProvidesItem; | ||
export type ProvidesObject<Enhanced extends boolean> = { | ||
[k: string]: ProvidesConfig<Enhanced> | ProvidesItem; | ||
}; | ||
export type ProvidesConfig = { | ||
export type ProvidesConfig<Enhanced extends boolean> = Enhanced extends true ? ProvidesEnhancedConfig : ProvidesV1Config; | ||
type ProvidesV1Config = { | ||
eager?: boolean; | ||
@@ -20,15 +21,15 @@ shareKey: string; | ||
}; | ||
export declare class ProvideSharedPlugin extends RspackBuiltinPlugin { | ||
type ProvidesEnhancedConfig = ProvidesV1Config & ProvidesEnhancedExtraConfig; | ||
type ProvidesEnhancedExtraConfig = { | ||
singleton?: boolean; | ||
strictVersion?: boolean; | ||
requiredVersion?: false | string; | ||
}; | ||
export declare class ProvideSharedPlugin<Enhanced extends boolean = false> extends RspackBuiltinPlugin { | ||
name: BuiltinPluginName; | ||
_options: { | ||
provides: [string, { | ||
shareKey: string; | ||
version: string | false | undefined; | ||
shareScope: string; | ||
eager: boolean; | ||
}][]; | ||
enhanced: boolean; | ||
}; | ||
constructor(options: ProvideSharedPluginOptions); | ||
_provides: [string, Omit<RawProvideOptions, "key">][]; | ||
_enhanced?: Enhanced; | ||
constructor(options: ProvideSharedPluginOptions<Enhanced>); | ||
raw(compiler: Compiler): BuiltinPlugin; | ||
} | ||
export {}; |
@@ -12,14 +12,13 @@ "use strict"; | ||
this.name = binding_1.BuiltinPluginName.ProvideSharedPlugin; | ||
this._options = { | ||
provides: (0, options_1.parseOptions)(options.provides, item => { | ||
if (Array.isArray(item)) | ||
throw new Error("Unexpected array of provides"); | ||
const result = { | ||
shareKey: item, | ||
version: undefined, | ||
shareScope: options.shareScope || "default", | ||
eager: false | ||
}; | ||
return result; | ||
}, item => ({ | ||
this._provides = (0, options_1.parseOptions)(options.provides, item => { | ||
if (Array.isArray(item)) | ||
throw new Error("Unexpected array of provides"); | ||
return { | ||
shareKey: item, | ||
version: undefined, | ||
shareScope: options.shareScope || "default", | ||
eager: false | ||
}; | ||
}, item => { | ||
const raw = { | ||
shareKey: item.shareKey, | ||
@@ -29,9 +28,19 @@ version: item.version, | ||
eager: !!item.eager | ||
})), | ||
enhanced: options.enhanced ?? false | ||
}; | ||
}; | ||
if (options.enhanced) { | ||
const enhancedItem = item; | ||
return { | ||
...raw, | ||
singleton: enhancedItem.singleton, | ||
requiredVersion: enhancedItem.requiredVersion, | ||
strictVersion: enhancedItem.strictVersion | ||
}; | ||
} | ||
return raw; | ||
}); | ||
this._enhanced = options.enhanced; | ||
} | ||
raw(compiler) { | ||
new ShareRuntimePlugin_1.ShareRuntimePlugin(this._options.enhanced).apply(compiler); | ||
const rawOptions = this._options.provides.map(([key, v]) => ({ | ||
new ShareRuntimePlugin_1.ShareRuntimePlugin(this._enhanced ?? false).apply(compiler); | ||
const rawOptions = this._provides.map(([key, v]) => ({ | ||
key, | ||
@@ -38,0 +47,0 @@ ...v |
@@ -43,2 +43,5 @@ import type { Compiler } from "../Compiler"; | ||
eager: boolean | undefined; | ||
singleton: boolean | undefined; | ||
requiredVersion: string | false | undefined; | ||
strictVersion: boolean | undefined; | ||
}; | ||
@@ -45,0 +48,0 @@ }[]; |
@@ -42,3 +42,6 @@ "use strict"; | ||
version: options.version, | ||
eager: options.eager | ||
eager: options.eager, | ||
singleton: options.singleton, | ||
requiredVersion: options.requiredVersion, | ||
strictVersion: options.strictVersion | ||
} | ||
@@ -45,0 +48,0 @@ })); |
@@ -35,6 +35,6 @@ "use strict"; | ||
hasErrors() { | ||
return __classPrivateFieldGet(this, _Stats_inner, "f").getErrors().length > 0; | ||
return __classPrivateFieldGet(this, _Stats_inner, "f").hasErrors(); | ||
} | ||
hasWarnings() { | ||
return __classPrivateFieldGet(this, _Stats_inner, "f").getWarnings().length > 0; | ||
return __classPrivateFieldGet(this, _Stats_inner, "f").hasWarnings(); | ||
} | ||
@@ -46,2 +46,3 @@ toJson(opts, forToString) { | ||
const statsFactory = this.compilation.createStatsFactory(options); | ||
const statsCompilationMap = new Map(); | ||
// FIXME: This is a really ugly workaround for avoid panic for accessing previous compilation. | ||
@@ -55,2 +56,11 @@ // Modern.js dev server will detect whether the returned stats is available. | ||
compilation: this.compilation, | ||
getStatsCompilation: (compilation) => { | ||
if (statsCompilationMap.has(compilation)) { | ||
return statsCompilationMap.get(compilation); | ||
} | ||
const innerStats = __classPrivateFieldGet(this, _Stats_instances, "m", _Stats_getInnerByCompilation).call(this, compilation); | ||
const innerStatsCompilation = innerStats.toJson(options); | ||
statsCompilationMap.set(compilation, innerStatsCompilation); | ||
return innerStatsCompilation; | ||
}, | ||
getInner: __classPrivateFieldGet(this, _Stats_instances, "m", _Stats_getInnerByCompilation).bind(this) | ||
@@ -71,2 +81,3 @@ }); | ||
const statsPrinter = this.compilation.createStatsPrinter(options); | ||
const statsCompilationMap = new Map(); | ||
// FIXME: This is a really ugly workaround for avoid panic for accessing previous compilation. | ||
@@ -80,2 +91,11 @@ // Modern.js dev server will detect whether the returned stats is available. | ||
compilation: this.compilation, | ||
getStatsCompilation: (compilation) => { | ||
if (statsCompilationMap.has(compilation)) { | ||
return statsCompilationMap.get(compilation); | ||
} | ||
const innerStats = __classPrivateFieldGet(this, _Stats_instances, "m", _Stats_getInnerByCompilation).call(this, compilation); | ||
const innerStatsCompilation = innerStats.toJson(options); | ||
statsCompilationMap.set(compilation, innerStatsCompilation); | ||
return innerStatsCompilation; | ||
}, | ||
getInner: __classPrivateFieldGet(this, _Stats_instances, "m", _Stats_getInnerByCompilation).bind(this) | ||
@@ -82,0 +102,0 @@ }); |
@@ -123,3 +123,3 @@ "use strict"; | ||
while (path.length > 0) { | ||
keys.push(path.join("/") + "/"); | ||
keys.push(`${path.join("/")}/`); | ||
path.pop(); | ||
@@ -150,3 +150,3 @@ } | ||
getKeys: asset => { | ||
return asset.info && asset.info[name] ? ["1"] : undefined; | ||
return asset.info?.[name] ? ["1"] : undefined; | ||
}, | ||
@@ -261,8 +261,9 @@ // @ts-expect-error | ||
getKeys: (module) => { | ||
if (!module.moduleType) | ||
const moduleType = module.moduleType; | ||
if (!moduleType) | ||
return; | ||
if (groupModulesByType) { | ||
return [module.moduleType.split("/", 1)[0]]; | ||
return [moduleType.split("/", 1)[0]]; | ||
} | ||
if (module.moduleType === "runtime") { | ||
if (moduleType === "runtime") { | ||
return ["runtime"]; | ||
@@ -311,3 +312,3 @@ } | ||
while (path.length > 0) { | ||
keys.push(path.join("/") + "/"); | ||
keys.push(`${path.join("/")}/`); | ||
path.pop(); | ||
@@ -404,3 +405,3 @@ } | ||
_: comparators => { | ||
comparators.push((0, comparators_1.compareSelect)((m) => m.depth, comparators_1.compareNumbers), (0, comparators_1.compareSelect)((m) => m.preOrderIndex, comparators_1.compareNumbers), (0, comparators_1.compareSelect)((m) => m.identifier, compareIds)); | ||
comparators.push((0, comparators_1.compareSelect)((m) => m.commonAttributes.depth, comparators_1.compareNumbers), (0, comparators_1.compareSelect)((m) => m.commonAttributes.preOrderIndex, comparators_1.compareNumbers), (0, comparators_1.compareSelect)((m) => m.commonAttributes.moduleDescriptor?.identifier, compareIds)); | ||
} | ||
@@ -434,12 +435,29 @@ }; | ||
object.message = error.message; | ||
object.chunkName = error.chunkName; | ||
object.chunkEntry = error.chunkEntry; | ||
object.chunkInitial = error.chunkInitial; | ||
object.file = error.file; | ||
object.moduleIdentifier = error.moduleIdentifier; | ||
object.moduleName = error.moduleName; | ||
if (error.chunkName) { | ||
object.chunkName = error.chunkName; | ||
} | ||
if (error.chunkEntry) { | ||
object.chunkEntry = error.chunkEntry; | ||
} | ||
if (error.chunkInitial) { | ||
object.chunkInitial = error.chunkInitial; | ||
} | ||
if (error.file) { | ||
object.file = error.file; | ||
} | ||
if (error.moduleDescriptor) { | ||
object.moduleIdentifier = error.moduleDescriptor.identifier; | ||
object.moduleName = error.moduleDescriptor.name; | ||
} | ||
if ("loc" in error) { | ||
object.loc = error.loc; | ||
} | ||
}, | ||
ids: (object, error) => { | ||
object.chunkId = error.chunkId; | ||
object.moduleId = error.moduleId; | ||
if (error.chunkId) { | ||
object.chunkId = error.chunkId; | ||
} | ||
if (error.moduleDescriptor) { | ||
object.moduleId = error.moduleDescriptor.id; | ||
} | ||
}, | ||
@@ -460,2 +478,3 @@ moduleTrace: (object, error, context, _, factory) => { | ||
_: (object, compilation, context, options) => { | ||
const statsCompilation = context.getStatsCompilation(compilation); | ||
if (!context.makePathsRelative) { | ||
@@ -466,3 +485,3 @@ context.makePathsRelative = identifier_1.makePathsRelative.bindContextCache(compilation.compiler.context, compilation.compiler.root); | ||
context.cachedGetErrors = _compilation => { | ||
return context.getInner(compilation).getErrors(); | ||
return statsCompilation.errors; | ||
}; | ||
@@ -472,3 +491,3 @@ } | ||
context.cachedGetWarnings = _compilation => { | ||
const warnings = context.getInner(compilation).getWarnings(); | ||
const warnings = statsCompilation.warnings; | ||
return compilation.hooks.processWarnings.call(warnings); | ||
@@ -617,3 +636,4 @@ }; | ||
hash: (object, compilation, context) => { | ||
object.hash = context.getInner(compilation).getHash() || undefined; | ||
const statsCompilation = context.getStatsCompilation(compilation); | ||
object.hash = statsCompilation.hash; | ||
}, | ||
@@ -641,5 +661,6 @@ version: object => { | ||
assets: (object, compilation, context, options, factory) => { | ||
const { assets: compilationAssets, assetsByChunkName } = context | ||
.getInner(compilation) | ||
.getAssets(); | ||
const { type, getStatsCompilation } = context; | ||
const statsCompilation = getStatsCompilation(compilation); | ||
const compilationAssets = statsCompilation.assets; | ||
const assetsByChunkName = statsCompilation.assetsByChunkName; | ||
const assetMap = new Map(); | ||
@@ -679,3 +700,3 @@ const assets = new Set(); | ||
}, {}); | ||
const groupedAssets = factory.create(`${context.type}.assets`, Array.from(assets), { | ||
const groupedAssets = factory.create(`${type}.assets`, Array.from(assets), { | ||
...context | ||
@@ -690,13 +711,11 @@ // compilationFileToChunks | ||
chunks: (object, compilation, context, options, factory) => { | ||
const { type } = context; | ||
const chunks = context | ||
.getInner(compilation) | ||
.getChunks(options.chunkModules, options.chunkRelations, options.reasons, options.moduleAssets, options.nestedModules, options.source, options.usedExports, options.providedExports); | ||
const { type, getStatsCompilation } = context; | ||
const statsCompilation = getStatsCompilation(compilation); | ||
const chunks = statsCompilation.chunks; | ||
object.chunks = factory.create(`${type}.chunks`, chunks, context); | ||
}, | ||
modules: (object, compilation, context, options, factory) => { | ||
const { type } = context; | ||
const array = context | ||
.getInner(compilation) | ||
.getModules(options.reasons, options.moduleAssets, options.nestedModules, options.source, options.usedExports, options.providedExports); | ||
const { type, getStatsCompilation } = context; | ||
const statsCompilation = getStatsCompilation(compilation); | ||
const array = statsCompilation.modules; | ||
const groupedModules = factory.create(`${type}.modules`, array, context); | ||
@@ -708,7 +727,5 @@ const limited = (0, statsFactoryUtils_1.spaceLimited)(groupedModules, options.modulesSpace); | ||
entrypoints: (object, compilation, context, { entrypoints, chunkGroups, chunkGroupAuxiliary, chunkGroupChildren }, factory) => { | ||
const { type } = context; | ||
const array = context | ||
.getInner(compilation) | ||
.getEntrypoints(chunkGroupAuxiliary, chunkGroupChildren) | ||
.map(entrypoint => ({ | ||
const { type, getStatsCompilation } = context; | ||
const statsCompilation = getStatsCompilation(compilation); | ||
const array = statsCompilation.entrypoints.map(entrypoint => ({ | ||
name: entrypoint.name, | ||
@@ -739,7 +756,5 @@ chunkGroup: entrypoint | ||
chunkGroups: (object, compilation, context, { chunkGroupAuxiliary, chunkGroupChildren }, factory) => { | ||
const { type } = context; | ||
const namedChunkGroups = context | ||
.getInner(compilation) | ||
.getNamedChunkGroups(chunkGroupAuxiliary, chunkGroupChildren) | ||
.map(cg => ({ | ||
const { type, getStatsCompilation } = context; | ||
const statsCompilation = getStatsCompilation(compilation); | ||
const namedChunkGroups = statsCompilation.namedChunkGroups.map(cg => ({ | ||
name: cg.name, | ||
@@ -750,5 +765,26 @@ chunkGroup: cg | ||
}, | ||
errors: (object, compilation, context, _options, _factory) => { | ||
const { cachedGetErrors } = context; | ||
object.errors = cachedGetErrors(compilation); | ||
errors: (object, compilation, context, options, factory) => { | ||
const { type, cachedGetErrors } = context; | ||
// const rawErrors = cachedGetErrors!(compilation); | ||
const factorizedErrors = factory.create(`${type}.errors`, cachedGetErrors(compilation), context); | ||
// let filtered = 0; | ||
// if (options.errorDetails === "auto" && rawErrors.length >= 3) { | ||
// filtered = rawErrors | ||
// .map(e => typeof e !== "string" && e.details) | ||
// .filter(Boolean).length; | ||
// } | ||
// if ( | ||
// options.errorDetails === true || | ||
// !Number.isFinite(options.errorsSpace) | ||
// ) { | ||
// object.errors = factorizedErrors; | ||
// if (filtered) object.filteredErrorDetailsCount = filtered; | ||
// return; | ||
// } | ||
// const [errors, filteredBySpace] = errorsSpaceLimit( | ||
// factorizedErrors, | ||
// options.errorsSpace | ||
// ); | ||
// object.filteredErrorDetailsCount = filtered + filteredBySpace; | ||
object.errors = factorizedErrors; | ||
}, | ||
@@ -758,5 +794,25 @@ errorsCount: (object, compilation, { cachedGetErrors }) => { | ||
}, | ||
warnings: (object, compilation, context, _options, _factory) => { | ||
const { cachedGetWarnings } = context; | ||
object.warnings = cachedGetWarnings(compilation); | ||
warnings: (object, compilation, context, options, factory) => { | ||
const { type, cachedGetWarnings } = context; | ||
const rawWarnings = factory.create(`${type}.warnings`, cachedGetWarnings(compilation), context); | ||
// let filtered = 0; | ||
// if (options.errorDetails === "auto") { | ||
// filtered = cachedGetWarnings!(compilation) | ||
// .map(e => typeof e !== "string" && e.details) | ||
// .filter(Boolean).length; | ||
// } | ||
// if ( | ||
// options.errorDetails === true || | ||
// !Number.isFinite(options.warningsSpace) | ||
// ) { | ||
// object.warnings = rawWarnings; | ||
// if (filtered) object.filteredWarningDetailsCount = filtered; | ||
// return; | ||
// } | ||
// const [warnings, filteredBySpace] = errorsSpaceLimit( | ||
// rawWarnings, | ||
// options.warningsSpace | ||
// ); | ||
// object.filteredWarningDetailsCount = filtered + filteredBySpace; | ||
object.warnings = rawWarnings; | ||
}, | ||
@@ -828,7 +884,8 @@ warningsCount: (object, compilation, context) => { | ||
const { type } = context; | ||
object.type = module.type; | ||
object.moduleType = module.moduleType; | ||
object.layer = module.layer; | ||
object.size = module.size; | ||
const sizes = module.sizes.map(({ sourceType, size }) => [ | ||
const { commonAttributes } = module; | ||
object.type = commonAttributes.type; | ||
object.moduleType = commonAttributes.moduleType; | ||
object.layer = commonAttributes.layer; | ||
object.size = commonAttributes.size; | ||
const sizes = commonAttributes.sizes.map(({ sourceType, size }) => [ | ||
sourceType, | ||
@@ -839,7 +896,9 @@ size | ||
object.sizes = Object.fromEntries(sizes); | ||
object.built = module.built; | ||
object.codeGenerated = module.codeGenerated; | ||
object.buildTimeExecuted = module.buildTimeExecuted; | ||
object.cached = module.cached; | ||
if (module.built || module.codeGenerated || options.cachedModules) { | ||
object.built = commonAttributes.built; | ||
object.codeGenerated = commonAttributes.codeGenerated; | ||
object.buildTimeExecuted = commonAttributes.buildTimeExecuted; | ||
object.cached = commonAttributes.cached; | ||
if (commonAttributes.built || | ||
commonAttributes.codeGenerated || | ||
options.cachedModules) { | ||
Object.assign(object, factory.create(`${type}$visible`, module, context)); | ||
@@ -852,20 +911,25 @@ } | ||
const { type } = context; | ||
object.identifier = module.identifier; | ||
object.name = module.name; | ||
object.nameForCondition = module.nameForCondition; | ||
object.index = module.preOrderIndex; | ||
object.preOrderIndex = module.preOrderIndex; | ||
object.index2 = module.postOrderIndex; | ||
object.postOrderIndex = module.postOrderIndex; | ||
object.cacheable = module.cacheable; | ||
object.optional = module.optional; | ||
object.orphan = module.orphan; | ||
const { commonAttributes } = module; | ||
if (commonAttributes.moduleDescriptor) { | ||
object.identifier = commonAttributes.moduleDescriptor.identifier; | ||
object.name = commonAttributes.moduleDescriptor.name; | ||
} | ||
object.nameForCondition = commonAttributes.nameForCondition; | ||
object.index = commonAttributes.preOrderIndex; | ||
object.preOrderIndex = commonAttributes.preOrderIndex; | ||
object.index2 = commonAttributes.postOrderIndex; | ||
object.postOrderIndex = commonAttributes.postOrderIndex; | ||
object.cacheable = commonAttributes.cacheable; | ||
object.optional = commonAttributes.optional; | ||
object.orphan = commonAttributes.orphan; | ||
object.dependent = module.dependent; | ||
object.issuer = module.issuer; | ||
object.issuerName = module.issuerName; | ||
object.issuerPath = factory.create(`${type.slice(0, -8)}.issuerPath`, module.issuerPath, context); | ||
object.failed = module.failed; | ||
object.errors = module.errors; | ||
object.warnings = module.warnings; | ||
const profile = module.profile; | ||
object.issuer = module.issuerDescriptor?.identifier; | ||
object.issuerName = module.issuerDescriptor?.name; | ||
object.issuerPath = | ||
module.issuerDescriptor && | ||
factory.create(`${type.slice(0, -8)}.issuerPath`, module.issuerPath, context); | ||
object.failed = commonAttributes.failed; | ||
object.errors = commonAttributes.errors; | ||
object.warnings = commonAttributes.warnings; | ||
const profile = commonAttributes.profile; | ||
if (profile) { | ||
@@ -876,16 +940,20 @@ object.profile = factory.create(`${type}.profile`, profile, context); | ||
ids: (object, module) => { | ||
object.id = module.id; | ||
object.issuerId = module.issuerId; | ||
object.chunks = module.chunks; | ||
const { commonAttributes } = module; | ||
if (commonAttributes.moduleDescriptor) { | ||
object.id = commonAttributes.moduleDescriptor.id; | ||
} | ||
object.issuerId = module.issuerDescriptor?.id; | ||
object.chunks = commonAttributes.chunks; | ||
}, | ||
moduleAssets: (object, module) => { | ||
object.assets = module.assets; | ||
object.assets = module.commonAttributes.assets; | ||
}, | ||
reasons: (object, module, context, options, factory) => { | ||
const { type } = context; | ||
object.reasons = factory.create(`${type.slice(0, -8)}.reasons`, module.reasons, context); | ||
object.reasons = factory.create(`${type.slice(0, -8)}.reasons`, module.commonAttributes.reasons, context); | ||
// object.filteredReasons | ||
}, | ||
source: (object, module) => { | ||
object.source = module.source; | ||
const { commonAttributes } = module; | ||
object.source = commonAttributes.source; | ||
}, | ||
@@ -909,4 +977,5 @@ usedExports: (object, module) => { | ||
providedExports: (object, module) => { | ||
if (Array.isArray(module.providedExports)) { | ||
object.providedExports = module.providedExports; | ||
const { commonAttributes } = module; | ||
if (Array.isArray(commonAttributes.providedExports)) { | ||
object.providedExports = commonAttributes.providedExports; | ||
} | ||
@@ -918,6 +987,7 @@ else { | ||
optimizationBailout: (object, module) => { | ||
object.optimizationBailout = module.optimizationBailout || null; | ||
object.optimizationBailout = | ||
module.commonAttributes.optimizationBailout || null; | ||
}, | ||
depth: (object, module) => { | ||
object.depth = module.depth; | ||
object.depth = module.commonAttributes.depth; | ||
}, | ||
@@ -950,7 +1020,9 @@ nestedModules: (object, module, context, options, factory) => { | ||
_: (object, module, context, options, factory) => { | ||
object.identifier = module.identifier; | ||
object.name = module.name; | ||
if (module.moduleDescriptor) { | ||
object.identifier = module.moduleDescriptor.identifier; | ||
object.name = module.moduleDescriptor.name; | ||
} | ||
}, | ||
ids: (object, module) => { | ||
object.id = module.id; | ||
object.id = module.moduleDescriptor.id; | ||
} | ||
@@ -960,4 +1032,6 @@ }, | ||
_: (object, reason) => { | ||
object.moduleIdentifier = reason.moduleIdentifier; | ||
object.moduleName = reason.moduleName; | ||
if (reason.moduleDescriptor) { | ||
object.moduleIdentifier = reason.moduleDescriptor.identifier; | ||
object.moduleName = reason.moduleDescriptor.name; | ||
} | ||
object.type = reason.type; | ||
@@ -967,3 +1041,5 @@ object.userRequest = reason.userRequest; | ||
ids: (object, reason) => { | ||
object.moduleId = reason.moduleId; | ||
object.moduleId = reason.moduleDescriptor | ||
? reason.moduleDescriptor.id | ||
: null; | ||
} | ||
@@ -1001,3 +1077,14 @@ }, | ||
chunkOrigins: (object, chunk, context, options, factory) => { | ||
object.origins = chunk.origins; | ||
object.origins = chunk.origins.map(origin => { | ||
const { moduleDescriptor, loc, request } = origin; | ||
const statsChunkOrigin = { | ||
module: moduleDescriptor ? moduleDescriptor.identifier : "", | ||
moduleIdentifier: moduleDescriptor ? moduleDescriptor.identifier : "", | ||
moduleName: moduleDescriptor ? moduleDescriptor.name : "", | ||
moduleId: moduleDescriptor ? moduleDescriptor.id : undefined, | ||
loc, | ||
request | ||
}; | ||
return statsChunkOrigin; | ||
}); | ||
} | ||
@@ -1010,10 +1097,14 @@ }, | ||
_: (object, { origin, module }, context, { requestShortener }, factory) => { | ||
object.originIdentifier = origin.identifier; | ||
object.originName = origin.name; | ||
object.moduleIdentifier = module.identifier; | ||
object.moduleName = module.name; | ||
if (origin.moduleDescriptor) { | ||
object.originIdentifier = origin.moduleDescriptor.identifier; | ||
object.originName = origin.moduleDescriptor.name; | ||
} | ||
if (module.moduleDescriptor) { | ||
object.moduleIdentifier = module.moduleDescriptor.identifier; | ||
object.moduleName = module.moduleDescriptor.name; | ||
} | ||
}, | ||
ids: (object, { origin, module }) => { | ||
object.originId = origin.id; | ||
object.moduleId = module.id; | ||
object.originId = origin.moduleDescriptor.id; | ||
object.moduleId = module.moduleDescriptor.id; | ||
} | ||
@@ -1020,0 +1111,0 @@ } |
@@ -197,4 +197,3 @@ "use strict"; | ||
: all !== false, | ||
// cachedModules: ({ all, cached }, { forToString }) => | ||
// cached !== undefined ? cached : forToString ? all === true : all !== false, | ||
cachedModules: ({ all, cached }, { forToString }) => cached !== undefined ? cached : forToString ? all === true : all !== false, | ||
moduleAssets: OFF_FOR_TO_STRING, | ||
@@ -201,0 +200,0 @@ depth: OFF_FOR_TO_STRING, |
@@ -209,3 +209,3 @@ "use strict"; | ||
"module.cached": (cached, { formatFlag, green }) => cached ? green(formatFlag("cached")) : undefined, | ||
"module.assets": (assets, { formatFlag, magenta }) => assets && assets.length | ||
"module.assets": (assets, { formatFlag, magenta }) => assets?.length | ||
? magenta(formatFlag(`${assets.length} ${plural(assets.length, "asset", "assets")}`)) | ||
@@ -704,3 +704,3 @@ : undefined, | ||
const indent = (str, prefix, noPrefixInFirstLine) => { | ||
const rem = str.replace(/\n([^\n])/g, "\n" + prefix + "$1"); | ||
const rem = str.replace(/\n([^\n])/g, `\n${prefix}$1`); | ||
if (noPrefixInFirstLine) | ||
@@ -727,3 +727,3 @@ return rem; | ||
firstInLine = content.endsWith("\n"); | ||
return noJoiner ? content : " " + content; | ||
return noJoiner ? content : ` ${content}`; | ||
}) | ||
@@ -809,16 +809,15 @@ .filter(Boolean) | ||
let hasEntry = false; | ||
return ("chunk " + | ||
joinExplicitNewLine(items.filter(item => { | ||
switch (item.element) { | ||
case "entry": | ||
if (item.content) | ||
hasEntry = true; | ||
break; | ||
case "initial": | ||
if (hasEntry) | ||
return false; | ||
break; | ||
} | ||
return true; | ||
}), " ")); | ||
return `chunk ${joinExplicitNewLine(items.filter(item => { | ||
switch (item.element) { | ||
case "entry": | ||
if (item.content) | ||
hasEntry = true; | ||
break; | ||
case "initial": | ||
if (hasEntry) | ||
return false; | ||
break; | ||
} | ||
return true; | ||
}), " ")}`; | ||
}, | ||
@@ -863,7 +862,7 @@ "chunk.childrenByOrder[]": items => `(${joinOneLine(items)})`, | ||
moduleIssuer: joinOneLine, | ||
chunkOrigin: items => "> " + joinOneLine(items), | ||
chunkOrigin: items => `> ${joinOneLine(items)}`, | ||
"errors[].error": joinError(true), | ||
"warnings[].error": joinError(false), | ||
loggingGroup: items => joinExplicitNewLine(items, "").trimEnd(), | ||
moduleTraceItem: items => " @ " + joinOneLine(items), | ||
moduleTraceItem: items => ` @ ${joinOneLine(items)}`, | ||
moduleTraceDependency: joinOneLine | ||
@@ -870,0 +869,0 @@ }; |
@@ -10,3 +10,3 @@ /** | ||
*/ | ||
import type { JsStats, JsStatsError, JsStatsWarning } from "@rspack/binding"; | ||
import type { JsStats, JsStatsCompilation, JsStatsError, JsStatsWarning } from "@rspack/binding"; | ||
import { HookMap, SyncBailHook, SyncWaterfallHook } from "@rspack/lite-tapable"; | ||
@@ -21,2 +21,3 @@ import type { Compilation } from "../Compilation"; | ||
cachedGetWarnings?: ((arg0: Compilation) => JsStatsWarning[]) | undefined; | ||
getStatsCompilation: (compilation: Compilation) => JsStatsCompilation; | ||
getInner: (compilation: Compilation) => JsStats; | ||
@@ -23,0 +24,0 @@ }; |
@@ -124,5 +124,3 @@ "use strict"; | ||
if (comparators.length > 0) { | ||
items.sort( | ||
// @ts-expect-error number of arguments is correct | ||
(0, comparators_1.concatComparators)(...comparators)); | ||
items.sort((0, comparators_1.concatComparators)(...comparators)); | ||
} | ||
@@ -151,5 +149,3 @@ // run filter on sorted items | ||
if (comparators2.length > 0) { | ||
resultItems.sort( | ||
// @ts-expect-error number of arguments is correct | ||
(0, comparators_1.concatComparators)(...comparators2)); | ||
resultItems.sort((0, comparators_1.concatComparators)(...comparators2)); | ||
} | ||
@@ -156,0 +152,0 @@ // group result items |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import type * as binding from "@rspack/binding"; | ||
@@ -5,8 +6,6 @@ import type { Compilation, NormalizedStatsOptions } from "../Compilation"; | ||
import type { StatsFactory, StatsFactoryContext } from "./StatsFactory"; | ||
type Writable<T> = { | ||
-readonly [K in keyof T]: T[K]; | ||
}; | ||
export type KnownStatsChunkGroup = binding.JsStatsChunkGroup; | ||
export type KnownStatsChunk = Omit<Writable<binding.JsStatsChunk>, "sizes"> & { | ||
export type KnownStatsChunk = Omit<binding.JsStatsChunk, "sizes" | "origins"> & { | ||
sizes: Record<string, number>; | ||
origins: StatsChunkOrigin[]; | ||
}; | ||
@@ -18,10 +17,42 @@ export type KnownStatsAssetInfo = Omit<binding.JsStatsAssetInfo, "related">; | ||
export type StatsChunk = KnownStatsChunk & Record<string, any>; | ||
export type KnownStatsModule = Omit<Writable<binding.JsStatsModule>, "usedExports" | "providedExports" | "optimizationBailout" | "sizes"> & { | ||
profile?: StatsProfile; | ||
usedExports?: null | string[] | boolean; | ||
providedExports?: null | string[]; | ||
optimizationBailout?: null | string[]; | ||
sizes: Record<string, number>; | ||
export type KnownStatsModule = { | ||
type: string; | ||
moduleType: string; | ||
layer?: string; | ||
identifier?: string; | ||
name?: string; | ||
nameForCondition?: string; | ||
index?: number; | ||
index2?: number; | ||
preOrderIndex?: number; | ||
postOrderIndex?: number; | ||
size: number; | ||
sizes: Record<string, number>; | ||
cacheable?: boolean; | ||
built: boolean; | ||
codeGenerated: boolean; | ||
buildTimeExecuted: boolean; | ||
cached: boolean; | ||
optional?: boolean; | ||
orphan?: boolean; | ||
id?: string; | ||
issuerId?: string; | ||
chunks?: string[]; | ||
assets?: string[]; | ||
dependent?: boolean; | ||
issuer?: string; | ||
issuerName?: string; | ||
issuerPath?: StatsModuleIssuer[]; | ||
failed?: boolean; | ||
errors?: number; | ||
warnings?: number; | ||
profile?: StatsProfile; | ||
reasons?: StatsModuleReason[]; | ||
usedExports?: boolean | string[] | null; | ||
providedExports?: string[] | null; | ||
optimizationBailout?: string[] | null; | ||
depth?: number; | ||
modules?: StatsModule[]; | ||
filteredModules?: number; | ||
source?: string | Buffer; | ||
}; | ||
@@ -35,5 +66,11 @@ export type StatsProfile = KnownStatsProfile & Record<string, any>; | ||
export type StatsModule = KnownStatsModule & Record<string, any>; | ||
export type StatsModuleIssuer = binding.JsStatsModuleIssuer & Record<string, any>; | ||
export type StatsError = binding.JsStatsError & Record<string, any>; | ||
export type StatsWarnings = binding.JsStatsWarning & Record<string, any>; | ||
export type StatsModuleIssuer = Omit<binding.JsStatsModuleIssuer, "identifier"> & { | ||
identifier?: string; | ||
} & Record<string, any>; | ||
export type StatsError = Omit<binding.JsStatsError, "moduleIdentifier"> & { | ||
moduleIdentifier?: string; | ||
} & Record<string, any>; | ||
export type StatsWarnings = Omit<binding.JsStatsWarning, "moduleIdentifier"> & { | ||
moduleIdentifier?: string; | ||
} & Record<string, any>; | ||
export type StatsModuleTraceItem = { | ||
@@ -47,3 +84,14 @@ originIdentifier?: string; | ||
}; | ||
export type StatsModuleReason = Writable<binding.JsStatsModuleReason> & Record<string, any>; | ||
export type StatsModuleReason = Omit<binding.JsStatsModuleReason, "moduleIdentifier"> & { | ||
moduleIdentifier?: string; | ||
} & Record<string, any>; | ||
export type KnownStatsChunkOrigin = { | ||
module: string; | ||
moduleIdentifier: string; | ||
moduleName: string; | ||
loc: string; | ||
request: string; | ||
moduleId?: string; | ||
}; | ||
export type StatsChunkOrigin = KnownStatsChunkOrigin & Record<string, any>; | ||
export type KnownStatsCompilation = { | ||
@@ -93,10 +141,2 @@ /** | ||
}; | ||
export type KnownStatsChunkOrigin = { | ||
module?: string | undefined; | ||
moduleIdentifier?: string | undefined; | ||
moduleName?: string | undefined; | ||
loc?: string | undefined; | ||
request?: string | undefined; | ||
moduleId?: (string | number) | undefined; | ||
}; | ||
type ExtractorsByOption<T, O> = { | ||
@@ -125,3 +165,3 @@ [x: string]: (object: O, data: T, context: StatsFactoryContext, options: any, factory: StatsFactory) => void; | ||
error: ExtractorsByOption<binding.JsStatsError, StatsError>; | ||
warning: ExtractorsByOption<binding.JsStatsWarning, StatsError>; | ||
warning: ExtractorsByOption<binding.JsStatsWarning, StatsWarnings>; | ||
moduleTraceItem: ExtractorsByOption<binding.JsStatsModuleTrace, StatsModuleTraceItem>; | ||
@@ -128,0 +168,0 @@ }; |
@@ -159,3 +159,3 @@ "use strict"; | ||
const ind = str[0] === "\n" ? "" : prefix; | ||
return ind + str.replace(/\n([^\n])/g, "\n" + prefix + "$1"); | ||
return ind + str.replace(/\n([^\n])/g, `\n${prefix}$1`); | ||
} | ||
@@ -190,3 +190,3 @@ /** | ||
} | ||
if (minId < 16 + ("" + minId).length) { | ||
if (minId < 16 + `${minId}`.length) { | ||
// add minId x ',' instead of 'Array(minId).concat(…)' | ||
@@ -193,0 +193,0 @@ minId = 0; |
@@ -67,8 +67,8 @@ "use strict"; | ||
return new Error(`unsupported cpu arch: ${arch}`); | ||
binding += "-" + arch; | ||
binding += `-${arch}`; | ||
if (typeof abi === "string") { | ||
binding += abi.length ? "-" + abi : ""; | ||
binding += abi.length ? `-${abi}` : ""; | ||
} | ||
else if (typeof abi === "object") { | ||
binding += "-" + abi[isMusl() ? "musl" : "gnu"]; | ||
binding += `-${abi[isMusl() ? "musl" : "gnu"]}`; | ||
} | ||
@@ -75,0 +75,0 @@ else { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resolveByProperty = exports.removeOperations = exports.cleverMerge = exports.cachedSetProperty = exports.cachedCleverMerge = exports.DELETE = void 0; | ||
const DYNAMIC_INFO = Symbol("cleverMerge dynamic info"); | ||
const mergeCache = new WeakMap(); | ||
const setPropertyCache = new WeakMap(); | ||
exports.DELETE = Symbol("DELETE"); | ||
const DYNAMIC_INFO = Symbol("cleverMerge dynamic info"); | ||
/** | ||
@@ -302,3 +302,3 @@ * Merges two given objects and caches the result to avoid computation if same objects passed as arguments again. | ||
return secondEntry; | ||
case VALUE_TYPE_UNDEFINED: | ||
case VALUE_TYPE_UNDEFINED: { | ||
if (!firstEntry.byProperty) { | ||
@@ -327,2 +327,3 @@ // = first.base + second.byProperty | ||
}; | ||
} | ||
default: { | ||
@@ -329,0 +330,0 @@ if (!firstEntry.byProperty) { |
@@ -14,3 +14,3 @@ /** | ||
type Selector<A, B> = (input: A) => B; | ||
export declare const concatComparators: (c1: Comparator, c2: Comparator, ...cRest: Comparator[]) => Comparator; | ||
export declare const concatComparators: (...comps: Array<Comparator>) => Comparator; | ||
export declare const compareIds: (a: string | number, b: string | number) => -1 | 0 | 1; | ||
@@ -17,0 +17,0 @@ export declare const compareChunksById: (a: Chunk, b: Chunk) => -1 | 0 | 1; |
@@ -34,3 +34,7 @@ "use strict"; | ||
const concatComparatorsCache = new TwoKeyWeakMap(); | ||
const concatComparators = (c1, c2, ...cRest) => { | ||
const concatComparators = (...comps) => { | ||
const [c1, c2, ...cRest] = comps; | ||
if (c2 === undefined) { | ||
return c1; | ||
} | ||
if (cRest.length > 0) { | ||
@@ -40,5 +44,2 @@ const [c3, ...cRest2] = cRest; | ||
} | ||
if (c2 === undefined) { | ||
return c1; | ||
} | ||
const cacheEntry = concatComparatorsCache.get(c1, c2); | ||
@@ -45,0 +46,0 @@ if (cacheEntry !== undefined) |
@@ -130,3 +130,3 @@ "use strict"; | ||
digest(encoding) { | ||
return ("debug-digest-" + Buffer.from(this.string).toString(encoding || "hex")); | ||
return `debug-digest-${Buffer.from(this.string).toString(encoding || "hex")}`; | ||
} | ||
@@ -133,0 +133,0 @@ } |
@@ -59,3 +59,3 @@ "use strict"; | ||
const join = (fs, rootPath, filename) => { | ||
if (fs && fs.join) { | ||
if (fs?.join) { | ||
return fs.join(rootPath, filename); | ||
@@ -72,3 +72,3 @@ } | ||
const dirname = (fs, absPath) => { | ||
if (fs && fs.dirname) { | ||
if (fs?.dirname) { | ||
return fs.dirname(absPath); | ||
@@ -75,0 +75,0 @@ } |
@@ -315,4 +315,4 @@ "use strict"; | ||
if (pos < 0) | ||
return outputPath + "/"; | ||
append = outputPath.slice(pos + 1) + "/" + append; | ||
return `${outputPath}/`; | ||
append = `${outputPath.slice(pos + 1)}/${append}`; | ||
outputPath = outputPath.slice(0, pos); | ||
@@ -319,0 +319,0 @@ } |
@@ -76,3 +76,3 @@ "use strict"; | ||
function indent(str, prefix) { | ||
const rem = str.replace(/\n([^\n])/g, "\n" + prefix + "$1"); | ||
const rem = str.replace(/\n([^\n])/g, `\n${prefix}$1`); | ||
return prefix + rem; | ||
@@ -79,0 +79,0 @@ } |
@@ -6,7 +6,5 @@ "use strict"; | ||
let cache = false; | ||
// @ts-expect-error | ||
let result = undefined; | ||
let result; | ||
return () => { | ||
if (cache) { | ||
// @ts-expect-error | ||
return result; | ||
@@ -18,3 +16,2 @@ } | ||
// and all dependent resources | ||
// @ts-expect-error | ||
fn = undefined; | ||
@@ -21,0 +18,0 @@ return result; |
@@ -22,4 +22,4 @@ "use strict"; | ||
const index = Math.floor(Math.log(size) / Math.log(1024)); | ||
return `${+(size / Math.pow(1024, index)).toPrecision(3)} ${abbreviations[index]}`; | ||
return `${+(size / 1024 ** index).toPrecision(3)} ${abbreviations[index]}`; | ||
}; | ||
exports.formatSize = formatSize; |
@@ -81,9 +81,7 @@ "use strict"; | ||
state.options = options = | ||
(groupConfig.getOptions && | ||
groupConfig.getOptions(group.name, Array.from(items, ({ item }) => item))) || | ||
false; | ||
groupConfig.getOptions?.(group.name, Array.from(items, ({ item }) => item)) || false; | ||
} | ||
const force = options && options.force; | ||
const force = options !== false && options.force; | ||
if (!force) { | ||
if (bestGroupOptions && bestGroupOptions.force) | ||
if (bestGroupOptions !== false && bestGroupOptions?.force) | ||
continue; | ||
@@ -96,3 +94,3 @@ if (used) | ||
} | ||
const targetGroupCount = (options && options.targetGroupCount) || 4; | ||
const targetGroupCount = (options !== false && options.targetGroupCount) || 4; | ||
const sizeValue = force | ||
@@ -99,0 +97,0 @@ ? items.size |
declare const _default: { | ||
readonly createHash: any; | ||
readonly createHash: (algorithm: (string & {}) | "debug" | "xxhash64" | "md4" | "native-md4" | (new () => import("./hash").default)) => import("./hash").default; | ||
}; | ||
export default _default; |
@@ -7,5 +7,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const createHash_1 = require("./createHash"); | ||
exports.default = { | ||
get createHash() { | ||
return require("./createHash"); | ||
return createHash_1.createHash; | ||
} | ||
@@ -12,0 +13,0 @@ // get comparators() { |
@@ -112,3 +112,3 @@ /** | ||
const enum HotUpdateStatus { | ||
enum HotUpdateStatus { | ||
idle = "idle", | ||
@@ -115,0 +115,0 @@ check = "check", |
{ | ||
"name": "@rspack/core", | ||
"version": "1.0.0-beta.1", | ||
"version": "1.0.0-beta.2", | ||
"webpackVersion": "5.75.0", | ||
@@ -62,4 +62,4 @@ "license": "MIT", | ||
"caniuse-lite": "^1.0.30001616", | ||
"@rspack/lite-tapable": "1.0.0-beta.1", | ||
"@rspack/binding": "1.0.0-beta.1" | ||
"@rspack/lite-tapable": "1.0.0-beta.2", | ||
"@rspack/binding": "1.0.0-beta.2" | ||
}, | ||
@@ -66,0 +66,0 @@ "peerDependencies": { |
Sorry, the diff of this file is too big to display
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
2492228
427
61631
+ Added@rspack/binding@1.0.0-beta.2(transitive)
+ Added@rspack/binding-darwin-arm64@1.0.0-beta.2(transitive)
+ Added@rspack/binding-darwin-x64@1.0.0-beta.2(transitive)
+ Added@rspack/binding-linux-arm64-gnu@1.0.0-beta.2(transitive)
+ Added@rspack/binding-linux-arm64-musl@1.0.0-beta.2(transitive)
+ Added@rspack/binding-linux-x64-gnu@1.0.0-beta.2(transitive)
+ Added@rspack/binding-linux-x64-musl@1.0.0-beta.2(transitive)
+ Added@rspack/binding-win32-arm64-msvc@1.0.0-beta.2(transitive)
+ Added@rspack/binding-win32-ia32-msvc@1.0.0-beta.2(transitive)
+ Added@rspack/binding-win32-x64-msvc@1.0.0-beta.2(transitive)
+ Added@rspack/lite-tapable@1.0.0-beta.2(transitive)
- Removed@rspack/binding@1.0.0-beta.1(transitive)
- Removed@rspack/binding-darwin-arm64@1.0.0-beta.1(transitive)
- Removed@rspack/binding-darwin-x64@1.0.0-beta.1(transitive)
- Removed@rspack/binding-linux-arm64-gnu@1.0.0-beta.1(transitive)
- Removed@rspack/binding-linux-arm64-musl@1.0.0-beta.1(transitive)
- Removed@rspack/binding-linux-x64-gnu@1.0.0-beta.1(transitive)
- Removed@rspack/binding-linux-x64-musl@1.0.0-beta.1(transitive)
- Removed@rspack/binding-win32-arm64-msvc@1.0.0-beta.1(transitive)
- Removed@rspack/binding-win32-ia32-msvc@1.0.0-beta.1(transitive)
- Removed@rspack/binding-win32-x64-msvc@1.0.0-beta.1(transitive)
- Removed@rspack/lite-tapable@1.0.0-beta.1(transitive)
Updated@rspack/binding@1.0.0-beta.2