package-build-stats 8.0.0 → 8.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "package-build-stats",
3
- "version": "8.0.0",
3
+ "version": "8.0.1",
4
4
  "author": "Shubham Kanodia <shubham.kanodia10@gmail.com>",
5
5
  "repository": "https://github.com/pastelsky/package-build-stats",
6
6
  "publishConfig": {
@@ -79,6 +79,7 @@
79
79
  "@rspack/core": "^1.6.0",
80
80
  "@swc/core": "^1.14.0",
81
81
  "autoprefixer": "^9.7.6",
82
+ "css-loader": "^7.1.0",
82
83
  "debug": "^4.4.3",
83
84
  "esbuild": "^0.25.12",
84
85
  "esbuild-register": "^3.6.0",
@@ -87,6 +88,7 @@
87
88
  "firebase-admin": "^13.6.0",
88
89
  "is-valid-npm-name": "^0.0.5",
89
90
  "less": "^4.4.2",
91
+ "less-loader": "^12.2.0",
90
92
  "lodash": "^4.17.21",
91
93
  "mitt": "^3.0.1",
92
94
  "node-fetch": "^2.7.0",
@@ -95,8 +97,14 @@
95
97
  "oxc-resolver": "^11.13.0",
96
98
  "oxc-walker": "^0.5.2",
97
99
  "pify": "^6.1.0",
100
+ "postcss": "^8.4.0",
101
+ "postcss-loader": "^8.1.0",
98
102
  "rimraf": "^6.1.0",
99
103
  "sanitize-filename": "^1.6.3",
104
+ "sass": "^1.69.0",
105
+ "sass-loader": "^14.0.0",
106
+ "svelte": "^4.0.0",
107
+ "svelte-loader": "^3.1.0",
100
108
  "terser": "^5.44.0",
101
109
  "yargs": "^18.0.0"
102
110
  },
@@ -106,7 +106,6 @@ export default async function getPackageStats(
106
106
  ...builtDetails,
107
107
  size: mainAsset.size,
108
108
  gzip: mainAsset.gzip,
109
- installPath,
110
109
  }
111
110
  } catch (e) {
112
111
  Telemetry.packageStats(
@@ -1,26 +0,0 @@
1
- type PackageManager = 'npm' | 'yarn' | 'pnpm' | 'bun';
2
- type AllOptions = {
3
- customImports?: Array<string>;
4
- splitCustomImports?: boolean;
5
- debug?: boolean;
6
- minify?: boolean;
7
- esm?: boolean;
8
- entryFilename?: string;
9
- client?: PackageManager | PackageManager[];
10
- limitConcurrency?: boolean;
11
- networkConcurrency?: number;
12
- additionalPackages?: Array<string>;
13
- isLocal?: boolean;
14
- installTimeout?: number;
15
- };
16
- export type BuildPackageOptions = Pick<AllOptions, 'customImports' | 'splitCustomImports' | 'debug' | 'minify'> & {
17
- includeDependencySizes: boolean;
18
- };
19
- export type CreateEntryPointOptions = Pick<AllOptions, 'esm' | 'customImports' | 'entryFilename'>;
20
- export type InstallPackageOptions = Pick<AllOptions, 'client' | 'limitConcurrency' | 'networkConcurrency' | 'additionalPackages' | 'isLocal' | 'installTimeout' | 'debug'>;
21
- export type GetPackageStatsOptions = Pick<AllOptions, 'client' | 'limitConcurrency' | 'networkConcurrency' | 'debug' | 'customImports' | 'installTimeout' | 'minify'>;
22
- export type Externals = {
23
- externalPackages: Array<string>;
24
- externalBuiltIns: Array<string>;
25
- };
26
- export {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +0,0 @@
1
- declare const _default: {
2
- tmp: string;
3
- };
4
- export default _default;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- // Use ES6 supported by Node v6.10 only!
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const path_1 = __importDefault(require("path"));
8
- exports.default = {
9
- tmp: path_1.default.join('/tmp', 'tmp-build'),
10
- };
@@ -1,11 +0,0 @@
1
- import type { Entry, Configuration } from '@rspack/core';
2
- import { Externals } from '../common.types';
3
- type MakeRspackConfigOptions = {
4
- packageName: string;
5
- externals: Externals;
6
- debug?: boolean;
7
- minify?: boolean;
8
- entry: Entry;
9
- };
10
- export default function makeRspackConfig({ packageName: _packageName, entry, externals, debug: _debug, minify, }: MakeRspackConfigOptions): Configuration;
11
- export {};
@@ -1,168 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = makeRspackConfig;
7
- const autoprefixer_1 = __importDefault(require("autoprefixer"));
8
- const escape_string_regexp_1 = __importDefault(require("escape-string-regexp"));
9
- const core_1 = __importDefault(require("@rspack/core"));
10
- function makeRspackConfig({ packageName: _packageName, entry, externals, debug: _debug, minify = true, }) {
11
- const externalsRegex = makeExternalsRegex(externals.externalPackages);
12
- const isExternalRequest = (request) => {
13
- const isPeerDep = externals.externalPackages.length
14
- ? externalsRegex.test(request)
15
- : false;
16
- const isBuiltIn = externals.externalBuiltIns.includes(request);
17
- return isPeerDep || isBuiltIn;
18
- };
19
- const configuration = {
20
- entry: entry,
21
- mode: 'production',
22
- devtool: _debug ? 'source-map' : false,
23
- optimization: {
24
- runtimeChunk: { name: 'runtime' },
25
- realContentHash: false,
26
- minimize: minify,
27
- // Rspack automatically uses its built-in default minifiers:
28
- // - SwcJsMinimizerRspackPlugin for JS (SWC-based, very fast)
29
- // - LightningCssMinimizerRspackPlugin for CSS (Lightning CSS-based)
30
- // See: https://rspack.rs/guide/optimization/production
31
- splitChunks: {
32
- cacheGroups: {
33
- styles: {
34
- name: 'main',
35
- test: /\.css$/,
36
- chunks: 'all',
37
- },
38
- },
39
- },
40
- },
41
- stats: {
42
- source: true,
43
- modules: true,
44
- nestedModules: true,
45
- reasons: true,
46
- depth: true,
47
- chunkModules: true,
48
- },
49
- resolve: {
50
- modules: ['node_modules'],
51
- extensions: [
52
- '.web.mjs',
53
- '.mjs',
54
- '.web.js',
55
- '.js',
56
- '.mjs',
57
- '.json',
58
- '.css',
59
- '.sass',
60
- '.scss',
61
- ],
62
- mainFields: ['browser', 'module', 'main', 'style'],
63
- },
64
- module: {
65
- rules: [
66
- {
67
- type: 'javascript/auto',
68
- test: /\.mjs$/,
69
- use: [],
70
- },
71
- {
72
- test: /\.css$/,
73
- type: 'javascript/auto',
74
- use: [
75
- core_1.default.CssExtractRspackPlugin.loader,
76
- require.resolve('css-loader'),
77
- ],
78
- },
79
- {
80
- test: /\.(html|svelte)$/,
81
- use: {
82
- loader: require.resolve('svelte-loader'),
83
- options: {
84
- emitCss: true,
85
- },
86
- },
87
- },
88
- // {
89
- // test: /\.vue$/,
90
- // loader: require.resolve('vue-loader'),
91
- // },
92
- {
93
- test: /\.(scss|sass)$/,
94
- type: 'javascript/auto',
95
- use: [
96
- core_1.default.CssExtractRspackPlugin.loader,
97
- require.resolve('css-loader'),
98
- {
99
- loader: require.resolve('postcss-loader'),
100
- options: {
101
- postcssOptions: {
102
- plugins: [(0, autoprefixer_1.default)()],
103
- },
104
- },
105
- },
106
- require.resolve('sass-loader'),
107
- ],
108
- },
109
- {
110
- test: /\.less$/,
111
- type: 'javascript/auto',
112
- use: [
113
- core_1.default.CssExtractRspackPlugin.loader,
114
- require.resolve('css-loader'),
115
- {
116
- loader: require.resolve('postcss-loader'),
117
- options: {
118
- postcssOptions: {
119
- plugins: [
120
- (0, autoprefixer_1.default)({
121
- overrideBrowserslist: [
122
- 'last 5 Chrome versions',
123
- 'last 5 Firefox versions',
124
- 'Safari >= 8',
125
- 'Explorer >= 10',
126
- 'edge >= 12',
127
- ],
128
- }),
129
- ],
130
- },
131
- },
132
- },
133
- {
134
- loader: require.resolve('less-loader'),
135
- options: {
136
- lessOptions: {
137
- javascriptEnabled: true,
138
- },
139
- },
140
- },
141
- ],
142
- },
143
- ],
144
- },
145
- plugins: [
146
- new core_1.default.CssExtractRspackPlugin({
147
- filename: '[name].bundle.css',
148
- }),
149
- ],
150
- node: {
151
- global: false,
152
- },
153
- output: {
154
- filename: '[name].bundle.js',
155
- },
156
- externals: ({ request }, callback) => isExternalRequest(request || '')
157
- ? callback(undefined, 'commonjs ' + request)
158
- : callback(undefined),
159
- };
160
- return configuration;
161
- }
162
- function makeExternalsRegex(externals) {
163
- let externalsRegex = externals
164
- .map(dep => `^${(0, escape_string_regexp_1.default)(dep)}$|^${(0, escape_string_regexp_1.default)(dep)}\\/`)
165
- .join('|');
166
- externalsRegex = `(${externalsRegex})`;
167
- return new RegExp(externalsRegex);
168
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * Wraps the original error with a identifiable
3
- * name.
4
- */
5
- declare class CustomError extends Error {
6
- originalError: any;
7
- extra: any;
8
- constructor(name: string, originalError: Error, extra?: any);
9
- toJSON(): {
10
- name: string;
11
- originalError: any;
12
- extra: any;
13
- };
14
- }
15
- export declare class BuildError extends CustomError {
16
- constructor(originalError: any, extra?: any);
17
- }
18
- export declare class EntryPointError extends CustomError {
19
- constructor(originalError: any, extra?: any);
20
- }
21
- export declare class InstallError extends CustomError {
22
- constructor(originalError: any, extra?: any);
23
- }
24
- export declare class PackageNotFoundError extends CustomError {
25
- constructor(originalError: any, extra?: any);
26
- }
27
- export declare class CLIBuildError extends CustomError {
28
- constructor(originalError: any, extra?: any);
29
- }
30
- export declare class MinifyError extends CustomError {
31
- constructor(originalError: any, extra?: any);
32
- }
33
- export declare class MissingDependencyError extends CustomError {
34
- missingModules: Array<string>;
35
- constructor(originalError: any, extra: {
36
- missingModules: Array<string>;
37
- });
38
- }
39
- export declare class UnexpectedBuildError extends CustomError {
40
- constructor(originalError: any, extra?: any);
41
- }
42
- export {};
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UnexpectedBuildError = exports.MissingDependencyError = exports.MinifyError = exports.CLIBuildError = exports.PackageNotFoundError = exports.InstallError = exports.EntryPointError = exports.BuildError = void 0;
4
- /**
5
- * Wraps the original error with a identifiable
6
- * name.
7
- */
8
- class CustomError extends Error {
9
- constructor(name, originalError, extra) {
10
- super(name);
11
- this.name = name;
12
- this.originalError = originalError;
13
- this.extra = extra;
14
- Object.setPrototypeOf(this, CustomError.prototype);
15
- }
16
- toJSON() {
17
- return {
18
- name: this.name,
19
- originalError: this.originalError,
20
- extra: this.extra,
21
- };
22
- }
23
- }
24
- class BuildError extends CustomError {
25
- constructor(originalError, extra) {
26
- super('BuildError', originalError, extra);
27
- Object.setPrototypeOf(this, BuildError.prototype);
28
- }
29
- }
30
- exports.BuildError = BuildError;
31
- class EntryPointError extends CustomError {
32
- constructor(originalError, extra) {
33
- super('EntryPointError', originalError, extra);
34
- Object.setPrototypeOf(this, EntryPointError.prototype);
35
- }
36
- }
37
- exports.EntryPointError = EntryPointError;
38
- class InstallError extends CustomError {
39
- constructor(originalError, extra) {
40
- super('InstallError', originalError, extra);
41
- Object.setPrototypeOf(this, InstallError.prototype);
42
- }
43
- }
44
- exports.InstallError = InstallError;
45
- class PackageNotFoundError extends CustomError {
46
- constructor(originalError, extra) {
47
- super('PackageNotFoundError', originalError, extra);
48
- Object.setPrototypeOf(this, PackageNotFoundError.prototype);
49
- }
50
- }
51
- exports.PackageNotFoundError = PackageNotFoundError;
52
- class CLIBuildError extends CustomError {
53
- constructor(originalError, extra) {
54
- super('CLIBuildError', originalError, extra);
55
- Object.setPrototypeOf(this, CLIBuildError.prototype);
56
- }
57
- }
58
- exports.CLIBuildError = CLIBuildError;
59
- class MinifyError extends CustomError {
60
- constructor(originalError, extra) {
61
- super('MinifyError', originalError, extra);
62
- Object.setPrototypeOf(this, MinifyError.prototype);
63
- }
64
- }
65
- exports.MinifyError = MinifyError;
66
- class MissingDependencyError extends CustomError {
67
- constructor(originalError, extra) {
68
- super('MissingDependencyError', originalError, extra);
69
- this.missingModules = extra.missingModules;
70
- Object.setPrototypeOf(this, MissingDependencyError.prototype);
71
- }
72
- }
73
- exports.MissingDependencyError = MissingDependencyError;
74
- class UnexpectedBuildError extends CustomError {
75
- constructor(originalError, extra) {
76
- super('UnexpectedBuildError', originalError, extra);
77
- Object.setPrototypeOf(this, UnexpectedBuildError.prototype);
78
- }
79
- }
80
- exports.UnexpectedBuildError = UnexpectedBuildError;
@@ -1,6 +0,0 @@
1
- type RspackStatsCompilation = NonNullable<ReturnType<NonNullable<import('@rspack/core').Stats['toJson']>>>;
2
- declare function bundleSizeTree(packageName: string, stats: RspackStatsCompilation): Promise<{
3
- name: string;
4
- approximateSize: number;
5
- }[]>;
6
- export default bundleSizeTree;
@@ -1,277 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const path_1 = __importDefault(require("path"));
7
- const core_1 = require("@swc/core");
8
- const CustomError_1 = require("./errors/CustomError");
9
- const telemetry_utils_1 = __importDefault(require("./utils/telemetry.utils"));
10
- const perf_hooks_1 = require("perf_hooks");
11
- function modulePath(identifier) {
12
- // the format of module paths is
13
- // '(<loader expression>!)?/path/to/module.js'
14
- // OR
15
- // 'javascript/esm|/some/path'
16
- let loaderRegex = /.*!/;
17
- const withoutLoader = identifier.replace(loaderRegex, '');
18
- if (withoutLoader.includes('|'))
19
- return withoutLoader.split('|')[1];
20
- return withoutLoader;
21
- }
22
- function getUtf8Size(value) {
23
- const size = Buffer.byteLength(value, 'utf8');
24
- if (process.env.DEBUG_SIZE && Math.random() < 0.01) {
25
- // Only debug 1% to avoid spam
26
- console.log(`Size: ${size} bytes`);
27
- }
28
- return size;
29
- }
30
- /**
31
- * Extract all package names from a module path to build a dependency chain.
32
- * For example: /node_modules/a/node_modules/b/index.js returns ['a', 'b']
33
- * This preserves the old behavior of showing nested dependencies.
34
- */
35
- function extractPackageNamesFromPath(moduleFilePath) {
36
- // pnpm will serve packages from a global symlink (.pnpm/package@version/node_modules/package)
37
- // needs to be stripped off
38
- const pnpmPrefix = '.pnpm\\' + path_1.default.sep + '.+\\' + path_1.default.sep + 'node_modules\\' + path_1.default.sep;
39
- const packages = moduleFilePath.split(new RegExp('\\' + path_1.default.sep + 'node_modules\\' + path_1.default.sep + `(?:${pnpmPrefix})?`));
40
- if (packages.length <= 1)
41
- return [];
42
- const lastSegment = packages.pop();
43
- if (!lastSegment)
44
- return [];
45
- // Extract the package name from the last segment
46
- let lastPackageName;
47
- if (lastSegment[0] === '@') {
48
- // package is a scoped package
49
- const offset = lastSegment.indexOf(path_1.default.sep) + 1;
50
- lastPackageName = lastSegment.slice(0, offset + lastSegment.slice(offset).indexOf(path_1.default.sep));
51
- }
52
- else {
53
- lastPackageName = lastSegment.slice(0, lastSegment.indexOf(path_1.default.sep));
54
- }
55
- packages.push(lastPackageName);
56
- packages.shift(); // Remove the first empty element
57
- return packages;
58
- }
59
- async function minifyDependencyCode(source) {
60
- if (process.env.DEBUG_SIZE) {
61
- console.log('Minifying dependency code...');
62
- }
63
- try {
64
- const startTime = Date.now();
65
- const result = await (0, core_1.minify)(source, {
66
- compress: true,
67
- mangle: true,
68
- module: true, // Treat as ES module to support import/export
69
- });
70
- const minifyTime = Date.now() - startTime;
71
- if (process.env.DEBUG_SIZE) {
72
- console.log(`Minify completed in ${minifyTime}ms`);
73
- }
74
- return { code: result.code };
75
- }
76
- catch (error) {
77
- if (process.env.DEBUG_SIZE) {
78
- console.log('Minify error occurred');
79
- }
80
- console.error('SWC minify error:', error);
81
- throw error;
82
- }
83
- }
84
- function normaliseModuleSource(mod) {
85
- const identifier = mod.identifier || '';
86
- const isJSON = identifier.endsWith('.json');
87
- const rawSource = mod.source;
88
- if (process.env.DEBUG_SIZE) {
89
- console.log(`Normalising module: ${identifier}`);
90
- }
91
- if (rawSource === undefined || rawSource === null) {
92
- if (process.env.DEBUG_SIZE) {
93
- console.log(`No source for module: ${identifier}`);
94
- }
95
- return null;
96
- }
97
- let source;
98
- if (typeof rawSource === 'string') {
99
- source = rawSource;
100
- if (process.env.DEBUG_SIZE) {
101
- console.log(`Source is string`);
102
- }
103
- }
104
- else if (Buffer.isBuffer(rawSource)) {
105
- source = rawSource.toString('utf8');
106
- if (process.env.DEBUG_SIZE) {
107
- console.log(`Source is buffer`);
108
- }
109
- }
110
- else {
111
- source = String(rawSource);
112
- if (process.env.DEBUG_SIZE) {
113
- console.log(`Source is other type`);
114
- }
115
- }
116
- const finalSource = isJSON ? `$a$=${source}` : source;
117
- if (process.env.DEBUG_SIZE) {
118
- console.log(`Module source normalised (length: ${finalSource.length})`);
119
- }
120
- return finalSource;
121
- }
122
- async function bundleSizeTree(packageName, stats) {
123
- const startTime = perf_hooks_1.performance.now();
124
- const statsTree = {
125
- packageName: '<root>',
126
- sources: [],
127
- children: [],
128
- };
129
- if (!stats.modules)
130
- return [];
131
- // Collect modules with their sources
132
- const modules = [];
133
- const makeModule = (mod) => {
134
- const identifier = mod.identifier || '';
135
- const resolvedPath = modulePath(identifier);
136
- const source = normaliseModuleSource(mod);
137
- if (!source)
138
- return null;
139
- return {
140
- path: resolvedPath,
141
- source,
142
- };
143
- };
144
- const filteredModules = stats.modules.filter(mod => { var _a; return !(((_a = mod.name) === null || _a === void 0 ? void 0 : _a.startsWith('external')) || mod.moduleType === 'runtime'); });
145
- if (process.env.DEBUG_SIZE) {
146
- console.log(`\n[LOCAL] ==================== ${packageName} ====================`);
147
- }
148
- filteredModules.forEach(mod => {
149
- if (mod.modules) {
150
- if (process.env.DEBUG_SIZE) {
151
- console.log(`Module has ${mod.modules.length} sub-modules`);
152
- }
153
- mod.modules.forEach(subMod => {
154
- const made = makeModule(subMod);
155
- if (made)
156
- modules.push(made);
157
- });
158
- }
159
- else {
160
- const made = makeModule(mod);
161
- if (made)
162
- modules.push(made);
163
- }
164
- });
165
- if (process.env.DEBUG_SIZE) {
166
- console.log(`Collected ${modules.length} total modules`);
167
- }
168
- modules.sort((a, b) => {
169
- if (a === b) {
170
- return 0;
171
- }
172
- else {
173
- return a < b ? -1 : 1;
174
- }
175
- });
176
- // Build tree structure from module paths
177
- modules.forEach((mod, modIndex) => {
178
- const packages = extractPackageNamesFromPath(mod.path);
179
- if (process.env.DEBUG_SIZE && modIndex < 5) {
180
- console.log(`[${modIndex}] Extracted packages: ${packages.join(' > ')}`);
181
- }
182
- if (packages.length === 0) {
183
- if (process.env.DEBUG_SIZE && modIndex < 5) {
184
- console.log(`[${modIndex}] No packages found in path`);
185
- }
186
- return;
187
- }
188
- let parent = statsTree;
189
- packages.forEach((pkg, pkgIndex) => {
190
- const existing = parent.children.filter(child => child.packageName === pkg);
191
- if (existing.length > 0) {
192
- existing[0].sources.push(mod.source);
193
- if (process.env.DEBUG_SIZE && modIndex < 5) {
194
- console.log(`[${modIndex}] Added to existing package: ${pkg}`);
195
- }
196
- parent = existing[0];
197
- }
198
- else {
199
- const newChild = {
200
- path: mod.path,
201
- packageName: pkg,
202
- sources: [mod.source],
203
- children: [],
204
- };
205
- parent.children.push(newChild);
206
- if (process.env.DEBUG_SIZE && modIndex < 5) {
207
- console.log(`[${modIndex}] Created new package: ${pkg}`);
208
- }
209
- parent = newChild;
210
- }
211
- });
212
- });
213
- // The old webpack implementation returned only the first-level children
214
- // We need to preserve that behavior
215
- const flattenedItems = statsTree.children;
216
- if (process.env.DEBUG_SIZE) {
217
- console.log(`\n[LOCAL] Tree structure built with ${flattenedItems.length} top-level dependencies:`);
218
- }
219
- const resultPromises = flattenedItems
220
- .map(treeItem => ({
221
- ...treeItem,
222
- sources: treeItem.sources.filter(source => !!source),
223
- }))
224
- .filter(treeItem => treeItem.sources.length)
225
- .map(async (treeItem) => {
226
- if (process.env.DEBUG_SIZE) {
227
- console.log(`\n[LOCAL] Processing dependency: ${treeItem.packageName}`);
228
- }
229
- const sourceMinifiedPromises = treeItem.sources.map(async (code, idx) => {
230
- const originalSize = getUtf8Size(code);
231
- if (process.env.DEBUG_SIZE) {
232
- console.log(`Source ${idx}: ${originalSize} bytes (original)`);
233
- }
234
- const minified = await minifyDependencyCode(code);
235
- const minifiedSize = getUtf8Size(minified.code || '');
236
- const minifiedCode = minified.code || '';
237
- if (process.env.DEBUG_SIZE) {
238
- console.log(`Source ${idx}: ${minifiedSize} bytes (minified)`);
239
- }
240
- return minified;
241
- });
242
- try {
243
- const sources = await Promise.all(sourceMinifiedPromises);
244
- const size = sources.reduce((acc, source, idx) => {
245
- const sourceSize = getUtf8Size(source.code || '');
246
- if (process.env.DEBUG_SIZE) {
247
- console.log(`Total accumulation at idx ${idx}: ${acc + sourceSize} bytes`);
248
- }
249
- return acc + sourceSize;
250
- }, 0);
251
- if (process.env.DEBUG_SIZE) {
252
- console.log(`Final size for ${treeItem.packageName}: ${size} bytes`);
253
- }
254
- return {
255
- name: treeItem.packageName,
256
- approximateSize: size,
257
- };
258
- }
259
- catch (error) {
260
- const { message, filename } = error;
261
- throw new CustomError_1.MinifyError(error, {
262
- message: message,
263
- filePath: filename,
264
- });
265
- }
266
- });
267
- try {
268
- const results = await Promise.all(resultPromises);
269
- telemetry_utils_1.default.dependencySizes(packageName, startTime, true, { minifier: 'swc' });
270
- return results;
271
- }
272
- catch (e) {
273
- telemetry_utils_1.default.dependencySizes(packageName, startTime, false, { minifier: 'swc' }, e);
274
- throw e;
275
- }
276
- }
277
- exports.default = bundleSizeTree;