heximon 0.35.2 → 0.36.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/README.md +5 -1
- package/dist/bin.mjs +181 -38
- package/dist/index.d.mts +14 -0
- package/package.json +18 -18
package/README.md
CHANGED
|
@@ -260,7 +260,11 @@ the fix instructions plus a non-zero exit code.
|
|
|
260
260
|
and the libraries that the heavy entries load most. It also lists each async registry of a library with its
|
|
261
261
|
contributors and the code that its first `load()` call adds. A row whose libraries own such a registry has an "On read" figure,
|
|
262
262
|
which the bytes of the row do not count. The code of a library starts at the chunk of its generated loader;
|
|
263
|
-
without one, the report uses the chunks of its npm package and says so.
|
|
263
|
+
without one, the report uses the chunks of its npm package and says so. Of the factories in a package
|
|
264
|
+
barrel (and of the construction chunks of a lazy library), a row counts only the code of the modules that the
|
|
265
|
+
entry loads. Code that only another `import()`
|
|
266
|
+
reaches can load later or never: the row gives it apart as "only through an import()" (`uncertain` in
|
|
267
|
+
`--json`), so that row is an upper bound. `--top <n>`
|
|
264
268
|
limits the rows, and `--json` carries the same data in `startupEntries`. The report fails nothing, and
|
|
265
269
|
`heximon.startup.json` does not record it.
|
|
266
270
|
- **`heximon workflows` still reports a breaking upgrade verdict per workflow.** The verdict comes out of a
|
package/dist/bin.mjs
CHANGED
|
@@ -1415,6 +1415,15 @@ var StartupBaseline = class StartupBaseline {
|
|
|
1415
1415
|
};
|
|
1416
1416
|
//#endregion
|
|
1417
1417
|
//#region src/startup-built-code.ts
|
|
1418
|
+
/** What a walk does with one `import()` of a file. */
|
|
1419
|
+
const ImportEdge = {
|
|
1420
|
+
/** The walk follows it: the packages of the walk run it. */
|
|
1421
|
+
Follow: "follow",
|
|
1422
|
+
/** The walk follows it, but the target can load later or never. */
|
|
1423
|
+
Uncertain: "uncertain",
|
|
1424
|
+
/** The walk does not follow it: it loads another package, or the factory of a module outside the walk. */
|
|
1425
|
+
Skip: "skip"
|
|
1426
|
+
};
|
|
1418
1427
|
/**
|
|
1419
1428
|
* The built server code of one entry, as the size walk read it, with the packages of each file. It finds the
|
|
1420
1429
|
* files that hold the code of a package, and the files that some files load when they run.
|
|
@@ -1425,12 +1434,25 @@ var StartupBaseline = class StartupBaseline {
|
|
|
1425
1434
|
* the `node_modules` directory of the package in the output, without the files that only the other roots of the
|
|
1426
1435
|
* package reach. From these files, the code of a package is every file that they import, with a static import or
|
|
1427
1436
|
* with `import()`, up to the loader chunk of another package.
|
|
1437
|
+
*
|
|
1438
|
+
* A package barrel has one `import()` for the factory of each module of the package:
|
|
1439
|
+
* `(await import("./create-orders.module.js")).createOrdersModule(...inputs)`. The factory of a lazy library
|
|
1440
|
+
* loads its construction chunk: `import("./internal/orders.module.chunk.js").then((chunk) =>
|
|
1441
|
+
* chunk.construct(inputs))` in `createOrdersModule`. The walk follows such an `import()` only for a module of the
|
|
1442
|
+
* walk, also when the barrel is loaded already. Another `import()` in the code of a package can load later or
|
|
1443
|
+
* never: the walk follows it, and counts its files as uncertain.
|
|
1428
1444
|
*/
|
|
1429
1445
|
var StartupBuiltCode = class StartupBuiltCode {
|
|
1430
1446
|
measured;
|
|
1431
1447
|
chunks;
|
|
1432
1448
|
/** The directory of the installed packages in a path of the output. */
|
|
1433
1449
|
static packageDirectory = "node_modules/";
|
|
1450
|
+
/** The prefix of the factory export of a module: `createOrdersModule` for `OrdersModule`. */
|
|
1451
|
+
static factoryPrefix = "create";
|
|
1452
|
+
/** The export of the construction chunk that the factory of a lazy library loads with `import()`. */
|
|
1453
|
+
static constructExport = "construct";
|
|
1454
|
+
/** The composed packages of the app, by the name of the factory of their module. */
|
|
1455
|
+
identitiesByFactory;
|
|
1434
1456
|
/** The bytes of each file that the walk reached, by path in the output directory. */
|
|
1435
1457
|
bytesByFile;
|
|
1436
1458
|
/** The files that hold the code of each package, by package name. */
|
|
@@ -1446,11 +1468,18 @@ var StartupBuiltCode = class StartupBuiltCode {
|
|
|
1446
1468
|
* @param chunks - The packages of each chunk of the build, from the build record.
|
|
1447
1469
|
* @param generated - The generated wiring files of each chunk of the build, from the build record.
|
|
1448
1470
|
* @param loaders - The generated loader file of each package, by identity, from the start report.
|
|
1471
|
+
* @param identities - Every composed package of the app, by identity, from the start report.
|
|
1449
1472
|
*/
|
|
1450
|
-
constructor(measured, chunks, generated = {}, loaders = {}) {
|
|
1473
|
+
constructor(measured, chunks, generated = {}, loaders = {}, identities = Object.keys(loaders)) {
|
|
1451
1474
|
this.measured = measured;
|
|
1452
1475
|
this.chunks = chunks;
|
|
1453
1476
|
const filesByPackage = /* @__PURE__ */ new Map();
|
|
1477
|
+
const identitiesByFactory = /* @__PURE__ */ new Map();
|
|
1478
|
+
for (const identity of new Set(identities)) {
|
|
1479
|
+
const factory = `${StartupBuiltCode.factoryPrefix}${identity.slice(identity.lastIndexOf("#") + 1)}`;
|
|
1480
|
+
identitiesByFactory.set(factory, [...identitiesByFactory.get(factory) ?? [], identity]);
|
|
1481
|
+
}
|
|
1482
|
+
this.identitiesByFactory = identitiesByFactory;
|
|
1454
1483
|
this.bytesByFile = new Map(measured.measurement.files.map((file) => [file.path, file.bytes]));
|
|
1455
1484
|
for (const file of measured.measurement.files) {
|
|
1456
1485
|
const names = new Set(Object.keys(this.packagesOfFile(file.path)));
|
|
@@ -1458,7 +1487,7 @@ var StartupBuiltCode = class StartupBuiltCode {
|
|
|
1458
1487
|
}
|
|
1459
1488
|
this.filesByPackage = filesByPackage;
|
|
1460
1489
|
this.loaderChunks = this.loaderChunksOf(generated, loaders);
|
|
1461
|
-
this.staticStart = this.reach(this.staticStartFiles(), /* @__PURE__ */ new Set(), void 0);
|
|
1490
|
+
this.staticStart = this.reach(this.staticStartFiles(), /* @__PURE__ */ new Set(), void 0, false);
|
|
1462
1491
|
}
|
|
1463
1492
|
/**
|
|
1464
1493
|
* The package name of a package identity: `@acme/orders/admin#OrdersModule` gives `@acme/orders`.
|
|
@@ -1477,13 +1506,22 @@ var StartupBuiltCode = class StartupBuiltCode {
|
|
|
1477
1506
|
* The files that the first load of some packages reaches, without the files that are loaded already: from the
|
|
1478
1507
|
* chunk of each loader, or the files of the npm package ({@link byPackageName}), every file that they import
|
|
1479
1508
|
* with a static import or with `import()`. The walk does not go into the loader chunk of another package
|
|
1480
|
-
* through `import()`, as that chunk loads on the first use of that package
|
|
1509
|
+
* through `import()`, as that chunk loads on the first use of that package, and it does not go into the
|
|
1510
|
+
* factory of a module of another package ({@link StartupBuiltCode}).
|
|
1481
1511
|
*
|
|
1482
1512
|
* @param identities - The packages, by identity.
|
|
1483
|
-
* @param loaded - The files that are loaded already. The walk does not
|
|
1513
|
+
* @param loaded - The files that are loaded already. The walk does not count them, and from them it follows
|
|
1514
|
+
* only the factory `import()` of a module of `identities`.
|
|
1484
1515
|
*/
|
|
1485
1516
|
codeOf(identities, loaded = /* @__PURE__ */ new Set()) {
|
|
1486
|
-
|
|
1517
|
+
const seeds = this.seedsOf(identities);
|
|
1518
|
+
const scope = this.scopeOf(new Set(identities));
|
|
1519
|
+
const files = this.reach(seeds, loaded, scope, true);
|
|
1520
|
+
const certain = this.reach(seeds, loaded, scope, false);
|
|
1521
|
+
return {
|
|
1522
|
+
files,
|
|
1523
|
+
uncertain: new Set([...files].filter((file) => !certain.has(file)))
|
|
1524
|
+
};
|
|
1487
1525
|
}
|
|
1488
1526
|
/**
|
|
1489
1527
|
* The files that the app loads before it is ready: the static start closure, and the code of the start
|
|
@@ -1492,7 +1530,11 @@ var StartupBuiltCode = class StartupBuiltCode {
|
|
|
1492
1530
|
* @param identities - The start packages, by identity.
|
|
1493
1531
|
*/
|
|
1494
1532
|
startFiles(identities) {
|
|
1495
|
-
|
|
1533
|
+
const code = this.codeOf(identities);
|
|
1534
|
+
return {
|
|
1535
|
+
files: /* @__PURE__ */ new Set([...this.staticStart, ...code.files]),
|
|
1536
|
+
uncertain: new Set([...code.uncertain].filter((file) => !this.staticStart.has(file)))
|
|
1537
|
+
};
|
|
1496
1538
|
}
|
|
1497
1539
|
/** Whether the code finds the files of some package by its loader chunk. */
|
|
1498
1540
|
hasLoaders() {
|
|
@@ -1508,16 +1550,14 @@ var StartupBuiltCode = class StartupBuiltCode {
|
|
|
1508
1550
|
return identities.filter((identity) => !this.loaderChunks.has(identity));
|
|
1509
1551
|
}
|
|
1510
1552
|
/**
|
|
1511
|
-
* How many files
|
|
1553
|
+
* How many files some code has, and their bytes, with the part that is uncertain when there is one.
|
|
1512
1554
|
*
|
|
1513
|
-
* @param
|
|
1555
|
+
* @param code - The files.
|
|
1514
1556
|
*/
|
|
1515
|
-
sizeOf(
|
|
1516
|
-
let bytes = 0;
|
|
1517
|
-
for (const file of files) bytes += this.bytesByFile.get(file) ?? 0;
|
|
1557
|
+
sizeOf(code) {
|
|
1518
1558
|
return {
|
|
1519
|
-
files
|
|
1520
|
-
|
|
1559
|
+
...this.filesSizeOf(code.files),
|
|
1560
|
+
...code.uncertain.size === 0 ? {} : { uncertain: this.filesSizeOf(code.uncertain) }
|
|
1521
1561
|
};
|
|
1522
1562
|
}
|
|
1523
1563
|
/**
|
|
@@ -1533,20 +1573,78 @@ var StartupBuiltCode = class StartupBuiltCode {
|
|
|
1533
1573
|
for (const file of files) for (const [name, bytes] of Object.entries(this.packagesOfFile(file))) bytesByPackage.set(name, (bytesByPackage.get(name) ?? 0) + bytes);
|
|
1534
1574
|
return bytesByPackage;
|
|
1535
1575
|
}
|
|
1576
|
+
/** How many files a set has, and their bytes. */
|
|
1577
|
+
filesSizeOf(files) {
|
|
1578
|
+
let bytes = 0;
|
|
1579
|
+
for (const file of files) bytes += this.bytesByFile.get(file) ?? 0;
|
|
1580
|
+
return {
|
|
1581
|
+
files: files.size,
|
|
1582
|
+
bytes
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1536
1585
|
/**
|
|
1537
|
-
* Some files and every file that they import, without the files that are loaded already. With
|
|
1538
|
-
* walk follows `import()` too,
|
|
1586
|
+
* Some files and every file that they import, without the files that are loaded already. With a scope, the
|
|
1587
|
+
* walk follows `import()` too ({@link importEdgeOf}), and passes through a loaded file only to find the factory
|
|
1588
|
+
* `import()` of a module of the scope. Without `withUncertain`, it does not follow an uncertain `import()`.
|
|
1539
1589
|
*/
|
|
1540
|
-
reach(seeds, loaded,
|
|
1541
|
-
const
|
|
1542
|
-
const pending = seeds.filter((file) => !loaded.has(file));
|
|
1590
|
+
reach(seeds, loaded, scope, withUncertain) {
|
|
1591
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1592
|
+
const pending = scope === void 0 ? seeds.filter((file) => !loaded.has(file)) : [...seeds];
|
|
1543
1593
|
for (let file = pending.pop(); file !== void 0; file = pending.pop()) {
|
|
1544
|
-
if (
|
|
1545
|
-
|
|
1546
|
-
const
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1594
|
+
if (visited.has(file)) continue;
|
|
1595
|
+
visited.add(file);
|
|
1596
|
+
const isLoaded = loaded.has(file);
|
|
1597
|
+
const targets = [...StartupBuiltCode.importsOf(this.measured.staticImports, file), ...scope === void 0 ? [] : StartupBuiltCode.importsOf(this.measured.dynamicImports, file).filter((target) => {
|
|
1598
|
+
const edge = this.importEdgeOf(file, target, scope, isLoaded);
|
|
1599
|
+
return edge === ImportEdge.Follow || withUncertain && edge === ImportEdge.Uncertain;
|
|
1600
|
+
})];
|
|
1601
|
+
for (const target of targets) if ((scope !== void 0 || !loaded.has(target)) && !visited.has(target)) pending.push(target);
|
|
1602
|
+
}
|
|
1603
|
+
return new Set([...visited].filter((file) => !loaded.has(file)));
|
|
1604
|
+
}
|
|
1605
|
+
/**
|
|
1606
|
+
* What a walk does with an `import()` of a file. It follows the factory `import()` of a module of the walk, and
|
|
1607
|
+
* skips the factory `import()` of another composed module. It follows the other `import()` calls of a loader
|
|
1608
|
+
* chunk of the walk. Another `import()` of a file that is not loaded is uncertain, and the walk skips it in a
|
|
1609
|
+
* loaded file, as the walk of that file followed it.
|
|
1610
|
+
*/
|
|
1611
|
+
importEdgeOf(file, target, scope, isLoaded) {
|
|
1612
|
+
if (scope.boundary.has(target)) return ImportEdge.Skip;
|
|
1613
|
+
const modules = this.factoryModulesOf(file, target);
|
|
1614
|
+
if (modules !== void 0) return modules.some((identity) => scope.identities.has(identity)) ? ImportEdge.Follow : ImportEdge.Skip;
|
|
1615
|
+
if (isLoaded) return ImportEdge.Skip;
|
|
1616
|
+
return scope.loaderChunks.has(file) ? ImportEdge.Follow : ImportEdge.Uncertain;
|
|
1617
|
+
}
|
|
1618
|
+
/**
|
|
1619
|
+
* The composed modules whose factory an `import()` of a file loads. In a barrel, the file reads the factory
|
|
1620
|
+
* from the result. In a lazy factory, the exported factory holds the `import()` and reads `construct` from the
|
|
1621
|
+
* result. Each factory must be of a module of a package of the file, else the modules are `undefined`.
|
|
1622
|
+
*/
|
|
1623
|
+
factoryModulesOf(file, target) {
|
|
1624
|
+
const read = StartupBuiltCode.namesOf(this.measured.dynamicImportNames, file, target);
|
|
1625
|
+
const names = read?.length === 1 && read[0] === StartupBuiltCode.constructExport ? StartupBuiltCode.namesOf(this.measured.dynamicImportOwners, file, target) : read;
|
|
1626
|
+
if (names === void 0 || names.length === 0) return;
|
|
1627
|
+
const packages = new Set(Object.keys(this.packagesOfFile(file)));
|
|
1628
|
+
const modules = [];
|
|
1629
|
+
for (const name of names) {
|
|
1630
|
+
const owners = (this.identitiesByFactory.get(name) ?? []).filter((identity) => packages.has(StartupBuiltCode.packageNameOf(identity)));
|
|
1631
|
+
if (owners.length === 0) return;
|
|
1632
|
+
modules.push(...owners);
|
|
1633
|
+
}
|
|
1634
|
+
return modules;
|
|
1635
|
+
}
|
|
1636
|
+
/** The names that a record of the size walk gives an `import()` of a file. */
|
|
1637
|
+
static namesOf(namesByImporter, file, target) {
|
|
1638
|
+
const namesByTarget = Object.hasOwn(namesByImporter, file) ? namesByImporter[file] : void 0;
|
|
1639
|
+
return namesByTarget !== void 0 && Object.hasOwn(namesByTarget, target) ? namesByTarget[target] : void 0;
|
|
1640
|
+
}
|
|
1641
|
+
/** The scope of a walk of some packages. */
|
|
1642
|
+
scopeOf(identities) {
|
|
1643
|
+
return {
|
|
1644
|
+
identities,
|
|
1645
|
+
loaderChunks: new Set([...identities].flatMap((identity) => this.loaderChunks.get(identity) ?? [])),
|
|
1646
|
+
boundary: this.loaderChunksOutside(identities)
|
|
1647
|
+
};
|
|
1550
1648
|
}
|
|
1551
1649
|
/** The chunk of the loader of each package, or the files of its npm package. */
|
|
1552
1650
|
seedsOf(identities) {
|
|
@@ -1567,11 +1665,11 @@ var StartupBuiltCode = class StartupBuiltCode {
|
|
|
1567
1665
|
const others = [...this.loaderChunks].filter(([other]) => other !== identity && StartupBuiltCode.packageNameOf(other) === name);
|
|
1568
1666
|
if (others.length === 0) return files;
|
|
1569
1667
|
const otherFiles = new Set(others.flatMap(([other, chunks]) => {
|
|
1570
|
-
const closure = this.loaderClosures.get(other) ?? this.reach(chunks, this.staticStart, this.
|
|
1668
|
+
const closure = this.loaderClosures.get(other) ?? this.reach(chunks, this.staticStart, this.scopeOf(/* @__PURE__ */ new Set([other])), true);
|
|
1571
1669
|
this.loaderClosures.set(other, closure);
|
|
1572
1670
|
return [...closure];
|
|
1573
1671
|
}));
|
|
1574
|
-
const ownFiles = this.reach(files.filter((file) => !otherFiles.has(file)), /* @__PURE__ */ new Set(), this.
|
|
1672
|
+
const ownFiles = this.reach(files.filter((file) => !otherFiles.has(file)), /* @__PURE__ */ new Set(), this.scopeOf(/* @__PURE__ */ new Set([identity])), true);
|
|
1575
1673
|
return files.filter((file) => !otherFiles.has(file) || ownFiles.has(file));
|
|
1576
1674
|
}
|
|
1577
1675
|
/** The targets of one file in an import table of the walk. */
|
|
@@ -1735,7 +1833,9 @@ var StartupSizeCheck = class StartupSizeCheck {
|
|
|
1735
1833
|
name,
|
|
1736
1834
|
measurement: graph.measurement,
|
|
1737
1835
|
staticImports: graph.staticImports,
|
|
1738
|
-
dynamicImports: graph.dynamicImports
|
|
1836
|
+
dynamicImports: graph.dynamicImports,
|
|
1837
|
+
dynamicImportNames: graph.dynamicImportNames,
|
|
1838
|
+
dynamicImportOwners: graph.dynamicImportOwners
|
|
1739
1839
|
};
|
|
1740
1840
|
});
|
|
1741
1841
|
return {
|
|
@@ -1942,7 +2042,7 @@ var StartupEntriesReport = class StartupEntriesReport {
|
|
|
1942
2042
|
const serverEntry = measured?.entries.find((entry) => entry.name === ServerBuildRecord.mainEntryName) ?? measured?.entries[0];
|
|
1943
2043
|
const chunks = serverEntry === void 0 ? void 0 : measured?.chunks;
|
|
1944
2044
|
const bytesUnavailable = measuring.kind === "skipped" ? measuring.result.reason : chunks === void 0 ? "no-chunk-record" : void 0;
|
|
1945
|
-
const apps = reports.filter((report) => report.role !== StartReportRole.Hostless).map((report) => StartupEntriesReport.appReport(report, serverEntry === void 0 || chunks === void 0 ? void 0 : new StartupBuiltCode(serverEntry, chunks, measured?.generated, report.loads?.loaders), top));
|
|
2045
|
+
const apps = reports.filter((report) => report.role !== StartReportRole.Hostless).map((report) => StartupEntriesReport.appReport(report, serverEntry === void 0 || chunks === void 0 ? void 0 : new StartupBuiltCode(serverEntry, chunks, measured?.generated, report.loads?.loaders, StartupEntriesReport.identitiesOf(report)), top));
|
|
1946
2046
|
const notice = measuring.kind === "skipped" ? `${measuring.message.replace(" The size check of the server code is skipped.", "")} The entries report has no bytes.` : chunks === void 0 ? `The build record ${ServerBuildRecord.relativePath} does not have the packages of its chunks, so the entries report has no bytes. Build the app again with this version of Heximon.` : void 0;
|
|
1947
2047
|
return {
|
|
1948
2048
|
result: {
|
|
@@ -1953,6 +2053,19 @@ var StartupEntriesReport = class StartupEntriesReport {
|
|
|
1953
2053
|
lines: [...notice === void 0 ? [] : [notice], ...apps.map((app) => StartupEntriesReport.appText(app, serverEntry?.measurement.entry))]
|
|
1954
2054
|
};
|
|
1955
2055
|
}
|
|
2056
|
+
/** Every composed package of a start report, by identity. */
|
|
2057
|
+
static identitiesOf(report) {
|
|
2058
|
+
return [.../* @__PURE__ */ new Set([
|
|
2059
|
+
...report.start.map((entry) => entry.package),
|
|
2060
|
+
...report.entries.flatMap((entry) => entry.packages),
|
|
2061
|
+
...(report.loads?.asyncRegistries ?? []).flatMap((registry) => [
|
|
2062
|
+
registry.owner,
|
|
2063
|
+
...registry.ownerPackages,
|
|
2064
|
+
...registry.packages.map((entry) => entry.package)
|
|
2065
|
+
]),
|
|
2066
|
+
...Object.keys(report.loads?.loaders ?? {})
|
|
2067
|
+
])];
|
|
2068
|
+
}
|
|
1956
2069
|
/** The report of one app. */
|
|
1957
2070
|
static appReport(report, code, top) {
|
|
1958
2071
|
const reasonsByPlace = new Map((report.loads?.entries ?? []).map((entry) => [StartupEntriesReport.placeOf(entry.kind, entry.key), new Map(entry.packages.map((loaded) => [loaded.package, loaded.reasons]))]));
|
|
@@ -1989,8 +2102,9 @@ var StartupEntriesReport = class StartupEntriesReport {
|
|
|
1989
2102
|
/** The report of one group of entries. */
|
|
1990
2103
|
static groupReport(group, reasonNames, reasons, asyncRegistries, code, startLoaded) {
|
|
1991
2104
|
const places = [...group.places].sort((first, second) => StartupEntriesReport.compareText(first, second));
|
|
1992
|
-
const addedFiles = code === void 0 || startLoaded === void 0 ? void 0 : code.codeOf(group.packages, startLoaded);
|
|
1993
|
-
const bytesByPackage = code === void 0 || addedFiles === void 0 ? /* @__PURE__ */ new Map() : code.packageBytes(addedFiles);
|
|
2105
|
+
const addedFiles = code === void 0 || startLoaded === void 0 ? void 0 : code.codeOf(group.packages, startLoaded.files);
|
|
2106
|
+
const bytesByPackage = code === void 0 || addedFiles === void 0 ? /* @__PURE__ */ new Map() : code.packageBytes(addedFiles.files);
|
|
2107
|
+
const uncertainBytesByPackage = code === void 0 || addedFiles === void 0 ? /* @__PURE__ */ new Map() : code.packageBytes(addedFiles.uncertain);
|
|
1994
2108
|
const identitiesByName = /* @__PURE__ */ new Map();
|
|
1995
2109
|
for (const identity of group.packages) {
|
|
1996
2110
|
const name = StartupBuiltCode.packageNameOf(identity);
|
|
@@ -1998,15 +2112,19 @@ var StartupEntriesReport = class StartupEntriesReport {
|
|
|
1998
2112
|
}
|
|
1999
2113
|
const modules = [...bytesByPackage].filter(([, bytes]) => bytes > 0).map(([name, bytes]) => {
|
|
2000
2114
|
const identities = identitiesByName.get(name);
|
|
2115
|
+
const uncertainBytes = uncertainBytesByPackage.get(name) ?? 0;
|
|
2116
|
+
const uncertain = uncertainBytes > 0 ? { uncertainBytes } : {};
|
|
2001
2117
|
if (identities === void 0) return {
|
|
2002
2118
|
module: name,
|
|
2003
2119
|
bytes,
|
|
2120
|
+
...uncertain,
|
|
2004
2121
|
reasons: [StartupEntryReasons.imported()]
|
|
2005
2122
|
};
|
|
2006
2123
|
const described = [...new Map(identities.flatMap((identity) => reasons.get(identity) ?? []).map((reason) => reasonNames.describe(reason)).map((named) => [named.text, named])).values()];
|
|
2007
2124
|
return {
|
|
2008
2125
|
module: identities.join(", "),
|
|
2009
2126
|
bytes,
|
|
2127
|
+
...uncertain,
|
|
2010
2128
|
reasons: described.length === 0 ? [StartupEntryReasons.notRecorded()] : described
|
|
2011
2129
|
};
|
|
2012
2130
|
}).sort((first, second) => second.bytes - first.bytes || StartupEntriesReport.compareText(first.module, second.module)).slice(0, StartupEntriesReport.namedModuleCount);
|
|
@@ -2017,7 +2135,7 @@ var StartupEntriesReport = class StartupEntriesReport {
|
|
|
2017
2135
|
packages,
|
|
2018
2136
|
...addedFiles === void 0 ? {} : { bytes: [...new Set(packages.map((identity) => StartupBuiltCode.packageNameOf(identity)))].reduce((sum, name) => sum + (bytesByPackage.get(name) ?? 0), 0) }
|
|
2019
2137
|
}));
|
|
2020
|
-
const loadedWithEntry = startLoaded === void 0 || addedFiles === void 0 ? void 0 : /* @__PURE__ */ new Set([...startLoaded, ...addedFiles]);
|
|
2138
|
+
const loadedWithEntry = startLoaded === void 0 || addedFiles === void 0 ? void 0 : /* @__PURE__ */ new Set([...startLoaded.files, ...addedFiles.files]);
|
|
2021
2139
|
return {
|
|
2022
2140
|
packages: group.packages,
|
|
2023
2141
|
entries: places,
|
|
@@ -2046,7 +2164,7 @@ var StartupEntriesReport = class StartupEntriesReport {
|
|
|
2046
2164
|
const packages = registry.packages.map((loaded) => loaded.package);
|
|
2047
2165
|
let added;
|
|
2048
2166
|
if (code !== void 0 && startLoaded !== void 0) {
|
|
2049
|
-
const loaded = /* @__PURE__ */ new Set([...startLoaded, ...code.codeOf([registry.owner, ...registry.ownerPackages], startLoaded)]);
|
|
2167
|
+
const loaded = /* @__PURE__ */ new Set([...startLoaded.files, ...code.codeOf([registry.owner, ...registry.ownerPackages], startLoaded.files).files]);
|
|
2050
2168
|
added = code.sizeOf(code.codeOf(packages, loaded));
|
|
2051
2169
|
}
|
|
2052
2170
|
return {
|
|
@@ -2069,7 +2187,7 @@ var StartupEntriesReport = class StartupEntriesReport {
|
|
|
2069
2187
|
kind,
|
|
2070
2188
|
entries: sets.length,
|
|
2071
2189
|
packages: shared,
|
|
2072
|
-
...code === void 0 || startLoaded === void 0 ? {} : { added: code.sizeOf(code.codeOf(shared, startLoaded)) }
|
|
2190
|
+
...code === void 0 || startLoaded === void 0 ? {} : { added: code.sizeOf(code.codeOf(shared, startLoaded.files)) }
|
|
2073
2191
|
}];
|
|
2074
2192
|
});
|
|
2075
2193
|
if (code === void 0 || report.entries.length === 0) return { everyEntry };
|
|
@@ -2100,12 +2218,13 @@ var StartupEntriesReport = class StartupEntriesReport {
|
|
|
2100
2218
|
/** The text of the report of one app. */
|
|
2101
2219
|
static appText(app, serverEntry) {
|
|
2102
2220
|
if (app.entries === 0) return `App '${app.app}' has no entries: the first use of each entry loads no package beyond the start.` + StartupEntriesReport.asyncRegistriesText(app);
|
|
2103
|
-
const lines = [`Entries of app '${app.app}': ${StartupEntriesReport.count(app.entries, "entry", "entries")} in ${StartupEntriesReport.count(app.groupCount, "module set", "module sets")}.` + (app.start === void 0 || serverEntry === void 0 ? "" : ` Each row gives the code that the first use of an entry loads after the start (${StartupEntriesReport.sizeText(app.start)}), in the build of ${serverEntry}.`)];
|
|
2221
|
+
const lines = [`Entries of app '${app.app}': ${StartupEntriesReport.count(app.entries, "entry", "entries")} in ${StartupEntriesReport.count(app.groupCount, "module set", "module sets")}.` + (app.start === void 0 || serverEntry === void 0 ? "" : ` Each row gives the code that the first use of an entry loads after the start (${StartupEntriesReport.sizeText(app.start, true)}), in the build of ${serverEntry}.`)];
|
|
2222
|
+
if (StartupEntriesReport.hasUncertainCode(app)) lines.push("Code \"only through an import()\" is code that an import() in the loaded code reaches, such as a lazy import in a package, and that the report cannot tie to a module that loads. It can load later or never, so a size with such code is an upper bound.");
|
|
2104
2223
|
if (app.byPackageNameOnly === true) lines.push("The build record names no loader chunk of a package, so the report finds the code of each package by its npm package name. Two roots of one npm package then share their code.");
|
|
2105
2224
|
if (app.groups.length < app.groupCount) lines.push(`The ${app.groups.length} largest of the ${app.groupCount} module sets (--top):`);
|
|
2106
2225
|
for (const [index, group] of app.groups.entries()) {
|
|
2107
2226
|
lines.push(`${index + 1}. ${StartupEntriesReport.count(group.entries.length, "entry", "entries")}, for example '${group.example}'` + (group.added === void 0 ? "." : `: ${StartupEntriesReport.sizeText(group.added)}.`), ` Module set: ${group.packages.length === 0 ? "no package beyond the start" : StartupEntriesReport.listText(group.packages)}.`);
|
|
2108
|
-
for (const module of group.modules) lines.push(` - ${module.module}: ${StartupSizeCheck.formatBytes(module.bytes)} (${module.reasons.map((reason) => reason.text).join("; ")})`);
|
|
2227
|
+
for (const module of group.modules) lines.push(` - ${module.module}: ${StartupSizeCheck.formatBytes(module.bytes)} (${module.reasons.map((reason) => reason.text).join("; ")}` + (module.uncertainBytes === void 0 ? "" : `; ${StartupSizeCheck.formatBytes(module.uncertainBytes)} of it only through an import()`) + ")");
|
|
2109
2228
|
for (const sealGroup of group.sealGroups) lines.push(` - The seal group of ${sealGroup.registry} loads ${StartupEntriesReport.count(sealGroup.packages.length, "package", "packages")}` + (sealGroup.bytes === void 0 ? "" : ` (${StartupSizeCheck.formatBytes(sealGroup.bytes)})`) + " with these entries. Extend AsyncContributions<T> for the registry, so that its contributors load on its first load() call.");
|
|
2110
2229
|
if (app.byPackageNameOnly !== true && group.byPackageName !== void 0) lines.push(` - Found by npm package name, as the build record names no loader chunk: ${StartupEntriesReport.listText(group.byPackageName)}.`);
|
|
2111
2230
|
for (const onRead of group.onRead) lines.push(` - On read: a load() call of '${onRead.registry}' of ${onRead.owner} can add ` + (onRead.added === void 0 ? "the code of its contributors." : `${StartupEntriesReport.sizeText(onRead.added)}. The row above does not count it.`));
|
|
@@ -2121,9 +2240,23 @@ var StartupEntriesReport = class StartupEntriesReport {
|
|
|
2121
2240
|
if (app.asyncRegistryCount === 0) return "";
|
|
2122
2241
|
return `\n${[`Async registries: the first load() call of each one loads its contributors. No entry counts this code${app.asyncRegistries.length < app.asyncRegistryCount ? ` (the ${app.asyncRegistries.length} largest of ${app.asyncRegistryCount}, --top)` : ""}.`, ...app.asyncRegistries.map((registry) => `- '${registry.registry}' of ${registry.owner}: ${StartupEntriesReport.count(registry.contributors.length, "contributor", "contributors")} (${StartupEntriesReport.listText(registry.contributors, StartupEntriesReport.namedContributorCount)}), ${StartupEntriesReport.count(registry.packages.length, "package", "packages")} beyond the start` + (registry.added === void 0 ? "." : `, ${StartupEntriesReport.sizeText(registry.added)}.`))].join("\n")}`;
|
|
2123
2242
|
}
|
|
2124
|
-
/**
|
|
2125
|
-
static
|
|
2126
|
-
return
|
|
2243
|
+
/** Whether the start, a row or an async registry of an app has code only through an `import()`. */
|
|
2244
|
+
static hasUncertainCode(app) {
|
|
2245
|
+
return [
|
|
2246
|
+
app.start,
|
|
2247
|
+
...app.groups.flatMap((group) => [group.added, ...group.onRead.map((onRead) => onRead.added)]),
|
|
2248
|
+
...app.asyncRegistries.map((registry) => registry.added)
|
|
2249
|
+
].some((size) => size?.uncertain !== void 0);
|
|
2250
|
+
}
|
|
2251
|
+
/**
|
|
2252
|
+
* Files and bytes for a person to read, with the part only through an `import()`: in parentheses, or after a
|
|
2253
|
+
* semicolon when the text is in parentheses already.
|
|
2254
|
+
*/
|
|
2255
|
+
static sizeText(size, isInParentheses = false) {
|
|
2256
|
+
const text = `${StartupEntriesReport.count(size.files, "file", "files")}, ${StartupSizeCheck.formatBytes(size.bytes)}`;
|
|
2257
|
+
if (size.uncertain === void 0) return text;
|
|
2258
|
+
const uncertain = `${StartupEntriesReport.count(size.uncertain.files, "file", "files")}, ${StartupSizeCheck.formatBytes(size.uncertain.bytes)} of it only through an import()`;
|
|
2259
|
+
return isInParentheses ? `${text}; ${uncertain}` : `${text} (${uncertain})`;
|
|
2127
2260
|
}
|
|
2128
2261
|
/** A list of names, with the count of the rest when it is long. */
|
|
2129
2262
|
static listText(names, limit = StartupEntriesReport.namedPackageCount) {
|
|
@@ -6694,6 +6827,14 @@ var PlatformBindingCensus = class PlatformBindingCensus {
|
|
|
6694
6827
|
binding,
|
|
6695
6828
|
neededBy: "`cloudflare.r2Buckets` in heximon.config.ts"
|
|
6696
6829
|
})),
|
|
6830
|
+
artifacts: (payload) => PlatformBindingCensus.entriesOf(payload["artifacts"], "binding").map((binding) => ({
|
|
6831
|
+
binding,
|
|
6832
|
+
neededBy: "`cloudflare.artifacts` in heximon.config.ts"
|
|
6833
|
+
})),
|
|
6834
|
+
"dispatch-namespaces": (payload) => PlatformBindingCensus.entriesOf(payload["dispatchNamespaces"], "binding").map((binding) => ({
|
|
6835
|
+
binding,
|
|
6836
|
+
neededBy: "`cloudflare.dispatchNamespaces` in heximon.config.ts"
|
|
6837
|
+
})),
|
|
6697
6838
|
browser: (payload) => PlatformBindingCensus.entriesOf([payload["browser"]], "binding").map((binding) => ({
|
|
6698
6839
|
binding,
|
|
6699
6840
|
neededBy: "`cloudflare.browser` in heximon.config.ts"
|
|
@@ -6717,6 +6858,8 @@ var PlatformBindingCensus = class PlatformBindingCensus {
|
|
|
6717
6858
|
"kv-namespaces": "Workers KV",
|
|
6718
6859
|
hyperdrive: "Hyperdrive",
|
|
6719
6860
|
"r2-buckets": "R2 bucket",
|
|
6861
|
+
artifacts: "Artifacts",
|
|
6862
|
+
"dispatch-namespaces": "Dispatch namespace",
|
|
6720
6863
|
browser: "Browser Rendering",
|
|
6721
6864
|
"queue-bindings": "Cloudflare Queue",
|
|
6722
6865
|
"integration-event-subscriptions": "Cloudflare Queue",
|
package/dist/index.d.mts
CHANGED
|
@@ -265,6 +265,15 @@ type CheckStartupSizeResult = {
|
|
|
265
265
|
interface CheckStartupAddedCode {
|
|
266
266
|
readonly files: number;
|
|
267
267
|
readonly bytes: number;
|
|
268
|
+
/**
|
|
269
|
+
* The part of the files that the report reaches only through an `import()` that it cannot tie to a module that
|
|
270
|
+
* loads, such as an `import()` in the code of a package. That code can load later or never, so {@link bytes} is
|
|
271
|
+
* an upper bound. Absent when there is no such part.
|
|
272
|
+
*/
|
|
273
|
+
readonly uncertain?: {
|
|
274
|
+
readonly files: number;
|
|
275
|
+
readonly bytes: number;
|
|
276
|
+
};
|
|
268
277
|
}
|
|
269
278
|
/** One reason why the entries of a module set load a module. */
|
|
270
279
|
interface CheckStartupEntryReason {
|
|
@@ -287,6 +296,11 @@ interface CheckStartupEntryModule {
|
|
|
287
296
|
readonly module: string;
|
|
288
297
|
/** About how many bytes of the added code belong to the module. */
|
|
289
298
|
readonly bytes: number;
|
|
299
|
+
/**
|
|
300
|
+
* About how many of {@link bytes} the report reaches only through an `import()` that it cannot tie to a module
|
|
301
|
+
* that loads ({@link CheckStartupAddedCode.uncertain}). Absent when there are none.
|
|
302
|
+
*/
|
|
303
|
+
readonly uncertainBytes?: number;
|
|
290
304
|
/** Why the entries load it. */
|
|
291
305
|
readonly reasons: readonly CheckStartupEntryReason[];
|
|
292
306
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "heximon",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.1",
|
|
4
4
|
"description": "The Heximon CLI: create, develop, build, migrate, and deploy Heximon apps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -38,28 +38,28 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@bomb.sh/tab": "^0.0.22",
|
|
40
40
|
"@clack/prompts": "^1.8.1",
|
|
41
|
-
"@heximon/compiler": "0.
|
|
42
|
-
"@heximon/cqrs": "0.
|
|
43
|
-
"@heximon/deploy": "0.
|
|
44
|
-
"@heximon/http": "0.
|
|
45
|
-
"@heximon/node": "0.
|
|
46
|
-
"@heximon/runtime": "0.
|
|
47
|
-
"@heximon/testing": "0.
|
|
41
|
+
"@heximon/compiler": "0.36.1",
|
|
42
|
+
"@heximon/cqrs": "0.36.1",
|
|
43
|
+
"@heximon/deploy": "0.36.1",
|
|
44
|
+
"@heximon/http": "0.36.1",
|
|
45
|
+
"@heximon/node": "0.36.1",
|
|
46
|
+
"@heximon/runtime": "0.36.1",
|
|
47
|
+
"@heximon/testing": "0.36.1",
|
|
48
48
|
"citty": "^0.2.2",
|
|
49
49
|
"giget": "^3.3.1",
|
|
50
50
|
"pathe": "^2.0.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@heximon/build": "0.
|
|
54
|
-
"@heximon/cloudflare": "0.
|
|
55
|
-
"@heximon/durable": "0.
|
|
56
|
-
"@heximon/integration": "0.
|
|
57
|
-
"@heximon/library": "0.
|
|
58
|
-
"@heximon/nitro": "0.
|
|
59
|
-
"@heximon/otel": "0.
|
|
60
|
-
"@heximon/queue": "0.
|
|
61
|
-
"@heximon/schedule": "0.
|
|
62
|
-
"@heximon/schema": "0.
|
|
53
|
+
"@heximon/build": "0.36.1",
|
|
54
|
+
"@heximon/cloudflare": "0.36.1",
|
|
55
|
+
"@heximon/durable": "0.36.1",
|
|
56
|
+
"@heximon/integration": "0.36.1",
|
|
57
|
+
"@heximon/library": "0.36.1",
|
|
58
|
+
"@heximon/nitro": "0.36.1",
|
|
59
|
+
"@heximon/otel": "0.36.1",
|
|
60
|
+
"@heximon/queue": "0.36.1",
|
|
61
|
+
"@heximon/schedule": "0.36.1",
|
|
62
|
+
"@heximon/schema": "0.36.1",
|
|
63
63
|
"@heximon/test-support": "0.0.1",
|
|
64
64
|
"@types/node": "^24.19.0",
|
|
65
65
|
"@typescript/native-preview": "^7.0.0-dev.20260707.2",
|