Skip to content

Commit b404ab7

Browse files
authored
Log size of additional modules (#4198)
* Log size of additional modules * Update snapshots * Create tiny-icons-breathe.md
1 parent 69b4303 commit b404ab7

4 files changed

Lines changed: 36 additions & 9 deletions

File tree

.changeset/tiny-icons-breathe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": minor
3+
---
4+
5+
When uploading additional modules with your worker, Wrangler will now report the (uncompressed) size of each individual module, as well as the aggregate size of your Worker

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,10 +2354,6 @@ addEventListener('fetch', event => {});`
23542354

23552355
expect(std.info).toMatchInlineSnapshot(`
23562356
"Attaching additional modules:
2357-
- a/1.mjs (esm)
2358-
- a/b/2.mjs (esm)
2359-
- a/b/3.mjs (esm)
2360-
- a/b/c/4.mjs (esm)
23612357
Fetching list of already uploaded assets...
23622358
Building list of assets to upload...
23632359
+ file-1.2ca234f380.text (uploading new version of file-1.text)
@@ -2366,7 +2362,18 @@ addEventListener('fetch', event => {});`
23662362
Uploaded 100% [2 out of 2]"
23672363
`);
23682364
expect(std.out).toMatchInlineSnapshot(`
2369-
"↗️ Done syncing assets
2365+
"┌─────────────┬──────┬──────────┐
2366+
│ Name │ Type │ Size │
2367+
├─────────────┼──────┼──────────┤
2368+
│ a/1.mjs │ esm │ xx KiB │
2369+
├─────────────┼──────┼──────────┤
2370+
│ a/b/2.mjs │ esm │ xx KiB │
2371+
├─────────────┼──────┼──────────┤
2372+
│ a/b/3.mjs │ esm │ xx KiB │
2373+
├─────────────┼──────┼──────────┤
2374+
│ a/b/c/4.mjs │ esm │ xx KiB │
2375+
└─────────────┴──────┴──────────┘
2376+
↗️ Done syncing assets
23702377
Total Upload: xx KiB / gzip: xx KiB
23712378
Uploaded test-name (TIMINGS)
23722379
Published test-name (TIMINGS)

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,16 @@ export const cat = "dog";`
470470
await runWrangler(`pages functions build --outfile=public/_worker.bundle`);
471471

472472
expect(existsSync("public/_worker.bundle")).toBe(true);
473-
expect(std.out).toMatchInlineSnapshot(`"✨ Compiled Worker successfully"`);
473+
expect(std.out).toMatchInlineSnapshot(`
474+
"┌─────────┬──────┬──────────┐
475+
│ Name │ Type │ Size │
476+
├─────────┼──────┼──────────┤
477+
│ cat.js │ esm │ xx KiB │
478+
├─────────┼──────┼──────────┤
479+
│ dog.mjs │ esm │ xx KiB │
480+
└─────────┴──────┴──────────┘
481+
✨ Compiled Worker successfully"
482+
`);
474483

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

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,15 @@ export async function findAdditionalModules(
5050

5151
if (modules.length > 0) {
5252
logger.info(`Attaching additional modules:`);
53-
modules.forEach(({ name, type }) => {
54-
logger.info(`- ${chalk.blue(name)} (${chalk.green(type ?? "")})`);
55-
});
53+
logger.table(
54+
modules.map(({ name, type, content }) => {
55+
return {
56+
Name: name,
57+
Type: type ?? "",
58+
Size: `${(content.length / 1024).toFixed(2)} KiB`,
59+
};
60+
})
61+
);
5662
}
5763

5864
return modules;

0 commit comments

Comments
 (0)