Skip to content

Commit 957d668

Browse files
authored
Log total amount + size of all modules (#6267)
1 parent e7c06d7 commit 957d668

File tree

4 files changed

+82
-59
lines changed

4 files changed

+82
-59
lines changed

.changeset/few-pumpkins-fetch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
chore: add total module size to the logged table, this makes it much easier to see the total size of all modules combined.

packages/wrangler/src/__tests__/deploy.test.ts

Lines changed: 52 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,28 +2674,30 @@ addEventListener('fetch', event => {});`
26742674
Uploaded 100% [2 out of 2]"
26752675
`);
26762676
expect(std.out).toMatchInlineSnapshot(`
2677-
"┌─────────────┬──────┬──────────┐
2678-
│ Name │ Type │ Size │
2679-
├─────────────┼──────┼──────────┤
2680-
│ a/1.mjs │ esm │ xx KiB │
2681-
├─────────────┼──────┼──────────┤
2682-
│ a/b/2.mjs │ esm │ xx KiB │
2683-
├─────────────┼──────┼──────────┤
2684-
│ a/b/3.mjs │ esm │ xx KiB │
2685-
├─────────────┼──────┼──────────┤
2686-
│ a/b/c/4.mjs │ esm │ xx KiB │
2687-
└─────────────┴──────┴──────────┘
2688-
↗️ Done syncing assets
2689-
Total Upload: xx KiB / gzip: xx KiB
2690-
Uploaded test-name (TIMINGS)
2691-
Published test-name (TIMINGS)
2692-
https://test-name.test-sub-domain.workers.dev
2693-
Current Deployment ID: Galaxy-Class
2694-
Current Version ID: Galaxy-Class
2677+
"┌───────────────────┬──────┬──────────┐
2678+
│ Name │ Type │ Size │
2679+
├───────────────────┼──────┼──────────┤
2680+
│ a/1.mjs │ esm │ xx KiB │
2681+
├───────────────────┼──────┼──────────┤
2682+
│ a/b/2.mjs │ esm │ xx KiB │
2683+
├───────────────────┼──────┼──────────┤
2684+
│ a/b/3.mjs │ esm │ xx KiB │
2685+
├───────────────────┼──────┼──────────┤
2686+
│ a/b/c/4.mjs │ esm │ xx KiB │
2687+
├───────────────────┼──────┼──────────┤
2688+
│ Total (4 modules) │ │ xx KiB │
2689+
└───────────────────┴──────┴──────────┘
2690+
↗️ Done syncing assets
2691+
Total Upload: xx KiB / gzip: xx KiB
2692+
Uploaded test-name (TIMINGS)
2693+
Published test-name (TIMINGS)
2694+
https://test-name.test-sub-domain.workers.dev
2695+
Current Deployment ID: Galaxy-Class
2696+
Current Version ID: Galaxy-Class
26952697
26962698
2697-
Note: Deployment ID has been renamed to Version ID. Deployment ID is present to maintain compatibility with the previous behavior of this command. This output will change in a future version of Wrangler. To learn more visit: https://developers.cloudflare.com/workers/configuration/versions-and-deployments"
2698-
`);
2699+
Note: Deployment ID has been renamed to Version ID. Deployment ID is present to maintain compatibility with the previous behavior of this command. This output will change in a future version of Wrangler. To learn more visit: https://developers.cloudflare.com/workers/configuration/versions-and-deployments"
2700+
`);
26992701
expect(std.err).toMatchInlineSnapshot(`""`);
27002702
});
27012703

@@ -10086,21 +10088,23 @@ export default{
1008610088
".wrangler/tmp/deploy/index.py"
1008710089
)
1008810090
).toMatchInlineSnapshot(`
10089-
"┌──────────────────────────────────────┬────────┬──────────┐
10090-
│ Name │ Type │ Size │
10091-
├──────────────────────────────────────┼────────┼──────────┤
10092-
│ .wrangler/tmp/deploy/index.py │ python │ xx KiB │
10093-
└──────────────────────────────────────┴────────┴──────────┘
10094-
Total Upload: xx KiB / gzip: xx KiB
10095-
Uploaded test-name (TIMINGS)
10096-
Published test-name (TIMINGS)
10097-
https://test-name.test-sub-domain.workers.dev
10098-
Current Deployment ID: Galaxy-Class
10099-
Current Version ID: Galaxy-Class
10091+
"┌──────────────────────────────────────┬────────┬──────────┐
10092+
│ Name │ Type │ Size │
10093+
├──────────────────────────────────────┼────────┼──────────┤
10094+
│ .wrangler/tmp/deploy/index.py │ python │ xx KiB │
10095+
├──────────────────────────────────────┼────────┼──────────┤
10096+
│ Total (1 module) │ │ xx KiB │
10097+
└──────────────────────────────────────┴────────┴──────────┘
10098+
Total Upload: xx KiB / gzip: xx KiB
10099+
Uploaded test-name (TIMINGS)
10100+
Published test-name (TIMINGS)
10101+
https://test-name.test-sub-domain.workers.dev
10102+
Current Deployment ID: Galaxy-Class
10103+
Current Version ID: Galaxy-Class
1010010104
1010110105
10102-
Note: Deployment ID has been renamed to Version ID. Deployment ID is present to maintain compatibility with the previous behavior of this command. This output will change in a future version of Wrangler. To learn more visit: https://developers.cloudflare.com/workers/configuration/versions-and-deployments"
10103-
`);
10106+
Note: Deployment ID has been renamed to Version ID. Deployment ID is present to maintain compatibility with the previous behavior of this command. This output will change in a future version of Wrangler. To learn more visit: https://developers.cloudflare.com/workers/configuration/versions-and-deployments"
10107+
`);
1010410108
});
1010510109

1010610110
it("should upload python module specified in CLI args", async () => {
@@ -10121,21 +10125,23 @@ export default{
1012110125
".wrangler/tmp/deploy/index.py"
1012210126
)
1012310127
).toMatchInlineSnapshot(`
10124-
"┌──────────────────────────────────────┬────────┬──────────┐
10125-
│ Name │ Type │ Size │
10126-
├──────────────────────────────────────┼────────┼──────────┤
10127-
│ .wrangler/tmp/deploy/index.py │ python │ xx KiB │
10128-
└──────────────────────────────────────┴────────┴──────────┘
10129-
Total Upload: xx KiB / gzip: xx KiB
10130-
Uploaded test-name (TIMINGS)
10131-
Published test-name (TIMINGS)
10132-
https://test-name.test-sub-domain.workers.dev
10133-
Current Deployment ID: Galaxy-Class
10134-
Current Version ID: Galaxy-Class
10128+
"┌──────────────────────────────────────┬────────┬──────────┐
10129+
│ Name │ Type │ Size │
10130+
├──────────────────────────────────────┼────────┼──────────┤
10131+
│ .wrangler/tmp/deploy/index.py │ python │ xx KiB │
10132+
├──────────────────────────────────────┼────────┼──────────┤
10133+
│ Total (1 module) │ │ xx KiB │
10134+
└──────────────────────────────────────┴────────┴──────────┘
10135+
Total Upload: xx KiB / gzip: xx KiB
10136+
Uploaded test-name (TIMINGS)
10137+
Published test-name (TIMINGS)
10138+
https://test-name.test-sub-domain.workers.dev
10139+
Current Deployment ID: Galaxy-Class
10140+
Current Version ID: Galaxy-Class
1013510141
1013610142
10137-
Note: Deployment ID has been renamed to Version ID. Deployment ID is present to maintain compatibility with the previous behavior of this command. This output will change in a future version of Wrangler. To learn more visit: https://developers.cloudflare.com/workers/configuration/versions-and-deployments"
10138-
`);
10143+
Note: Deployment ID has been renamed to Version ID. Deployment ID is present to maintain compatibility with the previous behavior of this command. This output will change in a future version of Wrangler. To learn more visit: https://developers.cloudflare.com/workers/configuration/versions-and-deployments"
10144+
`);
1013910145
});
1014010146
});
1014110147

packages/wrangler/src/__tests__/pages/functions-build.test.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -473,15 +473,17 @@ export const cat = "dog";`
473473

474474
expect(existsSync("public/_worker.bundle")).toBe(true);
475475
expect(std.out).toMatchInlineSnapshot(`
476-
"┌─────────┬──────┬──────────┐
477-
│ Name │ Type │ Size │
478-
├─────────┼──────┼──────────┤
479-
│ cat.js │ esm │ xx KiB │
480-
├─────────┼──────┼──────────┤
481-
│ dog.mjs │ esm │ xx KiB │
482-
└─────────┴──────┴──────────┘
483-
✨ Compiled Worker successfully"
484-
`);
476+
"┌───────────────────┬──────┬──────────┐
477+
│ Name │ Type │ Size │
478+
├───────────────────┼──────┼──────────┤
479+
│ cat.js │ esm │ xx KiB │
480+
├───────────────────┼──────┼──────────┤
481+
│ dog.mjs │ esm │ xx KiB │
482+
├───────────────────┼──────┼──────────┤
483+
│ Total (2 modules) │ │ xx KiB │
484+
└───────────────────┴──────┴──────────┘
485+
✨ Compiled Worker successfully"
486+
`);
485487

486488
const workerBundleContents = readFileSync("public/_worker.bundle", "utf-8");
487489
const workerBundleWithConstantData = replaceRandomWithConstantData(

packages/wrangler/src/deployment-bundle/find-additional-modules.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,13 @@ export async function findAdditionalModules(
109109

110110
if (modules.length > 0) {
111111
logger.info(`Attaching additional modules:`);
112-
logger.table(
113-
modules.map(({ name, type, content }) => {
112+
const totalSize = modules.reduce(
113+
(previous, { content }) => previous + content.length,
114+
0
115+
);
116+
117+
logger.table([
118+
...modules.map(({ name, type, content }) => {
114119
return {
115120
Name: name,
116121
Type: type ?? "",
@@ -119,8 +124,13 @@ export async function findAdditionalModules(
119124
? ""
120125
: `${(content.length / 1024).toFixed(2)} KiB`,
121126
};
122-
})
123-
);
127+
}),
128+
{
129+
Name: `Total (${modules.length} module${modules.length > 1 ? "s" : ""})`,
130+
Type: "",
131+
Size: `${(totalSize / 1024).toFixed(2)} KiB`,
132+
},
133+
]);
124134
}
125135

126136
return modules;

0 commit comments

Comments
 (0)