@bymaksym/loadline 0.1.0 → 1.0.0
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/README.md +66 -7
- package/dist/cli/cli/args.js +33 -3
- package/dist/cli/cli/declared.js +52 -0
- package/dist/cli/cli/html-report.js +107 -0
- package/dist/cli/cli/locate.js +60 -0
- package/dist/cli/cli/main.js +118 -5
- package/dist/cli/cli/memory.js +78 -0
- package/dist/cli/cli/read-build.js +8 -4
- package/dist/cli/cli/render-json.js +8 -5
- package/dist/cli/cli/render-markdown.js +1 -1
- package/dist/cli/cli/render-pr.js +5 -3
- package/dist/cli/cli/render-sarif.js +3 -3
- package/dist/cli/cli/render-text.js +63 -28
- package/dist/cli/cli/report.js +9 -3
- package/dist/cli/cli/since-last.js +45 -0
- package/dist/cli/cli/text.js +54 -19
- package/dist/cli/src/app/core/analysis/analysis.js +8 -4
- package/dist/cli/src/app/core/analysis/barrels.js +9 -2
- package/dist/cli/src/app/core/analysis/entries.js +41 -6
- package/dist/cli/src/app/core/analysis/metafile.types.js +14 -6
- package/dist/cli/src/app/core/analysis/split-drift.js +12 -6
- package/dist/cli/src/app/core/assets/assets.js +4 -2
- package/dist/cli/src/app/core/caching/caching.js +3 -3
- package/dist/cli/src/app/core/deps/deps.js +37 -7
- package/dist/cli/src/app/core/deps/pins.js +63 -0
- package/dist/cli/src/app/core/export/summary.js +27 -9
- package/dist/cli/src/app/core/findings/actions.js +63 -6
- package/dist/cli/src/app/core/findings/assets.js +30 -5
- package/dist/cli/src/app/core/findings/boot-single.js +76 -0
- package/dist/cli/src/app/core/findings/caching.js +1 -1
- package/dist/cli/src/app/core/findings/dupes.js +65 -0
- package/dist/cli/src/app/core/findings/effort.js +2 -0
- package/dist/cli/src/app/core/findings/finding-html.js +14 -1
- package/dist/cli/src/app/core/findings/finding-text.js +104 -31
- package/dist/cli/src/app/core/findings/finding.types.js +1 -0
- package/dist/cli/src/app/core/findings/findings.js +22 -38
- package/dist/cli/src/app/core/findings/graph.js +4 -4
- package/dist/cli/src/app/core/findings/scan.js +13 -3
- package/dist/cli/src/app/core/findings/shipped.js +3 -5
- package/dist/cli/src/app/core/format/format.utils.js +16 -9
- package/dist/cli/src/app/core/i18n/en.js +108 -48
- package/dist/cli/src/app/core/i18n/es.js +114 -50
- package/dist/cli/src/app/core/intake/bundle-graph.js +6 -5
- package/dist/cli/src/app/core/intake/dist-files.js +5 -2
- package/dist/cli/src/app/core/intake/embedded.js +46 -0
- package/dist/cli/src/app/core/intake/index-html.js +66 -16
- package/dist/cli/src/app/core/project/budget-advice.js +14 -10
- package/dist/cli/src/app/core/project/project-context.js +74 -16
- package/dist/cli/src/app/core/scan/scan.js +59 -21
- package/dist/cli/src/app/core/scan/secrets.js +0 -0
- package/dist/cli/src/app/core/situation/situation.js +3 -4
- package/dist/cli/src/app/state/report-messages.utils.js +1 -4
- package/loadline.html +22 -24
- package/package.json +60 -30
|
@@ -17,6 +17,15 @@ exports.TEXT = {
|
|
|
17
17
|
es: {
|
|
18
18
|
/** What the entry through the root is called when the measurement matches no screen. */
|
|
19
19
|
rootScreen: 'la raíz',
|
|
20
|
+
// The small pieces the lists inside a signal are built from. They were written in English in
|
|
21
|
+
// the modules that build the lists, and `--lang es` printed them in English in the middle of
|
|
22
|
+
// a Spanish sentence.
|
|
23
|
+
andMore: (count) => `y ${count} más`,
|
|
24
|
+
inPage: 'la pide la página',
|
|
25
|
+
each: 'cada uno',
|
|
26
|
+
fileCount: (count) => `${count} ${count === 1 ? 'fichero' : 'ficheros'}`,
|
|
27
|
+
packageBarrelRow: (files, entries, size, inBoot) => `${files} ${files === 1 ? 'fichero entra' : 'ficheros entran'}, ${entries} ${entries === 1 ? 'se importa' : 'se importan'} desde fuera, ${size}${inBoot ? ' (bootstrap)' : ''}`,
|
|
28
|
+
ownBarrelRow: (reexports, pulls, size) => `${reexports} ${reexports === 1 ? 'reexportación' : 'reexportaciones'}, ${pulls} ${pulls === 1 ? 'fichero' : 'ficheros'}, ${size}`,
|
|
20
29
|
shared: (d) => ({
|
|
21
30
|
chip: 'código común marcado como lazy',
|
|
22
31
|
title: `${d.size} que se descargan en ${d.screens} de tus ${d.total} pantallas`,
|
|
@@ -33,6 +42,14 @@ exports.TEXT = {
|
|
|
33
42
|
? `, en ${d.routes}, que es donde se carga la pantalla`
|
|
34
43
|
: ', dentro de un fichero de rutas lazy'}. Un efecto secundario a tener en cuenta: si tienes guards que comparan contra ${(0, finding_html_1.mono)('routeConfig.path')}, deja el guard en la ruta padre, porque al anidar el hijo pasa a tener ${(0, finding_html_1.mono)("path: ''")} y el guard deja de reconocerla.`,
|
|
35
44
|
}),
|
|
45
|
+
bootSingle: (d) => ({
|
|
46
|
+
chip: 'paquete del arranque con un solo importador',
|
|
47
|
+
title: d.count === 1
|
|
48
|
+
? `${d.pkg} pesa ${d.size} en el bootstrap y solo lo importa ${d.importer}`
|
|
49
|
+
: `${d.count} paquetes del bootstrap (${d.size}) que importa un solo fichero tuyo cada uno`,
|
|
50
|
+
body: `Lo descarga <strong>toda carga de la aplicación</strong> y entra por un único fichero tuyo, que no es una pantalla. Un solo importador es una dirección: hay un sitio donde decidir si el paquete hace falta antes de pintar o solo cuando ocurre algo —un inicio de sesión, abrir un diálogo, detectar el navegador—. ${d.list}.`,
|
|
51
|
+
fix: `Si no hace falta para el primer pintado, cambia el import estático de ese fichero por un ${(0, finding_html_1.mono)('await import()')} en el método que lo usa: el paquete sale del bootstrap a un chunk propio que se baja la primera vez que se llama. Con un SDK que hay que inicializar (Firebase, Teams), inicialízalo dentro de esa misma función y guarda la promesa para no repetirlo. Si sí hace falta antes de pintar —un tema, una comprobación de sesión al arrancar—, déjalo: entonces esta señal solo informa.`,
|
|
52
|
+
}),
|
|
36
53
|
commonJs: (d) => ({
|
|
37
54
|
chip: 'paquete en CommonJS',
|
|
38
55
|
title: d.count === 1
|
|
@@ -64,16 +81,20 @@ exports.TEXT = {
|
|
|
64
81
|
fix: 'Comprueba cuánto es comprimido antes de tocarlo: el texto repetitivo baja mucho y puede no compensar. Si crece con cada entrada nueva, al menos vigílalo con un budget de tamaño.',
|
|
65
82
|
}),
|
|
66
83
|
dupeZone: { boot: 'en el bootstrap', shared: 'en un chunk compartido', own: 'en una sola pantalla' },
|
|
67
|
-
dupeCopy: (d) => `<strong>${d.version ? `versión ${d.version}` : d.under ? `copia anidada en ${(0, finding_html_1.mono)(d.under)}` : 'copia principal'}</strong> · ${d.size} · ${d.zone}. ${d.chain ? `Entra por ${d.chain}` : 'No se ha podido seguir desde el punto de entrada'}${d.own ? `; la importa tu código en ${d.own}` : d.via ? `; la importa ${d.via}` : ''}.`,
|
|
84
|
+
dupeCopy: (d) => `<strong>${d.version ? `versión ${d.version}` : d.under ? `copia anidada en ${(0, finding_html_1.mono)(d.under)}` : 'copia principal'}</strong> · ${d.size} · ${d.zone}. ${d.chain ? `Entra por ${d.chain}` : 'No se ha podido seguir desde el punto de entrada'}${d.own ? `; la importa tu código en ${d.own}` : d.via ? `; la importa ${d.via}` : ''}${d.pinned ? `; ${d.pinned.parent} la fija a ${d.pinned.range} exacta` : ''}.`,
|
|
68
85
|
dupes: (d) => ({
|
|
69
86
|
chip: 'copias duplicadas',
|
|
70
87
|
title: `${d.count} paquete${d.count > 1 ? 's' : ''} que viaja${d.count > 1 ? 'n' : ''} más de una vez en el bundle`,
|
|
71
88
|
body: `Se paga el peso dos veces porque dos dependencias piden rangos incompatibles.${d.inBoot
|
|
72
89
|
? ' Una de las copias está en el bootstrap, así que ese peso de más lo descarga todo el mundo.'
|
|
73
90
|
: ''} ${d.list}`,
|
|
74
|
-
fix: d.
|
|
75
|
-
?
|
|
76
|
-
:
|
|
91
|
+
fix: d.pinnedApart
|
|
92
|
+
? `<strong>No se puede deduplicar desde tu proyecto</strong>: ${d.pinnedApart} fija su copia a una versión exacta, y la otra va por otra versión mayor. Forzar una sola con ${(0, finding_html_1.mono)('overrides')} o ${(0, finding_html_1.mono)('resolutions')} es meter un cambio de versión mayor dentro de ${d.pinnedApart}, que no se ha publicado contra esa versión. Lo razonable es aceptar la señal y esperar a que ${d.pinnedApart} se actualice${d.pinnedSame ? `; lo de ${d.pinnedSame} va en la misma versión mayor y ahí un override sí puede valer, probándolo` : ''}.`
|
|
93
|
+
: d.viaDependency
|
|
94
|
+
? `Al menos una de las copias no la pides tú: la importa otra dependencia, así que alinear tu ${(0, finding_html_1.mono)('package.json')} no basta. Fuerza la resolución con ${(0, finding_html_1.mono)('pnpm.overrides')}, ${(0, finding_html_1.mono)('overrides')} (npm) o ${(0, finding_html_1.mono)('resolutions')} (yarn), y comprueba que la versión que dejas vale para las dos${d.pinnedSame
|
|
95
|
+
? `: ${d.pinnedSame} fija su copia a una versión exacta, así que el override cambia una dependencia que esa librería no ha probado`
|
|
96
|
+
: ` —pasa ${(0, finding_html_1.mono)('--lock')} y el informe dirá si alguna está fijada a versión exacta—`}.`
|
|
97
|
+
: `Las dos copias entran por dependencias que pides tú directamente: alinea las versiones en ${(0, finding_html_1.mono)('package.json')} y vuelve a medir.`,
|
|
77
98
|
}),
|
|
78
99
|
heavy: (d) => ({
|
|
79
100
|
chip: d.count === 1 ? 'pantalla cara' : 'pantallas caras',
|
|
@@ -157,7 +178,9 @@ exports.TEXT = {
|
|
|
157
178
|
splitDrift: (d) => ({
|
|
158
179
|
chip: 'el desglose no cuadra con el fichero',
|
|
159
180
|
title: `El desglose por fichero suma un ${d.percent} % de lo que pesan los chunks que describe`,
|
|
160
|
-
body: `Hay dos medidas del mismo chunk y tendrían que dar lo mismo: lo que pesa el fichero (${d.file}) y lo que suman los pesos por fichero de dentro (${d.measured}), sobre ${d.chunks === 1 ? '1 chunk' : `${d.chunks} chunks`}. No lo dan, así que lo que el ${(0, finding_html_1.mono)('stats.json')} dice que hay dentro de un chunk no es una descripción del fichero que se sirve.
|
|
181
|
+
body: `Hay dos medidas del mismo chunk y tendrían que dar lo mismo: lo que pesa el fichero (${d.file}) y lo que suman los pesos por fichero de dentro (${d.measured}), sobre ${d.chunks === 1 ? '1 chunk' : `${d.chunks} chunks`}. No lo dan, así que lo que el ${(0, finding_html_1.mono)('stats.json')} dice que hay dentro de un chunk no es una descripción del fichero que se sirve. ${d.angular
|
|
182
|
+
? '<strong>La causa es el optimizador de chunks de Angular</strong>: después de esbuild vuelve a empaquetar los chunks con Rolldown y reescribe el peso de cada fichero como la longitud de ese paso repartida en proporción, antes de la minificación final. Por eso las partes suman más que el fichero, y en la misma proporción en todos. No son las hojas de estilos de los componentes: esas van dentro del JavaScript y ya están en el peso del fichero.'
|
|
183
|
+
: '<strong>Por qué difieren no se sabe desde aquí</strong> —algo cambió la salida después de escribirlo— y no hace falta saberlo para leer la consecuencia.'} Las cifras de arriba —el arranque, cada pantalla, las idas y vueltas— salen del fichero y son exactas. Las que se miden <strong>dentro</strong> de un chunk —el reparto por paquete, la columna exclusiva, lo que ahorraría un ${(0, finding_html_1.mono)('--what-if')}— salen de esta suma, así que van un ${d.off} % ${d.high ? 'altas' : 'bajas'}.`,
|
|
161
184
|
fix: `Compila con source maps —${(0, finding_html_1.mono)('"sourceMap": true')} en Angular, ${(0, finding_html_1.mono)('sourcemap: true')} en Vite— y suelta la carpeta: cuando hay ${(0, finding_html_1.mono)('.map')} el reparto se mide sobre el fichero generado y esta diferencia desaparece. No hace falta desplegarlos. Mientras tanto, léelas como una cota superior: el orden de la lista es correcto —todas están infladas igual— y la cifra absoluta no lo es.`,
|
|
162
185
|
}),
|
|
163
186
|
sourceMaps: (d) => ({
|
|
@@ -232,7 +255,7 @@ exports.TEXT = {
|
|
|
232
255
|
}),
|
|
233
256
|
media: (d) => ({
|
|
234
257
|
chip: 'imágenes y vídeo',
|
|
235
|
-
title: `${d.size} en ${d.count} ${d.count === 1 ? 'fichero' : 'ficheros'} de imagen o vídeo${d.inPage > 0 ? `, ${d.inPage} de ellos pedidos por la página` : ''}`,
|
|
258
|
+
title: `${d.size} en ${d.count} ${d.count === 1 ? 'fichero' : 'ficheros'} de imagen o vídeo${d.inPage > 0 ? `, ${d.inPage === 1 ? 'uno de ellos pedido' : `${d.inPage} de ellos pedidos`} por la página` : ''}`,
|
|
236
259
|
body: `Aquí no se recomprime nada: prometer «esto en AVIF pesaría 310 kB» sería inventarse una cifra. Se dice lo que pesa, en qué formato llega y si el ${(0, finding_html_1.mono)('index.html')} lo pide de entrada.${d.outdated > 0
|
|
237
260
|
? ` ${d.outdated === 1 ? 'Un fichero llega' : `${d.outdated} ficheros llegan`} en un formato antiguo teniendo el moderno al lado en la misma carpeta: ${d.outdatedList}.`
|
|
238
261
|
: ''} ${d.list}.`,
|
|
@@ -247,8 +270,12 @@ exports.TEXT = {
|
|
|
247
270
|
unreferencedAssets: (d) => ({
|
|
248
271
|
chip: 'ficheros que no alcanza nadie',
|
|
249
272
|
title: `${d.size} en ${d.count === 1 ? '1 fichero que no nombra' : `${d.count} ficheros que no nombra`} ni el HTML, ni el CSS, ni ningún chunk`,
|
|
250
|
-
body: `Es la misma idea que la señal de trozos inalcanzables, un nivel más afuera: se ha buscado cada nombre de fichero en el texto de los demás y estos no salen en ninguno.
|
|
251
|
-
|
|
273
|
+
body: `Es la misma idea que la señal de trozos inalcanzables, un nivel más afuera: se ha buscado cada nombre de fichero en el texto de los demás y estos no salen en ninguno.${d.fromRepo > 0
|
|
274
|
+
? ` <strong>${d.fromRepo === d.count ? (d.count === 1 ? 'No es un resto' : 'No son restos') : `${d.fromRepo} de ${d.count} no son restos`} de un despliegue anterior</strong>: ${d.verified ? (d.fromRepo === 1 ? 'está en' : 'están en') : d.fromRepo === 1 ? 'sale de' : 'salen de'} ${d.folders}, la carpeta que ${(0, finding_html_1.mono)('angular.json')} copia tal cual en cada build${d.verified ? '' : ' (según su configuración de assets)'}, y Angular vacía la carpeta de salida antes de compilar.`
|
|
275
|
+
: ' En una carpeta que nadie limpia suele haber megabytes de despliegues anteriores.'} ${d.list}.`,
|
|
276
|
+
fix: d.fromRepo > 0
|
|
277
|
+
? `Antes de borrar nada, descarta lo que esta búsqueda no ve: una ruta construida en tiempo de ejecución (${(0, finding_html_1.mono)('/assets/ + name + .png')}), un fichero que pide el service worker, el manifiesto o el servidor, o una imagen que solo se enlaza desde fuera (${(0, finding_html_1.mono)('og:image')}, un correo). Lo que quede después, <strong>bórralo del repositorio</strong> —de ${d.folders}—: limpiar la carpeta de build no sirve, porque el siguiente build lo vuelve a copiar.`
|
|
278
|
+
: `Antes de borrar nada, ten en cuenta lo que esta búsqueda no ve: una ruta construida en tiempo de ejecución (${(0, finding_html_1.mono)('/assets/ + name + .png')}), un fichero que pide el service worker o algo que referencia el servidor y no el bundle. Lo que quede después de descartar eso son restos: limpia la carpeta antes de compilar, porque ocupan sitio en el servidor y ensucian cualquier medida de la carpeta.`,
|
|
252
279
|
}),
|
|
253
280
|
inlinedData: (d) => ({
|
|
254
281
|
chip: 'ficheros incrustados como data URI',
|
|
@@ -286,17 +313,29 @@ exports.TEXT = {
|
|
|
286
313
|
title: d.query === ''
|
|
287
314
|
? `${d.count} ${d.count === 1 ? 'fichero no lleva' : 'ficheros no llevan'} hash en el nombre`
|
|
288
315
|
: `Hay ficheros con la versión en la query (${d.query}): se revalidan en cada visita`,
|
|
289
|
-
body: `Un fichero sin hash en el nombre no se puede cachear para siempre: el navegador tiene que preguntar si ha cambiado en cada visita, y esa pregunta cuesta una ida y vuelta aunque la respuesta sea que no. ${d.inPage > 0 ? `${d.inPage} de ellos los pide la página de entrada (${d.size}).` : 'Ninguno lo pide la página de entrada.'} ${d.list}.`,
|
|
316
|
+
body: `Un fichero sin hash en el nombre no se puede cachear para siempre: el navegador tiene que preguntar si ha cambiado en cada visita, y esa pregunta cuesta una ida y vuelta aunque la respuesta sea que no. ${d.inPage > 0 ? `${d.inPage === 1 ? 'Uno de ellos lo pide' : `${d.inPage} de ellos los pide`} la página de entrada (${d.size}).` : 'Ninguno lo pide la página de entrada.'} ${d.list}.`,
|
|
290
317
|
fix: `Casi siempre es informativo: un ${(0, finding_html_1.mono)('favicon.ico')} o un ${(0, finding_html_1.mono)('manifest.webmanifest')} no llevan hash y no hace falta que lo lleven. Cuando salta por algo grande que pide la página, ponle hash en el nombre desde la configuración del build. La versión en la query (${(0, finding_html_1.mono)('?v=3')}) es el caso que casi siempre es un error: cambia la URL de todos los ficheros a la vez en cada despliegue, que es justo lo contrario de lo que hace un hash por fichero.`,
|
|
291
318
|
}),
|
|
292
319
|
// --- lo que dice leer el texto del build (IDEAS §F) ---
|
|
320
|
+
secretBenign: { firebaseConfig: 'configuración web de Firebase: pública por diseño' },
|
|
321
|
+
secretOwner: (pkg) => `es código de ${pkg}`,
|
|
293
322
|
secrets: (d) => ({
|
|
294
|
-
chip:
|
|
323
|
+
chip: d.open > 0
|
|
324
|
+
? 'secretos o direcciones internas en el bundle'
|
|
325
|
+
: 'cadenas con forma de secreto, explicadas',
|
|
295
326
|
title: d.serious > 0
|
|
296
327
|
? `${d.serious === 1 ? 'Una credencial con forma de credencial viaja' : `${d.serious} credenciales con forma de credencial viajan`} en el bundle`
|
|
297
|
-
:
|
|
298
|
-
|
|
299
|
-
|
|
328
|
+
: d.open > 0
|
|
329
|
+
? `${d.open} ${d.open === 1 ? 'coincidencia' : 'coincidencias'} de secreto o dirección interna en el bundle`
|
|
330
|
+
: `${d.count} ${d.count === 1 ? 'cadena con forma de secreto que no lo es' : 'cadenas con forma de secreto que no lo son'}`,
|
|
331
|
+
body: `Cada patrón de aquí identifica un formato concreto por su prefijo y su longitud —${(0, finding_html_1.mono)('AKIA')} y dieciséis caracteres es una clave de AWS y no otra cosa—, a propósito: no hay ninguna regla del tipo «cadena larga cerca de la palabra key». Tipos: ${d.kinds}.${d.publicKeys > 0
|
|
332
|
+
? ` <strong>${d.publicKeys === 1 ? 'La clave de Google es' : `${d.publicKeys} de las claves de Google son`} el ${(0, finding_html_1.mono)('apiKey')} de una configuración web de Firebase</strong>: ${d.publicKeys === 1 ? 'está' : 'están'} junto a ${(0, finding_html_1.mono)('authDomain')}, ${(0, finding_html_1.mono)('projectId')} o ${(0, finding_html_1.mono)('messagingSenderId')}. Esa clave identifica el proyecto ante Google y la lleva toda aplicación web con Firebase; no da acceso a nada por sí sola, así que no es una filtración.`
|
|
333
|
+
: ''}${d.theirs
|
|
334
|
+
? ` Los ${(0, finding_html_1.mono)('process.env')} que quedan son de ${d.theirs}: es el paquete leyendo su propio interruptor, no una variable tuya que el build no sustituyó, y en el navegador se queda en ${(0, finding_html_1.mono)('undefined')}.`
|
|
335
|
+
: ''} Nada se imprime entero: este informe se pega en incidencias, y una herramienta que imprime una clave viva la ha publicado por segunda vez. ${d.list}.`,
|
|
336
|
+
fix: d.open > 0
|
|
337
|
+
? `Si alguna es real, lo primero es <strong>rotarla</strong>, no borrarla del código: lo que está desplegado ya lo tiene cualquiera que sepa la URL, y quitarla del siguiente build no revoca nada. Después, mira cómo entró: casi siempre es un ${(0, finding_html_1.mono)('.env')} que el bundler incrusta porque la variable no empieza por el prefijo público del framework, o una constante de configuración con la clave de servidor en vez de la de cliente. Una dirección interna no es una credencial pero sí es topología: dice qué hay dentro y cómo se llama.`
|
|
338
|
+
: `No hay nada que rotar.${d.publicKeys > 0 ? ' Lo que protege los datos de Firebase son las reglas de seguridad y App Check, no la clave: comprueba que las reglas no estén abiertas y, si quieres, restringe la clave a tus dominios en la consola de Google Cloud.' : ''}${d.theirs ? ` Lo que lee ${d.theirs} no es tuyo: si molesta, ${(0, finding_html_1.mono)('define')} en el build puede fijar esa variable, y en el navegador no cambia nada.` : ''}`,
|
|
300
339
|
}),
|
|
301
340
|
devLeftovers: (d) => ({
|
|
302
341
|
chip: d.unattributed ? 'marcas de desarrollo en la compilación' : 'restos de desarrollo en producción',
|
|
@@ -412,9 +451,9 @@ exports.TEXT = {
|
|
|
412
451
|
}),
|
|
413
452
|
budgetTooHigh: (d) => ({
|
|
414
453
|
chip: 'budget demasiado alto',
|
|
415
|
-
title: `${d.count === 1 ? 'El budget' : 'Los budgets'} de ${d.configs} ${d.count === 1 ? 'está' : 'están'} en ${d.error} y
|
|
416
|
-
body: `Es más de ${d.factor} veces
|
|
417
|
-
fix: 'Baja el error a algo que no quieras cruzar (por ejemplo, un 25 % por encima
|
|
454
|
+
title: `${d.count === 1 ? 'El budget' : 'Los budgets'} de ${d.configs} ${d.count === 1 ? 'está' : 'están'} en ${d.error} y la carga inicial pesa ${d.boot}: no puede saltar`,
|
|
455
|
+
body: `Es más de ${d.factor} veces la carga inicial de hoy: el JavaScript y el CSS iniciales en crudo, que es exactamente lo que suma el budget ${(0, finding_html_1.mono)('initial')} de Angular y la misma cifra sobre la que se calcula el budget sugerido. Un budget así no vigila nada: para llegar a él la aplicación tendría que multiplicar su tamaño.`,
|
|
456
|
+
fix: 'Baja el error a algo que no quieras cruzar (por ejemplo, un 25 % por encima de la carga inicial de hoy) y el aviso algo por debajo. Súbelo solo cuando alguien decida a sabiendas que el arranque tiene que crecer.',
|
|
418
457
|
}),
|
|
419
458
|
budgetWarnOnly: (d) => ({
|
|
420
459
|
chip: 'budget que solo avisa',
|
|
@@ -626,6 +665,12 @@ exports.TEXT = {
|
|
|
626
665
|
en: {
|
|
627
666
|
/** What the entry through the root is called when the measurement matches no screen. */
|
|
628
667
|
rootScreen: 'the root',
|
|
668
|
+
andMore: (count) => `and ${count} more`,
|
|
669
|
+
inPage: 'asked for by the page',
|
|
670
|
+
each: 'each',
|
|
671
|
+
fileCount: (count) => `${count} ${count === 1 ? 'file' : 'files'}`,
|
|
672
|
+
packageBarrelRow: (files, entries, size, inBoot) => `${files} ${files === 1 ? 'file' : 'files'} in, ${entries} imported from outside, ${size}${inBoot ? ' (bootstrap)' : ''}`,
|
|
673
|
+
ownBarrelRow: (reexports, pulls, size) => `${reexports} re-exports, ${pulls} ${pulls === 1 ? 'file' : 'files'}, ${size}`,
|
|
629
674
|
shared: (d) => ({
|
|
630
675
|
chip: 'common code marked as lazy',
|
|
631
676
|
title: `${d.size} downloaded by ${d.screens} of your ${d.total} screens`,
|
|
@@ -640,6 +685,14 @@ exports.TEXT = {
|
|
|
640
685
|
: ''}`,
|
|
641
686
|
fix: `Move its registration out of the bootstrap config and into that route’s providers${d.routes ? `, in ${d.routes}, where the screen is loaded from` : ', inside a lazy routes file'}. One side effect to keep in mind: if you have guards comparing against ${(0, finding_html_1.mono)('routeConfig.path')}, keep the guard on the parent route, because once nested the child gets ${(0, finding_html_1.mono)("path: ''")} and the guard stops recognising it.`,
|
|
642
687
|
}),
|
|
688
|
+
bootSingle: (d) => ({
|
|
689
|
+
chip: 'bootstrap package with a single importer',
|
|
690
|
+
title: d.count === 1
|
|
691
|
+
? `${d.pkg} weighs ${d.size} in the bootstrap and only ${d.importer} imports it`
|
|
692
|
+
: `${d.count} bootstrap packages (${d.size}) that one file of yours imports each`,
|
|
693
|
+
body: `<strong>Every load of the app</strong> downloads it, and it comes in through a single file of yours that is not a screen. One importer is an address: there is one place to decide whether the package is needed before the first paint or only when something happens — signing in, opening a dialog, sniffing the browser. ${d.list}.`,
|
|
694
|
+
fix: `If it is not needed for the first paint, turn that file's static import into an ${(0, finding_html_1.mono)('await import()')} in the method that uses it: the package leaves the bootstrap for a chunk of its own, downloaded the first time that method runs. With an SDK that has to be initialised (Firebase, Teams), initialise it inside that same function and keep the promise so it runs once. If it is needed before the first paint — a theme, a session check at start-up — leave it: then this signal is only information.`,
|
|
695
|
+
}),
|
|
643
696
|
commonJs: (d) => ({
|
|
644
697
|
chip: 'CommonJS package',
|
|
645
698
|
title: d.count === 1
|
|
@@ -671,14 +724,18 @@ exports.TEXT = {
|
|
|
671
724
|
fix: 'Check the compressed size before touching it: repetitive text compresses very well and the change may not pay off. If it grows with every new entry, at least put a size budget on it.',
|
|
672
725
|
}),
|
|
673
726
|
dupeZone: { boot: 'in the bootstrap', shared: 'in a shared chunk', own: 'in a single screen' },
|
|
674
|
-
dupeCopy: (d) => `<strong>${d.version ? `version ${d.version}` : d.under ? `copy nested inside ${(0, finding_html_1.mono)(d.under)}` : 'top-level copy'}</strong> · ${d.size} · ${d.zone}. ${d.chain ? `Comes in through ${d.chain}` : 'Could not be followed from the entry point'}${d.own ? `; your own code imports it in ${d.own}` : d.via ? `; ${d.via} imports it` : ''}.`,
|
|
727
|
+
dupeCopy: (d) => `<strong>${d.version ? `version ${d.version}` : d.under ? `copy nested inside ${(0, finding_html_1.mono)(d.under)}` : 'top-level copy'}</strong> · ${d.size} · ${d.zone}. ${d.chain ? `Comes in through ${d.chain}` : 'Could not be followed from the entry point'}${d.own ? `; your own code imports it in ${d.own}` : d.via ? `; ${d.via} imports it` : ''}${d.pinned ? `; ${d.pinned.parent} pins it to exactly ${d.pinned.range}` : ''}.`,
|
|
675
728
|
dupes: (d) => ({
|
|
676
729
|
chip: 'duplicate copies',
|
|
677
730
|
title: `${d.count} package${d.count > 1 ? 's' : ''} shipped more than once`,
|
|
678
731
|
body: `You pay the weight twice because two dependencies ask for incompatible ranges.${d.inBoot ? ' One of the copies is in the bootstrap, so everybody downloads that extra weight.' : ''} ${d.list}`,
|
|
679
|
-
fix: d.
|
|
680
|
-
?
|
|
681
|
-
:
|
|
732
|
+
fix: d.pinnedApart
|
|
733
|
+
? `<strong>This cannot be deduplicated from your project</strong>: ${d.pinnedApart} pins its copy to an exact version, and the other copy is on another major. Forcing a single one with ${(0, finding_html_1.mono)('overrides')} or ${(0, finding_html_1.mono)('resolutions')} puts a major version change inside ${d.pinnedApart}, which was never released against it. The sensible move is to accept the signal and wait for ${d.pinnedApart} to update${d.pinnedSame ? `; the one under ${d.pinnedSame} is on the same major, and an override may work there, once tested` : ''}.`
|
|
734
|
+
: d.viaDependency
|
|
735
|
+
? `At least one copy is not one you asked for: another dependency imports it, so aligning your ${(0, finding_html_1.mono)('package.json')} is not enough. Force the resolution with ${(0, finding_html_1.mono)('pnpm.overrides')}, ${(0, finding_html_1.mono)('overrides')} (npm) or ${(0, finding_html_1.mono)('resolutions')} (yarn), and check that the version you keep works for both${d.pinnedSame
|
|
736
|
+
? `: ${d.pinnedSame} pins its copy to an exact version, so the override changes a dependency that library has not been tested with`
|
|
737
|
+
: ` — pass ${(0, finding_html_1.mono)('--lock')} and the report will say whether any of them is pinned to an exact version`}.`
|
|
738
|
+
: `Both copies come in through dependencies you ask for directly: align the versions in ${(0, finding_html_1.mono)('package.json')} and measure again.`,
|
|
682
739
|
}),
|
|
683
740
|
heavy: (d) => ({
|
|
684
741
|
chip: d.count === 1 ? 'expensive screen' : 'expensive screens',
|
|
@@ -762,7 +819,9 @@ exports.TEXT = {
|
|
|
762
819
|
splitDrift: (d) => ({
|
|
763
820
|
chip: 'the breakdown does not add up to the file',
|
|
764
821
|
title: `The per-file breakdown adds up to ${d.percent} % of what the chunks it describes weigh`,
|
|
765
|
-
body: `There are two measurements of the same chunk and they are supposed to agree: what the file weighs (${d.file}) and what the per-file weights inside it add up to (${d.measured}), over ${d.chunks === 1 ? '1 chunk' : `${d.chunks} chunks`}. They do not, so what the ${(0, finding_html_1.mono)('stats.json')} says is inside a chunk is not an account of the file being served.
|
|
822
|
+
body: `There are two measurements of the same chunk and they are supposed to agree: what the file weighs (${d.file}) and what the per-file weights inside it add up to (${d.measured}), over ${d.chunks === 1 ? '1 chunk' : `${d.chunks} chunks`}. They do not, so what the ${(0, finding_html_1.mono)('stats.json')} says is inside a chunk is not an account of the file being served. ${d.angular
|
|
823
|
+
? "<strong>The cause is Angular's chunk optimizer</strong>: after esbuild it bundles the chunks again with Rolldown and rewrites each file's weight as that pass's length shared out in proportion, before the final minification. That is why the parts add up to more than the file, and by the same factor in every chunk. It is not the component stylesheets: those are inside the JavaScript and already in the file's weight."
|
|
824
|
+
: '<strong>Why they differ cannot be told from here</strong> — something changed the output after it was written — and it does not have to be known to read the consequence.'} The figures above — the bootstrap, each screen, the round trips — come from the file and are exact. The ones measured <strong>inside</strong> a chunk — the breakdown by package, the exclusive column, what a ${(0, finding_html_1.mono)('--what-if')} would save — come from this sum, so they read ${d.off} % ${d.high ? 'high' : 'low'}.`,
|
|
766
825
|
fix: `Build with source maps — ${(0, finding_html_1.mono)('"sourceMap": true')} in Angular, ${(0, finding_html_1.mono)('sourcemap: true')} in Vite — and drop the folder: with ${(0, finding_html_1.mono)('.map')} files the split is measured on the generated file itself and this difference goes away. They do not have to be deployed. Until then, read those figures as an upper bound: the order of the list is right — all of them are inflated by the same ratio — and the absolute number is not.`,
|
|
767
826
|
}),
|
|
768
827
|
sourceMaps: (d) => ({
|
|
@@ -852,8 +911,12 @@ exports.TEXT = {
|
|
|
852
911
|
unreferencedAssets: (d) => ({
|
|
853
912
|
chip: 'files nothing reaches',
|
|
854
913
|
title: `${d.size} in ${d.count === 1 ? '1 file named by' : `${d.count} files named by`} neither the HTML, nor the CSS, nor any chunk`,
|
|
855
|
-
body: `The same idea as the unreachable-chunks signal, one level further out: every file name was searched for in the text of the others, and these appear in none of them.
|
|
856
|
-
|
|
914
|
+
body: `The same idea as the unreachable-chunks signal, one level further out: every file name was searched for in the text of the others, and these appear in none of them.${d.fromRepo > 0
|
|
915
|
+
? ` <strong>${d.fromRepo === d.count ? (d.count === 1 ? 'It is not a leftover' : 'They are not leftovers') : `${d.fromRepo} of ${d.count} are not leftovers`} of an old deploy</strong>: ${d.fromRepo === 1 ? 'it' : 'they'} ${d.verified ? (d.fromRepo === 1 ? 'is in' : 'are in') : d.fromRepo === 1 ? 'comes from' : 'come from'} ${d.folders}, the folder ${(0, finding_html_1.mono)('angular.json')} copies as it is on every build${d.verified ? '' : ' (going by its assets configuration)'}, and Angular empties the output folder before building.`
|
|
916
|
+
: ' A folder nobody cleans usually holds megabytes of previous deploys.'} ${d.list}.`,
|
|
917
|
+
fix: d.fromRepo > 0
|
|
918
|
+
? `Before deleting anything, rule out what this search cannot see: a path built at run time (${(0, finding_html_1.mono)('/assets/ + name + .png')}), a file the service worker, the manifest or the server asks for, or a picture only linked from outside (${(0, finding_html_1.mono)('og:image')}, an email). Whatever is left, <strong>delete it from the repository</strong> — from ${d.folders} —: cleaning the build folder does nothing, because the next build copies it back.`
|
|
919
|
+
: `Before deleting anything, keep in mind what this search cannot see: a path built at run time (${(0, finding_html_1.mono)('/assets/ + name + .png')}), a file the service worker asks for, or something the server references rather than the bundle. What is left after discarding those is leftovers: clean the folder before building, because they take space on the server and skew any measurement of the folder.`,
|
|
857
920
|
}),
|
|
858
921
|
inlinedData: (d) => ({
|
|
859
922
|
chip: 'files embedded as data URIs',
|
|
@@ -891,17 +954,27 @@ exports.TEXT = {
|
|
|
891
954
|
title: d.query === ''
|
|
892
955
|
? `${d.count} ${d.count === 1 ? 'file carries' : 'files carry'} no hash in the name`
|
|
893
956
|
: `Some files carry the version in the query (${d.query}): they revalidate on every visit`,
|
|
894
|
-
body: `A file without a hash in its name cannot be cached for good: the browser has to ask whether it changed on every visit, and that question costs a round trip even when the answer is no. ${d.inPage > 0 ? `${d.inPage} of them are asked for by the page itself (${d.size}).` : 'None of them is asked for by the page itself.'} ${d.list}.`,
|
|
957
|
+
body: `A file without a hash in its name cannot be cached for good: the browser has to ask whether it changed on every visit, and that question costs a round trip even when the answer is no. ${d.inPage > 0 ? `${d.inPage === 1 ? 'One of them is' : `${d.inPage} of them are`} asked for by the page itself (${d.size}).` : 'None of them is asked for by the page itself.'} ${d.list}.`,
|
|
895
958
|
fix: `Almost always informative: a ${(0, finding_html_1.mono)('favicon.ico')} or a ${(0, finding_html_1.mono)('manifest.webmanifest')} carry no hash and do not need one. When it fires on something large the page asks for, hash the name in the build configuration. The version-in-the-query case (${(0, finding_html_1.mono)('?v=3')}) is the one that is nearly always a mistake: it changes the URL of every file at once on every deploy, which is the opposite of what a per-file hash does.`,
|
|
896
959
|
}),
|
|
897
960
|
// --- what reading the text of the build says (IDEAS §F) ---
|
|
961
|
+
secretBenign: { firebaseConfig: 'Firebase web configuration: public by design' },
|
|
962
|
+
secretOwner: (pkg) => `code of ${pkg}`,
|
|
898
963
|
secrets: (d) => ({
|
|
899
|
-
chip: 'secrets or internal addresses in the bundle',
|
|
964
|
+
chip: d.open > 0 ? 'secrets or internal addresses in the bundle' : 'secret-shaped strings, explained',
|
|
900
965
|
title: d.serious > 0
|
|
901
966
|
? `${d.serious === 1 ? 'A string shaped like a credential ships' : `${d.serious} strings shaped like credentials ship`} in the bundle`
|
|
902
|
-
:
|
|
903
|
-
|
|
904
|
-
|
|
967
|
+
: d.open > 0
|
|
968
|
+
? `${d.open} ${d.open === 1 ? 'match' : 'matches'} for a secret or an internal address in the bundle`
|
|
969
|
+
: `${d.count} ${d.count === 1 ? 'string shaped like a secret that is not one' : 'strings shaped like secrets that are not'}`,
|
|
970
|
+
body: `Every pattern here identifies a specific format by its own prefix and length — ${(0, finding_html_1.mono)('AKIA')} plus sixteen characters is an AWS key and nothing else — deliberately: there is no rule for "a long string near the word key". Kinds: ${d.kinds}.${d.publicKeys > 0
|
|
971
|
+
? ` <strong>${d.publicKeys === 1 ? 'The Google key is' : `${d.publicKeys} of the Google keys are`} the ${(0, finding_html_1.mono)('apiKey')} of a Firebase web configuration</strong>: ${d.publicKeys === 1 ? 'it sits' : 'they sit'} next to ${(0, finding_html_1.mono)('authDomain')}, ${(0, finding_html_1.mono)('projectId')} or ${(0, finding_html_1.mono)('messagingSenderId')}. That key identifies the project to Google and every web app using Firebase ships it; on its own it grants access to nothing, so it is not a leak.`
|
|
972
|
+
: ''}${d.theirs
|
|
973
|
+
? ` The ${(0, finding_html_1.mono)('process.env')} left in belong to ${d.theirs}: the package reading its own switch, not a variable of yours the build failed to substitute, and in a browser it stays ${(0, finding_html_1.mono)('undefined')}.`
|
|
974
|
+
: ''} Nothing is printed whole: this report gets pasted into issues, and a tool that prints a live credential in full has published it a second time. ${d.list}.`,
|
|
975
|
+
fix: d.open > 0
|
|
976
|
+
? `If any of them is real, the first move is to <strong>rotate</strong> it, not to delete it from the code: what is deployed is already in the hands of anybody who knows the URL, and taking it out of the next build revokes nothing. Then look at how it got in: almost always a ${(0, finding_html_1.mono)('.env')} the bundler inlines because the variable does not start with the framework's public prefix, or a configuration constant holding the server key instead of the client one. An internal address is not a credential, but it is topology: it says what is inside and what it is called.`
|
|
977
|
+
: `There is nothing to rotate.${d.publicKeys > 0 ? ' What protects Firebase data is the security rules and App Check, not the key: check that the rules are not open and, if you like, restrict the key to your domains in the Google Cloud console.' : ''}${d.theirs ? ` What ${d.theirs} reads is not yours: if it bothers you, ${(0, finding_html_1.mono)('define')} in the build can pin that variable, and it changes nothing in the browser.` : ''}`,
|
|
905
978
|
}),
|
|
906
979
|
devLeftovers: (d) => ({
|
|
907
980
|
chip: d.unattributed ? 'development markers in the build' : 'development leftovers in production',
|
|
@@ -1017,9 +1090,9 @@ exports.TEXT = {
|
|
|
1017
1090
|
}),
|
|
1018
1091
|
budgetTooHigh: (d) => ({
|
|
1019
1092
|
chip: 'budget too high',
|
|
1020
|
-
title: `The ${d.configs} ${d.count === 1 ? 'budget is' : 'budgets are'} ${d.error} and the
|
|
1021
|
-
body: `That is more than ${d.factor} times the
|
|
1022
|
-
fix: 'Lower the error to something you do not want to cross (say 25 % above the
|
|
1093
|
+
title: `The ${d.configs} ${d.count === 1 ? 'budget is' : 'budgets are'} ${d.error} and the initial load weighs ${d.boot}: ${d.count === 1 ? 'it' : 'they'} cannot fire`,
|
|
1094
|
+
body: `That is more than ${d.factor} times today's initial load: the initial JavaScript and CSS, raw, which is exactly what Angular's ${(0, finding_html_1.mono)('initial')} budget adds up and the same figure the suggested budget is computed from. A budget like that watches nothing: the app would have to multiply its size to reach it.`,
|
|
1095
|
+
fix: 'Lower the error to something you do not want to cross (say 25 % above the initial load today) and the warning a little below. Raise it only when someone knowingly decides the start-up has to grow.',
|
|
1023
1096
|
}),
|
|
1024
1097
|
budgetWarnOnly: (d) => ({
|
|
1025
1098
|
chip: 'budget that only warns',
|
|
@@ -5,7 +5,9 @@ const criteria_1 = require("../criteria/criteria");
|
|
|
5
5
|
const format_utils_1 = require("../format/format.utils");
|
|
6
6
|
const project_context_1 = require("../project/project-context");
|
|
7
7
|
const situation_1 = require("../situation/situation");
|
|
8
|
+
const boot_single_1 = require("./boot-single");
|
|
8
9
|
const caching_1 = require("./caching");
|
|
10
|
+
const dupes_1 = require("./dupes");
|
|
9
11
|
const finding_html_1 = require("./finding-html");
|
|
10
12
|
const finding_text_1 = require("./finding-text");
|
|
11
13
|
const graph_1 = require("./graph");
|
|
@@ -29,7 +31,13 @@ const buildFindings = (analysis, lang, mode, c = criteria_1.RECOMMENDED[mode],
|
|
|
29
31
|
* from here — the shape of the hash cascade, whose severity is not a property of the build —
|
|
30
32
|
* and it defaults to nobody having answered, which is what every caller did before it existed.
|
|
31
33
|
*/
|
|
32
|
-
situation = situation_1.EMPTY_SITUATION
|
|
34
|
+
situation = situation_1.EMPTY_SITUATION,
|
|
35
|
+
/**
|
|
36
|
+
* What each package declares as its dependencies, from the lock file or from `node_modules`.
|
|
37
|
+
* It reaches one signal: whether a duplicate is pinned to an exact version by its parent, which
|
|
38
|
+
* turns "force the resolution" from advice into a breaking change.
|
|
39
|
+
*/
|
|
40
|
+
declared = null) => {
|
|
33
41
|
const text = finding_text_1.TEXT[lang];
|
|
34
42
|
const findings = [];
|
|
35
43
|
const totalScreens = analysis.screens.length;
|
|
@@ -91,6 +99,10 @@ situation = situation_1.EMPTY_SITUATION) => {
|
|
|
91
99
|
}),
|
|
92
100
|
});
|
|
93
101
|
}
|
|
102
|
+
// 2b · The same package, imported by a single file of yours that everybody runs: a candidate for
|
|
103
|
+
// an `await import()` where it is used. Its own module, like the folder version below.
|
|
104
|
+
const lazyFlagged = new Set(findings.filter(finding => finding.kind === 'bootLazy').map(f => f.target?.key ?? ''));
|
|
105
|
+
findings.push(...(0, boot_single_1.buildBootSingleFindings)(analysis, lang, c, lazyFlagged));
|
|
94
106
|
// 3 · Own files too large inside the bootstrap: one signal listing all of them, no cut-off.
|
|
95
107
|
const bigFiles = analysis.ownFilesInBoot.filter(file => file.bytes > c.bigOwnFileBytes);
|
|
96
108
|
const first = bigFiles[0];
|
|
@@ -110,38 +122,9 @@ situation = situation_1.EMPTY_SITUATION) => {
|
|
|
110
122
|
}),
|
|
111
123
|
});
|
|
112
124
|
}
|
|
113
|
-
// 4 · Two versions of the same package, each copy followed to whatever brings it in
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
if (firstDupe) {
|
|
117
|
-
const list = analysis.duplicates
|
|
118
|
-
.map(dupe => {
|
|
119
|
-
const copies = dupe.copies
|
|
120
|
-
.map(copy => text.dupeCopy({
|
|
121
|
-
version: copy.version,
|
|
122
|
-
under: copy.under,
|
|
123
|
-
size: (0, format_utils_1.formatBytes)(copy.bytes),
|
|
124
|
-
zone: text.dupeZone[copy.zone],
|
|
125
|
-
chain: copy.chain ? (0, finding_html_1.chainHtml)((0, format_utils_1.chainSteps)(copy.chain)) : null,
|
|
126
|
-
own: copy.importers.length > 0 ? copy.importers.map(file => (0, finding_html_1.mono)(file)).join(', ') : null,
|
|
127
|
-
via: copy.viaPackages.length > 0 ? copy.viaPackages.map(pkg => (0, finding_html_1.mono)(pkg)).join(', ') : null,
|
|
128
|
-
}))
|
|
129
|
-
.join(' ');
|
|
130
|
-
return `<strong>${dupe.name}</strong> — ${copies}`;
|
|
131
|
-
})
|
|
132
|
-
.join(' ');
|
|
133
|
-
findings.push({
|
|
134
|
-
severity: 'mid',
|
|
135
|
-
target: { tab: 'search', key: firstDupe.name },
|
|
136
|
-
kind: 'dupes',
|
|
137
|
-
...text.dupes({
|
|
138
|
-
count: analysis.duplicates.length,
|
|
139
|
-
list,
|
|
140
|
-
viaDependency: analysis.duplicates.some(dupe => dupe.copies.some(copy => copy.importers.length === 0)),
|
|
141
|
-
inBoot: analysis.duplicates.some(dupe => dupe.inBoot),
|
|
142
|
-
}),
|
|
143
|
-
});
|
|
144
|
-
}
|
|
125
|
+
// 4 · Two versions of the same package, each copy followed to whatever brings it in — and, when
|
|
126
|
+
// the ranges are known, whether a parent pins its copy so it cannot be moved at all.
|
|
127
|
+
findings.push(...(0, dupes_1.buildDupesFindings)(analysis, lang, declared));
|
|
145
128
|
// 5 · A screen much more expensive than the rest.
|
|
146
129
|
if (analysis.screens.length >= c.heavyScreenMinScreens) {
|
|
147
130
|
const owns = analysis.screens.map(screen => screen.own).toSorted((a, b) => a - b);
|
|
@@ -355,7 +338,8 @@ const buildComparisonFindings = (comparison, lang, c) => {
|
|
|
355
338
|
exports.buildComparisonFindings = buildComparisonFindings;
|
|
356
339
|
/**
|
|
357
340
|
* What `angular.json`, `package.json` and the pipeline say. The budget signals compare against
|
|
358
|
-
* the raw
|
|
341
|
+
* the raw initial load — JavaScript and the global stylesheet — because that is what Angular's
|
|
342
|
+
* `initial` budget adds up, whatever the report shows, and it is the figure the suggestion uses.
|
|
359
343
|
*/
|
|
360
344
|
const buildContextFindings = (context, analysis, lang, c) => {
|
|
361
345
|
const text = finding_text_1.TEXT[lang];
|
|
@@ -382,7 +366,7 @@ const buildContextFindings = (context, analysis, lang, c) => {
|
|
|
382
366
|
...text.budgetNone({ configs: names(rows) }),
|
|
383
367
|
});
|
|
384
368
|
}
|
|
385
|
-
else if (known && built.length > 0 && strictest
|
|
369
|
+
else if (known && built.length > 0 && strictest?.builtBy.length === 0) {
|
|
386
370
|
findings.push({
|
|
387
371
|
severity: 'high',
|
|
388
372
|
target: { tab: 'project', key: strictest.name },
|
|
@@ -418,8 +402,8 @@ const buildContextFindings = (context, analysis, lang, c) => {
|
|
|
418
402
|
});
|
|
419
403
|
}
|
|
420
404
|
const tooHigh = examined.filter(row => row.error !== null &&
|
|
421
|
-
analysis.
|
|
422
|
-
row.error >= analysis.
|
|
405
|
+
analysis.initialRawBytes > 0 &&
|
|
406
|
+
row.error >= analysis.initialRawBytes * c.budgetSlackFactor);
|
|
423
407
|
const byError = groupBy(tooHigh, row => row.error ?? 0);
|
|
424
408
|
for (const [error, group] of byError) {
|
|
425
409
|
findings.push({
|
|
@@ -430,7 +414,7 @@ const buildContextFindings = (context, analysis, lang, c) => {
|
|
|
430
414
|
configs: plainNames(group),
|
|
431
415
|
count: group.length,
|
|
432
416
|
error: (0, format_utils_1.formatBytes)(error),
|
|
433
|
-
boot: (0, format_utils_1.formatBytes)(analysis.
|
|
417
|
+
boot: (0, format_utils_1.formatBytes)(analysis.initialRawBytes),
|
|
434
418
|
factor: c.budgetSlackFactor,
|
|
435
419
|
}),
|
|
436
420
|
});
|
|
@@ -62,9 +62,9 @@ const buildGraphFindings = (analysis, lang, c) => {
|
|
|
62
62
|
name: worstBarrel.path,
|
|
63
63
|
pulls: worstBarrel.pulls,
|
|
64
64
|
size: (0, format_utils_1.formatBytes)(worstBarrel.exclusive),
|
|
65
|
-
importers:
|
|
65
|
+
importers: (0, finding_html_1.fewNamed)(worstBarrel.importers.map(file => (0, format_utils_1.baseName)(file)), text.andMore),
|
|
66
66
|
list: barrels
|
|
67
|
-
.map(barrel => `${(0, finding_html_1.mono)(barrel.path)} — ${barrel.reexports
|
|
67
|
+
.map(barrel => `${(0, finding_html_1.mono)(barrel.path)} — ${text.ownBarrelRow(barrel.reexports, barrel.pulls, (0, format_utils_1.formatBytes)(barrel.exclusive))}`)
|
|
68
68
|
.join(' · '),
|
|
69
69
|
}),
|
|
70
70
|
});
|
|
@@ -83,9 +83,9 @@ const buildGraphFindings = (analysis, lang, c) => {
|
|
|
83
83
|
files: worstPackage.files,
|
|
84
84
|
entryPoints: worstPackage.entryPoints,
|
|
85
85
|
size: (0, format_utils_1.formatBytes)(worstPackage.bytes),
|
|
86
|
-
importers:
|
|
86
|
+
importers: (0, finding_html_1.fewNamed)(worstPackage.importers.map(file => (0, format_utils_1.baseName)(file)), text.andMore),
|
|
87
87
|
list: packages
|
|
88
|
-
.map(pkg => `${(0, finding_html_1.mono)(pkg.name)} — ${pkg.files
|
|
88
|
+
.map(pkg => `${(0, finding_html_1.mono)(pkg.name)} — ${text.packageBarrelRow(pkg.files, pkg.entryPoints, (0, format_utils_1.formatBytes)(pkg.bytes), pkg.inBoot)}`)
|
|
89
89
|
.join(' · '),
|
|
90
90
|
}),
|
|
91
91
|
});
|
|
@@ -23,18 +23,28 @@ const buildScanFindings = (scan, lang, c) => {
|
|
|
23
23
|
// no rule for "a long string near the word key", which is what makes a security signal noisy
|
|
24
24
|
// and then switched off.
|
|
25
25
|
const secrets = scan.secrets;
|
|
26
|
-
|
|
26
|
+
// A Firebase web `apiKey` is public by design, and a `process.env.X` inside a package is that
|
|
27
|
+
// package reading its own switch. Both are said, with the reason, and neither raises the card:
|
|
28
|
+
// a security signal that cries wolf on every Firebase app is one somebody switches off.
|
|
29
|
+
const explained = (match) => !!match.benign || !!match.owner;
|
|
30
|
+
const serious = secrets.filter(match => ALWAYS_SERIOUS.has(match.kind) && !explained(match));
|
|
31
|
+
const open = secrets.filter(match => !explained(match));
|
|
27
32
|
const first = secrets[0];
|
|
28
33
|
if (first) {
|
|
34
|
+
const publicKeys = secrets.filter(match => match.benign === 'firebaseConfig');
|
|
35
|
+
const theirs = secrets.filter(match => !!match.owner);
|
|
29
36
|
findings.push({
|
|
30
|
-
severity: serious.length > 0 ? 'high' : 'mid',
|
|
37
|
+
severity: serious.length > 0 ? 'high' : open.length > 0 ? 'mid' : 'info',
|
|
31
38
|
kind: 'secrets',
|
|
32
39
|
...text.secrets({
|
|
33
40
|
count: secrets.length,
|
|
34
41
|
serious: serious.length,
|
|
42
|
+
open: open.length,
|
|
43
|
+
publicKeys: publicKeys.length,
|
|
44
|
+
theirs: [...new Set(theirs.map(match => match.owner ?? ''))].map(pkg => (0, finding_html_1.mono)(pkg)).join(', '),
|
|
35
45
|
kinds: [...new Set(secrets.map(match => match.kind))].join(', '),
|
|
36
46
|
list: secrets
|
|
37
|
-
.map(match => `${(0, finding_html_1.mono)(match.kind)} ${match.redacted} (${(0, finding_html_1.mono)(match.chunk)}${match.count > 1 ? `, ×${match.count}` : ''})`)
|
|
47
|
+
.map(match => `${(0, finding_html_1.mono)(match.kind)} ${match.redacted} (${(0, finding_html_1.mono)(match.chunk)}${match.count > 1 ? `, ×${match.count}` : ''}${match.benign ? `, ${text.secretBenign[match.benign]}` : ''}${match.owner ? `, ${text.secretOwner((0, finding_html_1.mono)(match.owner))}` : ''})`)
|
|
38
48
|
.join(' · '),
|
|
39
49
|
}),
|
|
40
50
|
});
|
|
@@ -23,7 +23,7 @@ const finding_text_1 = require("./finding-text");
|
|
|
23
23
|
* files is what keeps the count right — `date-fns` splits one language across ten files under
|
|
24
24
|
* `locale/en-US/_lib/`, and counting those would report ten languages where there is one.
|
|
25
25
|
*/
|
|
26
|
-
const LOCALE_CODE = /^
|
|
26
|
+
const LOCALE_CODE = /^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})?$/;
|
|
27
27
|
/**
|
|
28
28
|
* What a library calls the folder it keeps its languages in. `locale` and `locales` were the whole
|
|
29
29
|
* list, which quietly meant that a package shipping them under `i18n/` — which plenty do — raised
|
|
@@ -145,10 +145,7 @@ exports.buildShippedFindings = buildShippedFindings;
|
|
|
145
145
|
*/
|
|
146
146
|
const unnamedScreen = (label) => {
|
|
147
147
|
const rest = label.replace(/^chunk[-._]/i, '');
|
|
148
|
-
|
|
149
|
-
return true;
|
|
150
|
-
}
|
|
151
|
-
return /^[\dA-Za-z_-]{6,}$/.test(rest) && /[a-z]/.test(rest) && /[A-Z]/.test(rest) && /\d/.test(rest);
|
|
148
|
+
return rest !== label || (/^[\w-]{6,}$/.test(rest) && /[a-z]/.test(rest) && /[A-Z]/.test(rest) && /\d/.test(rest));
|
|
152
149
|
};
|
|
153
150
|
/**
|
|
154
151
|
* How far the two measurements of the same chunks have to be apart before it is worth a line.
|
|
@@ -201,6 +198,7 @@ const driftFinding = (drift, lang) => {
|
|
|
201
198
|
chunks: drift.chunks,
|
|
202
199
|
file: (0, format_utils_1.formatBytes)(drift.file),
|
|
203
200
|
measured: (0, format_utils_1.formatBytes)(drift.measured),
|
|
201
|
+
angular: drift.angular === true,
|
|
204
202
|
}),
|
|
205
203
|
},
|
|
206
204
|
];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/** Presentation helpers and metafile path normalisation. */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.formatDelta = exports.elidePath = exports.screenLabel = exports.SOURCE_EXTENSION = exports.ROUTE_SUFFIXES = exports.VIEW_SUFFIXES = exports.projectFolderOf = exports.chainSteps = exports.packageOf = exports.shortName = exports.baseName = exports.formatCount = exports.formatBytes = exports.setNumberLang = void 0;
|
|
4
|
+
exports.formatDelta = exports.elidePath = exports.screenLabel = exports.SOURCE_EXTENSION = exports.ROUTE_SUFFIXES = exports.VIEW_SUFFIXES = exports.projectFolderOf = exports.chainSteps = exports.packageOf = exports.shortName = exports.baseName = exports.formatCount = exports.formatBytes = exports.setUnitSpace = exports.setNumberLang = void 0;
|
|
5
5
|
const KB = 1024;
|
|
6
6
|
/**
|
|
7
7
|
* The language the figures are written in. It only decides the decimal separator, and it is set
|
|
@@ -12,7 +12,7 @@ const KB = 1024;
|
|
|
12
12
|
const formatter = (lang) => new Intl.NumberFormat(lang, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
13
13
|
/** The same thing for figures that are not sizes, where two decimals would be false precision. */
|
|
14
14
|
const counter = (lang) => new Intl.NumberFormat(lang, { maximumFractionDigits: 1 });
|
|
15
|
-
const numbers = { lang: 'en', decimals: formatter('en'), counts: counter('en') };
|
|
15
|
+
const numbers = { lang: 'en', decimals: formatter('en'), counts: counter('en'), unitSpace: ' ' };
|
|
16
16
|
const setNumberLang = (lang) => {
|
|
17
17
|
if (lang === numbers.lang) {
|
|
18
18
|
return;
|
|
@@ -22,6 +22,15 @@ const setNumberLang = (lang) => {
|
|
|
22
22
|
numbers.counts = counter(lang);
|
|
23
23
|
};
|
|
24
24
|
exports.setNumberLang = setNumberLang;
|
|
25
|
+
/**
|
|
26
|
+
* What goes between a size and its unit. A plain space for the command, whose output is a terminal
|
|
27
|
+
* and plain text. The page sets a narrow no-break space (U+202F): "736 kB" must never break across
|
|
28
|
+
* two lines, and in the monospace face a full space reads as a double gap between figure and unit.
|
|
29
|
+
*/
|
|
30
|
+
const setUnitSpace = (space) => {
|
|
31
|
+
numbers.unitSpace = space;
|
|
32
|
+
};
|
|
33
|
+
exports.setUnitSpace = setUnitSpace;
|
|
25
34
|
/**
|
|
26
35
|
* Human-readable size. Stays in kB up to the megabyte so columns compare at a glance.
|
|
27
36
|
*
|
|
@@ -31,12 +40,10 @@ exports.setNumberLang = setNumberLang;
|
|
|
31
40
|
*/
|
|
32
41
|
const formatBytes = (bytes) => {
|
|
33
42
|
if (bytes >= KB * KB) {
|
|
34
|
-
return `${numbers.decimals.format(bytes / KB / KB)}
|
|
35
|
-
}
|
|
36
|
-
if (bytes >= KB) {
|
|
37
|
-
return `${Math.round(bytes / KB)} kB`;
|
|
43
|
+
return `${numbers.decimals.format(bytes / KB / KB)}${numbers.unitSpace}MB`;
|
|
38
44
|
}
|
|
39
|
-
|
|
45
|
+
const space = numbers.unitSpace;
|
|
46
|
+
return bytes >= KB ? `${Math.round(bytes / KB)}${space}kB` : `${bytes}${space}B`;
|
|
40
47
|
};
|
|
41
48
|
exports.formatBytes = formatBytes;
|
|
42
49
|
/**
|
|
@@ -143,7 +150,7 @@ const EXTENSION = new RegExp(String.raw `\.${exports.SOURCE_EXTENSION}$`);
|
|
|
143
150
|
* SvelteKit names a route file by its role and the route by its folder: `+page.svelte` in every
|
|
144
151
|
* one of them. Left alone, three screens came out as three rows called `+page.svelte`.
|
|
145
152
|
*/
|
|
146
|
-
const
|
|
153
|
+
const ROLE_PREFIX = '+';
|
|
147
154
|
/** Folders that are the root of the routes rather than one route: there the file name is all there is. */
|
|
148
155
|
const ROUTE_ROOTS = new Set(['routes', 'pages', 'app', 'src']);
|
|
149
156
|
/**
|
|
@@ -153,7 +160,7 @@ const ROUTE_ROOTS = new Set(['routes', 'pages', 'app', 'src']);
|
|
|
153
160
|
*/
|
|
154
161
|
const screenLabel = (source) => {
|
|
155
162
|
const name = (0, exports.baseName)(source).replace(SUFFIX, '').replace(EXTENSION, '') || (0, exports.baseName)(source);
|
|
156
|
-
if (!
|
|
163
|
+
if (!name.startsWith(ROLE_PREFIX)) {
|
|
157
164
|
return name;
|
|
158
165
|
}
|
|
159
166
|
const folder = source.split('/').at(-2) ?? '';
|