package-build-stats 8.2.3 → 8.2.5
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/build/common.types.d.ts +26 -0
- package/build/common.types.js +1 -0
- package/build/config/config.d.ts +4 -0
- package/build/config/config.js +5 -0
- package/build/config/makeRspackConfig.d.ts +11 -0
- package/build/config/makeRspackConfig.js +170 -0
- package/build/errors/CustomError.d.ts +42 -0
- package/build/errors/CustomError.js +69 -0
- package/build/getDependencySizeTree.d.ts +6 -0
- package/build/getDependencySizeTree.js +271 -0
- package/build/getPackageExportSizes.d.ts +18 -0
- package/build/getPackageExportSizes.js +95 -0
- package/build/getPackageStats.d.ts +26 -0
- package/build/getPackageStats.js +98 -0
- package/build/index.d.ts +4 -0
- package/build/index.js +4 -0
- package/build/utils/build.utils.d.ts +51 -0
- package/build/utils/build.utils.js +288 -0
- package/build/utils/common.utils.d.ts +20 -0
- package/build/utils/common.utils.js +112 -0
- package/build/utils/exports.utils.d.ts +26 -0
- package/build/utils/exports.utils.js +192 -0
- package/build/utils/installation.utils.d.ts +9 -0
- package/build/utils/installation.utils.js +203 -0
- package/build/utils/telemetry.utils.d.ts +17 -0
- package/build/utils/telemetry.utils.js +121 -0
- package/package.json +4 -2
- package/src/utils/build.utils.ts +39 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "package-build-stats",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Shubham Kanodia <shubham.kanodia10@gmail.com>",
|
|
6
6
|
"repository": "https://github.com/pastelsky/package-build-stats",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"compare:top": "tsx scripts/index.ts top",
|
|
41
41
|
"compare:advanced": "tsx scripts/index.ts compare",
|
|
42
42
|
"perf:test": "tsx scripts/performance-test.ts",
|
|
43
|
-
"
|
|
43
|
+
"prepack": "rm -rf build && yarn check && yarn build && yarn format"
|
|
44
44
|
},
|
|
45
45
|
"prettier": {
|
|
46
46
|
"semi": false,
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"@types/rimraf": "^4.0.5",
|
|
62
62
|
"@types/sanitize-filename": "^1.6.3",
|
|
63
63
|
"@types/semver": "^7",
|
|
64
|
+
"@types/server": "^1",
|
|
64
65
|
"@types/yargs": "^17.0.34",
|
|
65
66
|
"@vitest/coverage-v8": "^4.0.6",
|
|
66
67
|
"@vitest/ui": "4.0.6",
|
|
@@ -105,6 +106,7 @@
|
|
|
105
106
|
"sanitize-filename": "^1.6.3",
|
|
106
107
|
"sass": "^1.69.0",
|
|
107
108
|
"sass-loader": "^14.0.0",
|
|
109
|
+
"server": "^1.0.42",
|
|
108
110
|
"svelte": "^4.0.0",
|
|
109
111
|
"svelte-loader": "^3.1.0",
|
|
110
112
|
"terser": "^5.44.0",
|
package/src/utils/build.utils.ts
CHANGED
|
@@ -35,6 +35,8 @@ type CompilePackageReturn = {
|
|
|
35
35
|
error: Error | null
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
type Compiler = NonNullable<ReturnType<typeof rspack>>
|
|
39
|
+
|
|
38
40
|
type BuildPackageArgs = {
|
|
39
41
|
name: string
|
|
40
42
|
installPath: string
|
|
@@ -70,6 +72,18 @@ function getCompilationErrors(stats: Stats) {
|
|
|
70
72
|
return [...stats.compilation.errors].filter(notEmpty).flat()
|
|
71
73
|
}
|
|
72
74
|
|
|
75
|
+
function closeCompiler(compiler: Compiler) {
|
|
76
|
+
return new Promise<void>((resolve, reject) => {
|
|
77
|
+
compiler.close(error => {
|
|
78
|
+
if (error) {
|
|
79
|
+
reject(error)
|
|
80
|
+
} else {
|
|
81
|
+
resolve()
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
73
87
|
const BuildUtils = {
|
|
74
88
|
createEntryPoint(
|
|
75
89
|
packageName: string,
|
|
@@ -132,18 +146,25 @@ const BuildUtils = {
|
|
|
132
146
|
|
|
133
147
|
const compiler = rspack(options)
|
|
134
148
|
|
|
135
|
-
return new Promise<CompilePackageReturn>(resolve => {
|
|
136
|
-
compiler.run((error, stats) => {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
149
|
+
return new Promise<CompilePackageReturn>((resolve, reject) => {
|
|
150
|
+
compiler.run(async (error, stats) => {
|
|
151
|
+
try {
|
|
152
|
+
if (!stats) {
|
|
153
|
+
throw new Error('stats is null')
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
await closeCompiler(compiler)
|
|
157
|
+
|
|
158
|
+
if (error) {
|
|
159
|
+
console.error(error)
|
|
160
|
+
Telemetry.compilePackage(name, false, startTime, {}, error)
|
|
161
|
+
} else {
|
|
162
|
+
Telemetry.compilePackage(name, true, startTime, {})
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
resolve({ stats, error })
|
|
166
|
+
} catch (closeError) {
|
|
167
|
+
reject(closeError)
|
|
147
168
|
}
|
|
148
169
|
})
|
|
149
170
|
})
|
|
@@ -193,7 +214,7 @@ const BuildUtils = {
|
|
|
193
214
|
externals,
|
|
194
215
|
options,
|
|
195
216
|
}: BuildPackageArgs) {
|
|
196
|
-
let entry:
|
|
217
|
+
let entry: any = {}
|
|
197
218
|
|
|
198
219
|
if (options.splitCustomImports) {
|
|
199
220
|
if (!options.customImports || !options.customImports.length) {
|
|
@@ -313,7 +334,11 @@ const BuildUtils = {
|
|
|
313
334
|
(typeof name === 'string' && name.startsWith('runtime~')),
|
|
314
335
|
),
|
|
315
336
|
)
|
|
316
|
-
.filter(
|
|
337
|
+
.filter(
|
|
338
|
+
asset =>
|
|
339
|
+
typeof asset.name === 'string' &&
|
|
340
|
+
!asset.name.endsWith('LICENSE.txt'),
|
|
341
|
+
)
|
|
317
342
|
.map(getAssetStats) || []
|
|
318
343
|
const assetStats = await Promise.all(assetStatsPromises)
|
|
319
344
|
Telemetry.assetsGZIPParseTime(name, performance.now())
|