Skip to content

Commit c656538

Browse files
janechuCopilot
andcommitted
Add import paths to size export labels
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1ce5f88 commit c656538

3 files changed

Lines changed: 53 additions & 48 deletions

File tree

packages/fast-element/SIZES.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ Bundle sizes for `@microsoft/fast-element` exports.
55
| Export | Minified | Gzip | Brotli |
66
|--------|----------|------|--------|
77
| CDN Rollup Bundle | 68.29 KB | 20.22 KB | 18.05 KB |
8-
| FASTElement | 23.73 KB | 7.38 KB | 6.63 KB |
9-
| Updates | 473 B | 337 B | 287 B |
10-
| Observable | 6.70 KB | 2.49 KB | 2.22 KB |
11-
| observable | 6.74 KB | 2.50 KB | 2.24 KB |
12-
| attr | 477 B | 288 B | 244 B |
13-
| children | 4.81 KB | 1.86 KB | 1.64 KB |
14-
| ref | 3.78 KB | 1.53 KB | 1.33 KB |
15-
| slotted | 4.60 KB | 1.79 KB | 1.58 KB |
16-
| volatile | 6.79 KB | 2.53 KB | 2.25 KB |
17-
| when | 1.82 KB | 712 B | 568 B |
18-
| html | 25.92 KB | 8.50 KB | 7.61 KB |
19-
| repeat | 29.57 KB | 9.42 KB | 8.47 KB |
20-
| css | 2.43 KB | 1.00 KB | 911 B |
21-
| enableHydration | 43.25 KB | 13.22 KB | 11.89 KB |
22-
| ArrayObserver | 12.51 KB | 4.45 KB | 4.01 KB |
23-
| declarativeTemplate | 58.68 KB | 18.42 KB | 16.42 KB |
24-
| observerMap (extensions/observer-map.js) | 20.36 KB | 7.23 KB | 6.50 KB |
25-
| attributeMap (extensions/attribute-map.js) | 15.61 KB | 5.52 KB | 4.97 KB |
8+
| FASTElement (@microsoft/fast-element) | 23.73 KB | 7.38 KB | 6.63 KB |
9+
| Updates (@microsoft/fast-element) | 473 B | 337 B | 287 B |
10+
| Observable (@microsoft/fast-element) | 6.70 KB | 2.49 KB | 2.22 KB |
11+
| observable (@microsoft/fast-element) | 6.74 KB | 2.50 KB | 2.24 KB |
12+
| attr (@microsoft/fast-element) | 477 B | 288 B | 244 B |
13+
| children (@microsoft/fast-element) | 4.81 KB | 1.86 KB | 1.64 KB |
14+
| ref (@microsoft/fast-element) | 3.78 KB | 1.53 KB | 1.33 KB |
15+
| slotted (@microsoft/fast-element) | 4.60 KB | 1.79 KB | 1.58 KB |
16+
| volatile (@microsoft/fast-element) | 6.79 KB | 2.53 KB | 2.25 KB |
17+
| when (@microsoft/fast-element) | 1.82 KB | 712 B | 568 B |
18+
| html (@microsoft/fast-element) | 25.92 KB | 8.50 KB | 7.61 KB |
19+
| repeat (@microsoft/fast-element) | 29.57 KB | 9.42 KB | 8.47 KB |
20+
| css (@microsoft/fast-element/styles.js) | 2.43 KB | 1.00 KB | 911 B |
21+
| enableHydration (@microsoft/fast-element/hydration.js) | 43.25 KB | 13.22 KB | 11.89 KB |
22+
| ArrayObserver (@microsoft/fast-element/arrays.js) | 12.51 KB | 4.45 KB | 4.01 KB |
23+
| declarativeTemplate (@microsoft/fast-element/declarative.js) | 58.68 KB | 18.42 KB | 16.45 KB |
24+
| observerMap (@microsoft/fast-element/extensions/observer-map.js) | 20.36 KB | 7.23 KB | 6.50 KB |
25+
| attributeMap (@microsoft/fast-element/extensions/attribute-map.js) | 15.61 KB | 5.52 KB | 4.97 KB |

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

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { build } from "esbuild";
77
const __filename = fileURLToPath(import.meta.url);
88
const __dirname = path.dirname(__filename);
99
const packageRoot = path.resolve(__dirname, "..");
10+
const rootImportPath = "@microsoft/fast-element";
1011

1112
const namedExports = [
1213
"FASTElement",
@@ -24,34 +25,38 @@ const namedExports = [
2425
];
2526

2627
const subpathExports = [
27-
{ name: "css", path: "@microsoft/fast-element/styles.js", export: "css" },
28+
{ name: "css", importPath: "@microsoft/fast-element/styles.js", export: "css" },
2829
{
2930
name: "enableHydration",
30-
path: "@microsoft/fast-element/hydration.js",
31+
importPath: "@microsoft/fast-element/hydration.js",
3132
export: "enableHydration",
3233
},
3334
{
3435
name: "ArrayObserver",
35-
path: "@microsoft/fast-element/arrays.js",
36+
importPath: "@microsoft/fast-element/arrays.js",
3637
export: "ArrayObserver",
3738
},
3839
{
3940
name: "declarativeTemplate",
40-
path: "@microsoft/fast-element/declarative.js",
41+
importPath: "@microsoft/fast-element/declarative.js",
4142
export: "declarativeTemplate",
4243
},
4344
{
44-
name: "observerMap (extensions/observer-map.js)",
45-
path: "@microsoft/fast-element/extensions/observer-map.js",
45+
name: "observerMap",
46+
importPath: "@microsoft/fast-element/extensions/observer-map.js",
4647
export: "observerMap",
4748
},
4849
{
49-
name: "attributeMap (extensions/attribute-map.js)",
50-
path: "@microsoft/fast-element/extensions/attribute-map.js",
50+
name: "attributeMap",
51+
importPath: "@microsoft/fast-element/extensions/attribute-map.js",
5152
export: "attributeMap",
5253
},
5354
];
5455

56+
function formatExportLabel(name, importPath) {
57+
return `${name} (${importPath})`;
58+
}
59+
5560
function formatBytes(bytes) {
5661
if (bytes < 1024) return `${bytes} B`;
5762
return `${(bytes / 1024).toFixed(2)} KB`;
@@ -67,7 +72,7 @@ function measureBuffer(buffer) {
6772
};
6873
}
6974

70-
async function measureExport(exportName, importPath = "@microsoft/fast-element") {
75+
async function measureExport(exportName, importPath = rootImportPath) {
7176
const contents = `import { ${exportName} } from "${importPath}";\nexport { ${exportName} };\n`;
7277

7378
const result = await build({
@@ -104,16 +109,16 @@ async function main() {
104109
const exportResults = await Promise.all(
105110
namedExports.map(async name => {
106111
const sizes = await measureExport(name);
107-
return { name, ...sizes };
112+
return { name: formatExportLabel(name, rootImportPath), ...sizes };
108113
}),
109114
);
110115
results.push(...exportResults);
111116

112117
// Measure subpath exports in parallel
113118
const subpathResults = await Promise.all(
114-
subpathExports.map(async ({ name, path: importPath, export: exportName }) => {
119+
subpathExports.map(async ({ name, importPath, export: exportName }) => {
115120
const sizes = await measureExport(exportName, importPath);
116-
return { name, ...sizes };
121+
return { name: formatExportLabel(name, importPath), ...sizes };
117122
}),
118123
);
119124
results.push(...subpathResults);

sites/website/src/docs/3.x/resources/export-sizes.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ Bundle sizes for `@microsoft/fast-element` exports.
2020
| Export | Minified | Gzip | Brotli |
2121
|--------|----------|------|--------|
2222
| CDN Rollup Bundle | 68.29 KB | 20.22 KB | 18.05 KB |
23-
| FASTElement | 23.73 KB | 7.38 KB | 6.63 KB |
24-
| Updates | 473 B | 337 B | 287 B |
25-
| Observable | 6.70 KB | 2.49 KB | 2.22 KB |
26-
| observable | 6.74 KB | 2.50 KB | 2.24 KB |
27-
| attr | 477 B | 288 B | 244 B |
28-
| children | 4.81 KB | 1.86 KB | 1.64 KB |
29-
| ref | 3.78 KB | 1.53 KB | 1.33 KB |
30-
| slotted | 4.60 KB | 1.79 KB | 1.58 KB |
31-
| volatile | 6.79 KB | 2.53 KB | 2.25 KB |
32-
| when | 1.82 KB | 712 B | 568 B |
33-
| html | 25.92 KB | 8.50 KB | 7.61 KB |
34-
| repeat | 29.57 KB | 9.42 KB | 8.47 KB |
35-
| css | 2.43 KB | 1.00 KB | 911 B |
36-
| enableHydration | 43.25 KB | 13.22 KB | 11.89 KB |
37-
| ArrayObserver | 12.51 KB | 4.45 KB | 4.01 KB |
38-
| declarativeTemplate | 58.68 KB | 18.42 KB | 16.42 KB |
39-
| observerMap (extensions/observer-map.js) | 20.36 KB | 7.23 KB | 6.50 KB |
40-
| attributeMap (extensions/attribute-map.js) | 15.61 KB | 5.52 KB | 4.97 KB |
23+
| FASTElement (@microsoft/fast-element) | 23.73 KB | 7.38 KB | 6.63 KB |
24+
| Updates (@microsoft/fast-element) | 473 B | 337 B | 287 B |
25+
| Observable (@microsoft/fast-element) | 6.70 KB | 2.49 KB | 2.22 KB |
26+
| observable (@microsoft/fast-element) | 6.74 KB | 2.50 KB | 2.24 KB |
27+
| attr (@microsoft/fast-element) | 477 B | 288 B | 244 B |
28+
| children (@microsoft/fast-element) | 4.81 KB | 1.86 KB | 1.64 KB |
29+
| ref (@microsoft/fast-element) | 3.78 KB | 1.53 KB | 1.33 KB |
30+
| slotted (@microsoft/fast-element) | 4.60 KB | 1.79 KB | 1.58 KB |
31+
| volatile (@microsoft/fast-element) | 6.79 KB | 2.53 KB | 2.25 KB |
32+
| when (@microsoft/fast-element) | 1.82 KB | 712 B | 568 B |
33+
| html (@microsoft/fast-element) | 25.92 KB | 8.50 KB | 7.61 KB |
34+
| repeat (@microsoft/fast-element) | 29.57 KB | 9.42 KB | 8.47 KB |
35+
| css (@microsoft/fast-element/styles.js) | 2.43 KB | 1.00 KB | 911 B |
36+
| enableHydration (@microsoft/fast-element/hydration.js) | 43.25 KB | 13.22 KB | 11.89 KB |
37+
| ArrayObserver (@microsoft/fast-element/arrays.js) | 12.51 KB | 4.45 KB | 4.01 KB |
38+
| declarativeTemplate (@microsoft/fast-element/declarative.js) | 58.68 KB | 18.42 KB | 16.45 KB |
39+
| observerMap (@microsoft/fast-element/extensions/observer-map.js) | 20.36 KB | 7.23 KB | 6.50 KB |
40+
| attributeMap (@microsoft/fast-element/extensions/attribute-map.js) | 15.61 KB | 5.52 KB | 4.97 KB |

0 commit comments

Comments
 (0)