@dcaldeira/tooling 0.2.0 → 0.2.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/checks/bundle.mjs +4 -2
- package/config.schema.json +22 -0
- package/package.json +1 -1
package/checks/bundle.mjs
CHANGED
|
@@ -101,10 +101,12 @@ export function analyseBundle(root, budget) {
|
|
|
101
101
|
if (error.code !== 'ENOENT') throw error;
|
|
102
102
|
}
|
|
103
103
|
const size = gzip(file) / 1024;
|
|
104
|
-
|
|
104
|
+
// A file with no source map, such as a pre-built worker, gets its allowance by path.
|
|
105
|
+
const allowed = vendor ?? (budget.files ?? []).find(([part]) => file.includes(part));
|
|
106
|
+
const cap = allowed ? allowed[2] : budget.chunkKB;
|
|
105
107
|
if (size > cap)
|
|
106
108
|
errors.push(
|
|
107
|
-
`${file} (${
|
|
109
|
+
`${file} (${allowed ? allowed[1] : 'route chunk'}) ${size.toFixed(1)} KB > ${cap} KB`,
|
|
108
110
|
);
|
|
109
111
|
}
|
|
110
112
|
return { initialKB, initial: [...initial], chunks: chunks.length, errors };
|
package/config.schema.json
CHANGED
|
@@ -403,6 +403,28 @@
|
|
|
403
403
|
}
|
|
404
404
|
]
|
|
405
405
|
}
|
|
406
|
+
},
|
|
407
|
+
"files": {
|
|
408
|
+
"type": "array",
|
|
409
|
+
"items": {
|
|
410
|
+
"type": "array",
|
|
411
|
+
"minItems": 3,
|
|
412
|
+
"maxItems": 3,
|
|
413
|
+
"prefixItems": [
|
|
414
|
+
{
|
|
415
|
+
"type": "string",
|
|
416
|
+
"minLength": 1
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
"type": "string",
|
|
420
|
+
"minLength": 1
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
"type": "number",
|
|
424
|
+
"exclusiveMinimum": 0
|
|
425
|
+
}
|
|
426
|
+
]
|
|
427
|
+
}
|
|
406
428
|
}
|
|
407
429
|
}
|
|
408
430
|
}
|