@statoscope/webpack-model
Advanced tools
Comparing version 5.20.1 to 5.22.0
@@ -147,11 +147,15 @@ "use strict"; | ||
normalized.modules.push(module); | ||
processingContext.fileContext.indexes.compilation.byModule.set(module, normalized); | ||
} | ||
for (const chunk of processingContext.indexes.chunks.getAll()) { | ||
normalized.chunks.push(chunk); | ||
processingContext.fileContext.indexes.compilation.byChunks.set(chunk, normalized); | ||
} | ||
for (const asset of processingContext.indexes.assets.getAll()) { | ||
normalized.assets.push(asset); | ||
processingContext.fileContext.indexes.compilation.byAsset.set(asset, normalized); | ||
} | ||
for (const entry of processingContext.indexes.entrypoints.getAll()) { | ||
normalized.entrypoints.push(entry); | ||
processingContext.fileContext.indexes.compilation.byEntrypoint.set(entry, normalized); | ||
} | ||
@@ -302,2 +306,3 @@ const graph = buildGraph(normalized); | ||
normalizedChunk.files = chunk.files | ||
.filter(Boolean) // to skip null files, issue #158 | ||
.map((f) => context.rawIndexes.assets.get(typeof f === 'string' ? f : f.name)) | ||
@@ -304,0 +309,0 @@ .filter(Boolean); |
@@ -69,5 +69,15 @@ "use strict"; | ||
extensions: (0, indexer_1.default)((ext) => ext.data.descriptor.name, extensions), | ||
compilation: { | ||
byAsset: new WeakMap(), | ||
byChunks: new WeakMap(), | ||
byModule: new WeakMap(), | ||
byEntrypoint: new WeakMap(), | ||
}, | ||
}; | ||
const resolvers = { | ||
resolveExtension: (id) => indexes.extensions.get(id), | ||
resolveCompilationByAsset: (asset) => indexes.compilation.byAsset.get(asset), | ||
resolveCompilationByChunk: (chunk) => indexes.compilation.byChunks.get(chunk), | ||
resolveCompilationByModule: (module) => indexes.compilation.byModule.get(module), | ||
resolveCompilationByEntrypoint: (entrypoint) => indexes.compilation.byEntrypoint.get(entrypoint), | ||
}; | ||
@@ -74,0 +84,0 @@ const compilations = (0, handleCompilation_1.default)(rawStatsFileDescriptor, file, { |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -38,3 +42,8 @@ if (k2 === undefined) k2 = k; | ||
const prepared = (0, jora_1.prepareWithJora)(files, { | ||
helpers: { ...(0, jora_helpers_1.default)(normalizeResult), ...options.helpers }, | ||
helpers: { | ||
...(0, jora_helpers_1.default)(normalizeResult, { | ||
query: (request, input, context) => prepared.query(request, input, context), | ||
}), | ||
...options.helpers, | ||
}, | ||
}); | ||
@@ -41,0 +50,0 @@ return { |
@@ -5,3 +5,3 @@ import type { Size } from '@statoscope/stats-extension-compressed/dist/generator'; | ||
import type { Item } from '@statoscope/stats-extension-stats-validation-result/dist/generator'; | ||
import { RelationItem } from '@statoscope/types/types'; | ||
import { HelpersContext, RelationItem } from '@statoscope/types/types'; | ||
import { RuleDescriptor } from '@statoscope/types/types/validation/api'; | ||
@@ -40,7 +40,11 @@ import { Report } from '@statoscope/types/types/custom-report'; | ||
}; | ||
export default function (normalizeResult: NormalizeResult): { | ||
export default function (normalizeResult: NormalizeResult, context: HelpersContext): { | ||
moduleSize(module: NormalizedModule): number; | ||
chunkName(chunk: NormalizedChunk): string; | ||
assetChunkName(asset: NormalizedAsset): string | null; | ||
getTotalFilesSize: (asset: NormalizedAsset, hash?: string | undefined, compressed?: boolean | undefined) => number; | ||
getTotalFilesSize: (asset: NormalizedAsset, hash?: string, compressed?: boolean) => number; | ||
resolveCompilationByAsset(asset: NormalizedAsset, fileName: string): NormalizedCompilation | null; | ||
resolveCompilationByChunk(chunk: NormalizedChunk, fileName: string): NormalizedCompilation | null; | ||
resolveCompilationByModule(module: NormalizedModule, fileName: string): NormalizedCompilation | null; | ||
resolveCompilationByEntrypoint(entrypoint: NormalizedEntrypointItem, fileName: string): NormalizedCompilation | null; | ||
resolveChunk(id: ChunkID, compilationHash: string): NormalizedChunk | null; | ||
@@ -58,4 +62,4 @@ resolveAsset(id: string, compilationHash: string): NormalizedAsset | null; | ||
resolveExtensionByCompilation(id: string, hash: string): NormalizedExtension<unknown, unknown> | null; | ||
getModuleSize(module: NormalizedModule, hash?: string | undefined, compressed?: boolean | undefined): Size; | ||
getAssetSize(asset: NormalizedAsset, hash?: string | undefined, compressed?: boolean | undefined): Size; | ||
getModuleSize(module: NormalizedModule, hash?: string, compressed?: boolean): Size; | ||
getAssetSize(asset: NormalizedAsset, hash?: string, compressed?: boolean): Size; | ||
getPackageInstanceInfo(packageName: string, instancePath: string, hash: string): Instance | null; | ||
@@ -66,13 +70,23 @@ moduleResource: typeof moduleResource; | ||
nodeModule: typeof nodeModule; | ||
statName(stat?: ResolvedStats | undefined): string; | ||
statName(stat?: ResolvedStats): string; | ||
getModuleGraph(hash: string): Graph<ModuleGraphNodeData> | null; | ||
moduleGraph_getEntrypoints(module?: NormalizedModule | null | undefined, graph?: Graph<ModuleGraphNodeData> | undefined, entrypoints?: NormalizedEntrypointItem[] | undefined, max?: number): NormalizedEntrypointItem[]; | ||
moduleGraph_getPaths(from?: NormalizedModule | undefined, graph?: Graph<ModuleGraphNodeData> | undefined, to?: NormalizedModule | undefined, max?: number): PathSolution<ModuleGraphNodeData> | null; | ||
modulesToFoamTree(modules: NormalizedModule[], hash?: string | undefined, compressed?: boolean | undefined): FoamTreeNode; | ||
validation_getItems(hash?: string | undefined, relatedType?: "module" | "chunk" | "resource" | "entry" | "compilation" | "package" | "package-instance" | null | undefined, relatedId?: string | number | undefined): Item[]; | ||
validation_getItem(id?: number | undefined, hash?: string | undefined): Item | null; | ||
validation_resolveRelatedItem(item?: RelationItem | undefined, hash?: string | undefined): ResolvedRelatedItem; | ||
validation_resolveRule(name?: string | undefined, hash?: string | undefined): RuleDescriptor | null; | ||
customReports_getItems(file: string, hash?: string | null | undefined, relatedType?: "module" | "chunk" | "resource" | "entry" | "compilation" | "package" | "package-instance" | null | undefined, relatedId?: string | number | undefined): Report<unknown, unknown>[]; | ||
moduleGraph_getEntrypoints(module?: NormalizedModule | null, graph?: Graph<ModuleGraphNodeData>, entrypoints?: NormalizedEntrypointItem[], max?: number): NormalizedEntrypointItem[]; | ||
moduleGraph_getPaths(from?: NormalizedModule, graph?: Graph<ModuleGraphNodeData>, to?: NormalizedModule, max?: number): PathSolution<ModuleGraphNodeData> | null; | ||
modulesToFoamTree(modules: NormalizedModule[], hash?: string, compressed?: boolean): FoamTreeNode; | ||
validation_getItems(hash?: string, relatedType?: RelationItem['type'] | null, relatedId?: string | number): Item[]; | ||
validation_getItem(id?: number, hash?: string): Item | null; | ||
validation_resolveRelatedItem(item?: RelationItem, hash?: string): ResolvedRelatedItem; | ||
validation_resolveRule(name?: string, hash?: string): RuleDescriptor | null; | ||
customReports_getItems(file: string, hash?: string | null, relatedType?: RelationItem['type'] | null, relatedId?: string | number): Report<unknown, unknown>[]; | ||
customReports_getItem(id: string, file: string): Report<unknown, unknown> | null; | ||
asset_getSize(asset: NormalizedAsset, hash: string, useCompressedSize: boolean): Size; | ||
assets_getTotalSize(assets: NormalizedAsset[], hash: string, useCompressedSize: boolean): Size; | ||
entrypoint_getChunks(entrypoint: NormalizedEntrypointItem): NormalizedChunk[]; | ||
entrypoint_getInitialChunks(entrypoint: NormalizedEntrypointItem): NormalizedChunk[]; | ||
entrypoint_getInitialSize(entrypoint: NormalizedEntrypointItem, hash: string, useCompressedSize: boolean): Size; | ||
entrypoint_getAsyncChunks(entrypoint: NormalizedEntrypointItem): NormalizedChunk[]; | ||
entrypoint_getAsyncSize(entrypoint: NormalizedEntrypointItem, hash: string, useCompressedSize: boolean): Size; | ||
entrypoint_getAssets(entrypoint: NormalizedEntrypointItem): NormalizedAsset[]; | ||
entrypoint_getInitialAssets(entrypoint: NormalizedEntrypointItem): NormalizedAsset[]; | ||
entrypoint_getAsyncAssets(entrypoint: NormalizedEntrypointItem): NormalizedAsset[]; | ||
}; |
@@ -10,3 +10,3 @@ "use strict"; | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type | ||
function default_1(normalizeResult) { | ||
function default_1(normalizeResult, context) { | ||
const compilations = normalizeResult.compilations; | ||
@@ -58,2 +58,19 @@ const resolveCompilation = (0, entity_resolver_1.default)(compilations, (item) => { var _a; return (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.hash; }); | ||
}, | ||
resolveCompilationByAsset(asset, fileName) { | ||
var _a, _b; | ||
return ((_b = (_a = normalizeResult.resolvers.get(fileName)) === null || _a === void 0 ? void 0 : _a.resolveCompilationByAsset(asset)) !== null && _b !== void 0 ? _b : null); | ||
}, | ||
resolveCompilationByChunk(chunk, fileName) { | ||
var _a, _b; | ||
return ((_b = (_a = normalizeResult.resolvers.get(fileName)) === null || _a === void 0 ? void 0 : _a.resolveCompilationByChunk(chunk)) !== null && _b !== void 0 ? _b : null); | ||
}, | ||
resolveCompilationByModule(module, fileName) { | ||
var _a, _b; | ||
return ((_b = (_a = normalizeResult.resolvers.get(fileName)) === null || _a === void 0 ? void 0 : _a.resolveCompilationByModule(module)) !== null && _b !== void 0 ? _b : null); | ||
}, | ||
resolveCompilationByEntrypoint(entrypoint, fileName) { | ||
var _a, _b; | ||
return ((_b = (_a = normalizeResult.resolvers | ||
.get(fileName)) === null || _a === void 0 ? void 0 : _a.resolveCompilationByEntrypoint(entrypoint)) !== null && _b !== void 0 ? _b : null); | ||
}, | ||
resolveChunk(id, compilationHash) { | ||
@@ -324,2 +341,42 @@ var _a; | ||
}, | ||
asset_getSize(asset, hash, useCompressedSize) { | ||
return this.getAssetSize(asset, hash, useCompressedSize); | ||
}, | ||
assets_getTotalSize(assets, hash, useCompressedSize) { | ||
return context.query(` | ||
$hash: #.hash; | ||
$useCompressedSize: #.useCompressedSize; | ||
.[not name.shouldExcludeResource()].[] | ||
.(asset_getSize($hash, $useCompressedSize)) | | ||
$ ? .reduce(=> { | ||
$current: $; | ||
$all: $$; | ||
size: $all.size + $current.size, | ||
compressor: $all.compressor = $current.compressor ? $all.compressor : 'multiple' | ||
}) : {size: 0}`, assets, { useCompressedSize, hash }); | ||
}, | ||
entrypoint_getChunks(entrypoint) { | ||
return context.query(`data.chunks + data.chunks..children`, entrypoint); | ||
}, | ||
entrypoint_getInitialChunks(entrypoint) { | ||
return this.entrypoint_getChunks(entrypoint).filter((chunk) => chunk.initial); | ||
}, | ||
entrypoint_getInitialSize(entrypoint, hash, useCompressedSize) { | ||
return this.assets_getTotalSize(this.entrypoint_getInitialAssets(entrypoint), hash, useCompressedSize); | ||
}, | ||
entrypoint_getAsyncChunks(entrypoint) { | ||
return this.entrypoint_getChunks(entrypoint).filter((chunk) => !chunk.initial); | ||
}, | ||
entrypoint_getAsyncSize(entrypoint, hash, useCompressedSize) { | ||
return this.assets_getTotalSize(this.entrypoint_getAsyncAssets(entrypoint), hash, useCompressedSize); | ||
}, | ||
entrypoint_getAssets(entrypoint) { | ||
return context.query(`(data.chunks + data.chunks..children).files`, entrypoint); | ||
}, | ||
entrypoint_getInitialAssets(entrypoint) { | ||
return context.query(`(data.chunks + data.chunks..children).[initial].files`, entrypoint); | ||
}, | ||
entrypoint_getAsyncAssets(entrypoint) { | ||
return context.query(`(data.chunks + data.chunks..children).[not initial].files`, entrypoint); | ||
}, | ||
}; | ||
@@ -326,0 +383,0 @@ } |
{ | ||
"name": "@statoscope/webpack-model", | ||
"version": "5.20.1", | ||
"version": "5.22.0", | ||
"description": "This package contains helpers to process webpack stats", | ||
@@ -22,10 +22,10 @@ "main": "./dist/index.js", | ||
"@statoscope/extensions": "5.14.1", | ||
"@statoscope/helpers": "5.19.0", | ||
"@statoscope/helpers": "5.22.0", | ||
"@statoscope/stats": "5.14.1", | ||
"@statoscope/stats-extension-compressed": "5.19.0", | ||
"@statoscope/stats-extension-custom-reports": "5.19.0", | ||
"@statoscope/stats-extension-package-info": "5.19.3", | ||
"@statoscope/stats-extension-stats-validation-result": "5.19.0", | ||
"@statoscope/types": "5.14.1", | ||
"ajv": "^8.6.3", | ||
"@statoscope/stats-extension-compressed": "5.22.0", | ||
"@statoscope/stats-extension-custom-reports": "5.22.0", | ||
"@statoscope/stats-extension-package-info": "5.22.0", | ||
"@statoscope/stats-extension-stats-validation-result": "5.22.0", | ||
"@statoscope/types": "5.22.0", | ||
"ajv": "^8.11.0", | ||
"md5": "^2.3.0" | ||
@@ -38,3 +38,3 @@ }, | ||
}, | ||
"gitHead": "bef765876e47b58c614f74167ccd4815f669ea3b" | ||
"gitHead": "0d2e09d892c1bb6e019778e270079f99cb80d332" | ||
} |
@@ -148,5 +148,17 @@ import { ResolverFn } from '@statoscope/helpers/dist/entity-resolver'; | ||
extensions: IndexAPI<string, NormalizedExtension<unknown, unknown>>; | ||
compilation: { | ||
byAsset: WeakMap<NormalizedAsset, NormalizedCompilation>; | ||
byChunks: WeakMap<NormalizedChunk, NormalizedCompilation>; | ||
byModule: WeakMap<NormalizedModule, NormalizedCompilation>; | ||
byEntrypoint: WeakMap<NormalizedEntrypointItem, NormalizedCompilation>; | ||
}; | ||
}; | ||
resolvers: { | ||
resolveExtension: ResolverFn<string, NormalizedExtension<unknown, unknown>>; | ||
resolveCompilationByAsset(asset: NormalizedAsset): NormalizedCompilation | null; | ||
resolveCompilationByChunk(chunk: NormalizedChunk): NormalizedCompilation | null; | ||
resolveCompilationByModule(module: NormalizedModule): NormalizedCompilation | null; | ||
resolveCompilationByEntrypoint( | ||
entrypoint: NormalizedEntrypointItem | ||
): NormalizedCompilation | null; | ||
}; | ||
@@ -175,8 +187,4 @@ }; | ||
compilations: HandledCompilation[]; | ||
indexes: { | ||
extensions: IndexAPI<string, NormalizedExtension<unknown, unknown>>; | ||
}; | ||
resolvers: { | ||
resolveExtension: ResolverFn<string, NormalizedExtension<unknown, unknown>>; | ||
}; | ||
indexes: HandledFileContext['indexes']; | ||
resolvers: HandledFileContext['resolvers']; | ||
}; | ||
@@ -183,0 +191,0 @@ |
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
88529
2073
+ Added@statoscope/helpers@5.22.0(transitive)
+ Added@statoscope/stats-extension-compressed@5.22.0(transitive)
+ Added@statoscope/stats-extension-custom-reports@5.22.0(transitive)
+ Added@statoscope/stats-extension-package-info@5.22.0(transitive)
+ Added@statoscope/stats-extension-stats-validation-result@5.22.0(transitive)
+ Added@statoscope/types@5.22.0(transitive)
- Removed@statoscope/helpers@5.19.0(transitive)
- Removed@statoscope/stats-extension-compressed@5.19.0(transitive)
- Removed@statoscope/stats-extension-custom-reports@5.19.0(transitive)
- Removed@statoscope/stats-extension-package-info@5.19.3(transitive)
- Removed@statoscope/stats-extension-stats-validation-result@5.19.0(transitive)
- Removed@statoscope/types@5.14.1(transitive)
Updated@statoscope/helpers@5.22.0
Updated@statoscope/stats-extension-stats-validation-result@5.22.0
Updated@statoscope/types@5.22.0
Updatedajv@^8.11.0