Skip to content

Commit 1d097da

Browse files
janechuCopilot
andcommitted
fix: measure subpath exports in SIZES.md
Update measure-sizes.js to measure exports from subpath entry points (styles.js, hydration.js, arrays.js) instead of only the main barrel. Fixes css showing 0 B after moving to subpath. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 8f9dac0 commit 1d097da

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

packages/fast-element/SIZES.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ Bundle sizes for `@microsoft/fast-element` exports.
1111
| observable | 6.74 KB | 2.50 KB | 2.24 KB |
1212
| attr | 477 B | 288 B | 244 B |
1313
| children | 4.81 KB | 1.86 KB | 1.64 KB |
14-
| css | 0 B | 20 B | 1 B |
1514
| ref | 3.78 KB | 1.53 KB | 1.33 KB |
1615
| slotted | 4.60 KB | 1.79 KB | 1.58 KB |
1716
| volatile | 6.79 KB | 2.53 KB | 2.25 KB |
1817
| when | 1.82 KB | 712 B | 568 B |
1918
| html | 25.92 KB | 8.50 KB | 7.61 KB |
2019
| repeat | 29.57 KB | 9.42 KB | 8.47 KB |
20+
| css | 1.55 KB | 731 B | 654 B |
21+
| ElementStyles | 788 B | 397 B | 332 B |
22+
| enableHydration | 24.27 KB | 7.59 KB | 6.86 KB |
23+
| ArrayObserver | 12.51 KB | 4.45 KB | 4.01 KB |

packages/fast-element/scripts/measure-sizes.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const namedExports = [
1515
"observable",
1616
"attr",
1717
"children",
18-
"css",
1918
"ref",
2019
"slotted",
2120
"volatile",
@@ -24,6 +23,13 @@ const namedExports = [
2423
"repeat",
2524
];
2625

26+
const subpathExports = [
27+
{ name: "css", path: "@microsoft/fast-element/styles.js", export: "css" },
28+
{ name: "ElementStyles", path: "@microsoft/fast-element/styles.js", export: "ElementStyles" },
29+
{ name: "enableHydration", path: "@microsoft/fast-element/hydration.js", export: "enableHydration" },
30+
{ name: "ArrayObserver", path: "@microsoft/fast-element/arrays.js", export: "ArrayObserver" },
31+
];
32+
2733
function formatBytes(bytes) {
2834
if (bytes < 1024) return `${bytes} B`;
2935
return `${(bytes / 1024).toFixed(2)} KB`;
@@ -39,8 +45,8 @@ function measureBuffer(buffer) {
3945
};
4046
}
4147

42-
async function measureExport(exportName) {
43-
const contents = `import { ${exportName} } from "@microsoft/fast-element";\nexport { ${exportName} };\n`;
48+
async function measureExport(exportName, importPath = "@microsoft/fast-element") {
49+
const contents = `import { ${exportName} } from "${importPath}";\nexport { ${exportName} };\n`;
4450

4551
const result = await build({
4652
stdin: {
@@ -81,6 +87,15 @@ async function main() {
8187
);
8288
results.push(...exportResults);
8389

90+
// Measure subpath exports in parallel
91+
const subpathResults = await Promise.all(
92+
subpathExports.map(async ({ name, path: importPath, export: exportName }) => {
93+
const sizes = await measureExport(exportName, importPath);
94+
return { name, ...sizes };
95+
}),
96+
);
97+
results.push(...subpathResults);
98+
8499
// Generate markdown table
85100
const lines = [
86101
"# Export Sizes",

0 commit comments

Comments
 (0)