Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@statoscope/webpack-model

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@statoscope/webpack-model - npm Package Compare versions

Comparing version 5.28.0 to 5.28.1

24

dist/collector.d.ts

@@ -1,18 +0,10 @@

import { Webpack } from '../webpack';
import type { Webpack } from '../webpack';
import type { EntrypointItem } from '../types';
import Module = Webpack.Module;
import RawModule = Webpack.RawModule;
import Compilation = Webpack.Compilation;
import Chunk = Webpack.Chunk;
import Asset = Webpack.Asset;
import Reason = Webpack.Reason;
import RawReason = Webpack.RawReason;
import RawAsset = Webpack.RawAsset;
export declare function collector<TResult, TID, TEntry = TResult>(from: TEntry[], isItem: (entry: TEntry) => boolean, getChildren: (entry: TEntry) => TEntry[], getId: (item: TResult) => TID): Map<TID, TResult>;
export declare function collectRawModules(compilation: Compilation): RawModule[];
export declare function collectRawModulesFromArray(modules: Module[]): Map<string, RawModule>;
export declare function collectRawAssetsFromArray(assets: Asset[]): Map<string, RawAsset>;
export declare function collectRawReasonsFromArray(modules: Reason[]): Map<number, RawReason>;
export declare function collectRawChunks(compilation: Compilation): Chunk[];
export declare function collectRawAssets(compilation: Compilation): RawAsset[];
export declare function collectRawEntrypoints(compilation: Compilation): EntrypointItem[];
export declare function collectRawModules(compilation: Webpack.Compilation): Webpack.RawModule[];
export declare function collectRawModulesFromArray(modules: Webpack.Module[]): Map<string, Webpack.RawModule>;
export declare function collectRawAssetsFromArray(assets: Webpack.Asset[]): Map<string, Webpack.RawAsset>;
export declare function collectRawReasonsFromArray(modules: Webpack.Reason[]): Map<number, Webpack.RawReason>;
export declare function collectRawChunks(compilation: Webpack.Compilation): Webpack.Chunk[];
export declare function collectRawAssets(compilation: Webpack.Compilation): Webpack.RawAsset[];
export declare function collectRawEntrypoints(compilation: Webpack.Compilation): EntrypointItem[];

@@ -1,6 +0,4 @@

import { NormalizationData, Webpack } from '../webpack';
import Compilation = Webpack.Compilation;
import RawModule = Webpack.RawModule;
export declare type ModulesMap = Map<number, RawModule>;
export declare type CompilationData = {
import { NormalizationData, type Webpack } from '../webpack';
export type ModulesMap = Map<number, Webpack.RawModule>;
export type CompilationData = {
id: string;

@@ -11,3 +9,3 @@ data: {

};
export declare type DenormalizationData = {
export type DenormalizationData = {
links: NormalizationData['links'];

@@ -18,2 +16,2 @@ data: {

};
export default function denormalizeCompilation<T extends Compilation>(json: T): T;
export default function denormalizeCompilation<T extends Webpack.Compilation>(json: T): T;

@@ -1,6 +0,5 @@

import { Webpack } from '../webpack';
import type { Webpack } from '../webpack';
import { HandledCompilation, HandledFileContext, ProcessingContext } from '../types';
import { NormalizedFile, RawStatsFileDescriptor } from '../types';
import Compilation = Webpack.Compilation;
export default function handleCompilations(rawStatsFileDescriptor: RawStatsFileDescriptor, file: NormalizedFile, fileContext: HandledFileContext): HandledCompilation[];
export declare function extractPackages(compilation: Compilation, context: ProcessingContext): void;
export declare function extractPackages(compilation: Webpack.Compilation, context: ProcessingContext): void;

@@ -91,3 +91,2 @@ "use strict";

function handleCompilation(compilation, file, parent, fileContext) {
var _a;
const normalized = {

@@ -123,3 +122,2 @@ time: compilation.time,

}),
chunkAssets: new Map(),
};

@@ -146,13 +144,2 @@ const resolvers = {

for (const asset of (0, collector_1.collectRawAssets)(compilation)) {
for (let chunkOrId of (_a = asset.chunks) !== null && _a !== void 0 ? _a : []) {
if (chunkOrId && typeof chunkOrId !== 'string' && typeof chunkOrId !== 'number') {
chunkOrId = chunkOrId.id;
}
let assets = processingContext.rawIndexes.chunkAssets.get(chunkOrId);
if (!assets) {
assets = new Set();
processingContext.rawIndexes.chunkAssets.set(chunkOrId, assets);
}
assets.add(asset);
}
processingContext.rawIndexes.assets.add(asset);

@@ -325,3 +312,2 @@ }

function prepareChunk(chunk, context) {
var _a, _b;
if (chunk == null) {

@@ -342,17 +328,9 @@ return;

if (chunk.files) {
const assets = chunk.files
normalizedChunk.files = chunk.files
.filter(Boolean) // to skip null files, issue #158
.map((f) => context.rawIndexes.assets.get(typeof f === 'string' ? f : f.name))
.filter(Boolean);
const assetsUniq = new Set(assets);
for (const asset of (_a = context.rawIndexes.chunkAssets.get(chunk.id)) !== null && _a !== void 0 ? _a : []) {
assetsUniq.add(asset);
}
normalizedChunk.files = [...assetsUniq];
}
else {
chunk.files = [];
for (const asset of (_b = context.rawIndexes.chunkAssets.get(chunk.id)) !== null && _b !== void 0 ? _b : []) {
chunk.files.push(asset);
}
}

@@ -359,0 +337,0 @@ if (chunk.sizes) {

@@ -6,5 +6,5 @@ import { Options } from '@statoscope/helpers/dist/jora';

export * as module from './module';
export { StatsExtensionWebpackAdapter } from './stats-extension-webpack-adapter';
export type { StatsExtensionWebpackAdapter } from './stats-extension-webpack-adapter';
export { joraHelpers, normalize };
export declare type Prepared = {
export type Prepared = {
files: NormalizedFile[];

@@ -11,0 +11,0 @@ compilations: NormalizedCompilation[];

@@ -8,12 +8,11 @@ import type { Size } from '@statoscope/stats-extension-compressed/dist/generator';

import { Report } from '@statoscope/types/types/custom-report';
import { Webpack } from '../webpack';
import type { Webpack } from '../webpack';
import { ModuleGraphNodeData, NodeModuleInstance, NormalizedAsset, NormalizedChunk, NormalizedCompilation, NormalizedEntrypointItem, NormalizedExtension, NormalizedModule, NormalizedPackage, NormalizeResult, NormalizedFile } from '../types';
import { moduleNameResource, moduleReasonResource, moduleResource, nodeModule } from './module';
import { Node as FoamTreeNode } from './modules-to-foam-tree';
import ChunkID = Webpack.ChunkID;
export declare type ResolvedStats = {
export type ResolvedStats = {
file: NormalizedFile;
compilation: NormalizedCompilation;
};
export declare type ResolvedRelatedItem = {
export type ResolvedRelatedItem = {
type: 'module';

@@ -49,3 +48,3 @@ item: NormalizedModule | null;

resolveCompilationByEntrypoint(entrypoint: NormalizedEntrypointItem, fileName: string): NormalizedCompilation | null;
resolveChunk(id: ChunkID, compilationHash: string): NormalizedChunk | null;
resolveChunk(id: Webpack.ChunkID, compilationHash: string): NormalizedChunk | null;
resolveAsset(id: string, compilationHash: string): NormalizedAsset | null;

@@ -52,0 +51,0 @@ resolveModule(id: string, compilationHash: string): NormalizedModule | null;

@@ -1,5 +0,3 @@

import { Webpack } from '../webpack';
import type { Webpack } from '../webpack';
import { NormalizedModule, NormalizedReason } from '../types';
import RawModule = Webpack.RawModule;
import RawReason = Webpack.RawReason;
export declare const extractFileRx: RegExp;

@@ -9,5 +7,5 @@ export declare const concatenatedIdRx: RegExp;

export declare function moduleNameResource(name: string | null): string | null;
export declare function moduleResource(module: RawModule | NormalizedModule | null): string | null;
export declare function moduleReasonResource(reason: RawReason | NormalizedReason | null): string | null;
export declare type NodeModule = {
export declare function moduleResource(module: Webpack.RawModule | NormalizedModule | null): string | null;
export declare function moduleReasonResource(reason: Webpack.RawReason | NormalizedReason | null): string | null;
export type NodeModule = {
path: string;

@@ -14,0 +12,0 @@ name: string;

@@ -65,3 +65,7 @@ "use strict";

cached = name
? { path: input, name: [namespace, name].filter(Boolean).join('/'), isRoot }
? {
path: input,
name: [namespace, name].filter(Boolean).join('/'),
isRoot,
}
: null;

@@ -68,0 +72,0 @@ nodeModuleNameCache.set(path, cached);

import { Compressor, Size } from '@statoscope/stats-extension-compressed/dist/generator';
import { NormalizedModule } from '../types';
export declare type NodeLink = {
export type NodeLink = {
page: string;

@@ -14,7 +14,7 @@ id: string;

};
export declare type NodeData = {
export type NodeData = {
label: string;
link?: string | NodeLink;
};
export declare type Node = {
export type Node = {
label: string;

@@ -27,3 +27,3 @@ weight: number;

};
export declare type GetModuleSizeFN = (module: NormalizedModule) => Size;
export type GetModuleSizeFN = (module: NormalizedModule) => Size;
export default function modulesToFoamTree(modules: NormalizedModule[], getModuleSize: GetModuleSizeFN): Node;

@@ -19,3 +19,4 @@ "use strict";

}
const parts = resource.split(/[/\\]/).map((label) => ({ label }));
const partsLabels = resource.split(/[/\\]/);
const parts = partsLabels.map((label) => ({ label }));
let currentPackage = null;

@@ -45,6 +46,3 @@ for (const [i, part] of parts.entries()) {

params: {
instance: parts
.map((part) => part.label)
.slice(0, i + 1)
.join('/'),
instance: partsLabels.slice(0, i + 1).join('/'),
},

@@ -51,0 +49,0 @@ };

{
"name": "@statoscope/webpack-model",
"version": "5.28.0",
"version": "5.28.1",
"description": "This package contains helpers to process webpack stats",
"main": "./dist/index.js",
"scripts": {
"build": "../../node_modules/.bin/tsc",
"prepublishOnly": "npm run build"
"build": "../../node_modules/.bin/tsc"
},

@@ -21,18 +20,18 @@ "repository": "https://github.com/statoscope/statoscope.git",

"dependencies": {
"@statoscope/extensions": "5.14.1",
"@statoscope/helpers": "5.28.0",
"@statoscope/stats": "5.14.1",
"@statoscope/stats-extension-compressed": "5.28.0",
"@statoscope/stats-extension-custom-reports": "5.28.0",
"@statoscope/stats-extension-package-info": "5.28.0",
"@statoscope/stats-extension-stats-validation-result": "5.28.0",
"@statoscope/types": "5.27.0",
"@statoscope/extensions": "5.28.1",
"@statoscope/helpers": "5.28.1",
"@statoscope/stats": "5.28.1",
"@statoscope/stats-extension-compressed": "5.28.1",
"@statoscope/stats-extension-custom-reports": "5.28.1",
"@statoscope/stats-extension-package-info": "5.28.1",
"@statoscope/stats-extension-stats-validation-result": "5.28.1",
"@statoscope/types": "5.28.1",
"@types/md5": "^2.3.2",
"@types/webpack": "^5.0.0",
"md5": "^2.3.0"
},
"devDependencies": {
"@types/md5": "^2.3.0",
"@types/webpack": "^5.0.0",
"flatted": "^3.1.1"
"flatted": "^3.2.7"
},
"gitHead": "8593d1728fba7201855ba496eb5c01d28333c60b"
"gitHead": "a89f68a6251a1c914791e22b643dd94ca2a70253"
}

@@ -7,14 +7,6 @@ import { ResolverFn } from '@statoscope/helpers/dist/entity-resolver';

import { Webpack } from './webpack';
import ChunkID = Webpack.ChunkID;
import Entrypoint = Webpack.Entrypoint;
import RawModule = Webpack.RawModule;
import RawAsset = Webpack.RawAsset;
import Chunk = Webpack.Chunk;
import IssuerPathItem = Webpack.IssuerPathItem;
import Compilation = Webpack.Compilation;
import RawReason = Webpack.RawReason;
export type CompilationResolvers = {
resolveModule: ResolverFn<string, NormalizedModule>;
resolveChunk: ResolverFn<ChunkID, NormalizedChunk>;
resolveChunk: ResolverFn<Webpack.ChunkID, NormalizedChunk>;
resolveAsset: ResolverFn<string, NormalizedAsset>;

@@ -26,3 +18,3 @@ resolvePackage: ResolverFn<string, NormalizedPackage>;

export type NormalizedChunk = Omit<
Chunk,
Webpack.Chunk,
'modules' | 'files' | 'children' | 'parents' | 'siblings'

@@ -38,3 +30,3 @@ > & {

export type NormalizedEntrypointItem = { name: string; data: NormalizedEntrypoint };
export type NormalizedEntrypoint = Omit<Entrypoint, 'chunks' | 'assets'> & {
export type NormalizedEntrypoint = Omit<Webpack.Entrypoint, 'chunks' | 'assets'> & {
chunks: NormalizedChunk[];

@@ -44,7 +36,7 @@ assets: NormalizedAsset[];

};
export type NormalizedAsset = Omit<RawAsset, 'chunks' | 'files'> & {
export type NormalizedAsset = Omit<Webpack.RawAsset, 'chunks' | 'files'> & {
chunks: NormalizedChunk[];
files: File[];
};
export type NormalizedIssuerPathItem = IssuerPathItem & {
export type NormalizedIssuerPathItem = Webpack.IssuerPathItem & {
resolvedModule: NormalizedModule | null;

@@ -54,3 +46,3 @@ resolvedEntry?: NormalizedEntrypointItem | null;

};
export type NormalizedReason = RawReason & {
export type NormalizedReason = Webpack.RawReason & {
resolvedModule: NormalizedModule | null;

@@ -66,3 +58,3 @@ resolvedEntry?: NormalizedEntrypointItem | null;

export type NormalizedModule = Omit<
RawModule,
Webpack.RawModule,
'chunks' | 'reasons' | 'modules' | 'issuerPath'

@@ -111,3 +103,3 @@ > & {

modules: IndexAPI<string, NormalizedModule>;
chunks: IndexAPI<ChunkID, NormalizedChunk>;
chunks: IndexAPI<Webpack.ChunkID, NormalizedChunk>;
assets: IndexAPI<string, NormalizedAsset>;

@@ -120,10 +112,9 @@ packages: IndexAPI<string, NormalizedPackage>;

name: string;
data: Entrypoint;
data: Webpack.Entrypoint;
};
export type RawIndexes = {
modules: IndexAPI<string, RawModule>;
chunks: IndexAPI<ChunkID, Chunk>;
assets: IndexAPI<string, RawAsset>;
chunkAssets: Map<ChunkID, Set<RawAsset>>;
modules: IndexAPI<string, Webpack.RawModule>;
chunks: IndexAPI<Webpack.ChunkID, Webpack.Chunk>;
assets: IndexAPI<string, Webpack.RawAsset>;
entrypoints: IndexAPI<string, EntrypointItem>;

@@ -170,3 +161,3 @@ };

resolveCompilationByEntrypoint(
entrypoint: NormalizedEntrypointItem
entrypoint: NormalizedEntrypointItem,
): NormalizedCompilation | null;

@@ -176,3 +167,3 @@ };

export type RawStatsFileDescriptor = { name: string; data: Compilation };
export type RawStatsFileDescriptor = { name: string; data: Webpack.Compilation };

@@ -179,0 +170,0 @@ export type NormalizedFile = {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc