codecov / codecov/codecov-javascript-bundler-plugins

SvelteKit plugin is broken (treats every build as a new app)

Open
#252 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
9
Forks
10
PR merge metrics
No merged PRs in 30d

Description

It seems like the version number/hash it added to the bundle name, causing every build to be treated as a different app. For example, this is how the bundle report looks like for any one of my PRs, regardless of the changes:

Bundle name Previous size New size Change
todo-boards-__sveltekit_1uzgg2h.app-client-esm 0B 3.26MB +3.26MB
todo-boards-__sveltekit_1uzgg2h.app-server-esm 0B 2.85MB +2.85MB
todo-boards-__sveltekit_rjtutb.app-client-esm 3.25MB 3.25MB 0B
todo-boards-__sveltekit_rjtutb.app-server-esm 2.85MB 2.85MB 0B
todo-boards-__sveltekit_md9ml7.app-client-esm 3.25MB 3.25MB 0B
todo-boards-__sveltekit_md9ml7.app-server-esm 2.85MB 2.85MB 0B
todo-boards-__sveltekit_rw61bm.app-client-esm 3.25MB 3.25MB 0B
todo-boards-__sveltekit_rw61bm.app-server-esm 2.85MB 2.85MB 0B
todo-boards-__sveltekit_oc9q2g.app-client-esm 3.25MB 3.25MB 0B
todo-boards-__sveltekit_oc9q2g.app-server-esm 2.85MB 2.85MB 0B
todo-boards-__sveltekit_pd0dha.app-client-esm 3.25MB 3.25MB 0B
todo-boards-__sveltekit_pd0dha.app-server-esm 2.85MB 2.85MB 0B
todo-boards-__sveltekit_9048ew.app-client-esm 3.26MB 3.26MB 0B
todo-boards-__sveltekit_9048ew.app-server-esm 2.85MB 2.85MB 0B
todo-boards-__sveltekit_jb7hj3.app-client-esm 3.26MB 3.26MB 0B
todo-boards-__sveltekit_jb7hj3.app-server-esm 2.85MB 2.85MB 0B
todo-boards-__sveltekit_15434l3.app-client-esm 3.26MB 3.26MB 0B
todo-boards-__sveltekit_15434l3.app-server-esm 2.85MB 2.85MB 0B
todo-boards-__sveltekit_wbgdw4.app-client-esm 3.26MB 3.26MB 0B
todo-boards-__sveltekit_wbgdw4.app-server-esm 2.85MB 2.85MB 0B
todo-boards-__sveltekit_1ul4wew.app-client-esm 3.26MB 3.26MB 0B
todo-boards-__sveltekit_3mgeqa.app-client-esm 3.26MB 3.26MB 0B
todo-boards-__sveltekit_3mgeqa.app-server-esm 2.85MB 2.85MB 0B
todo-boards-__sveltekit_10ypcbc.app-client-esm 3.26MB 3.26MB 0B
todo-boards-__sveltekit_10ypcbc.app-server-esm 2.85MB 2.85MB 0B
todo-boards-__sveltekit_1xcvy2i.app-client-esm 3.26MB 3.26MB 0B
todo-boards-__sveltekit_1xcvy2i.app-server-esm 2.85MB 2.85MB 0B
todo-boards-__sveltekit_v9cwmu.app-client-esm 3.26MB 3.26MB 0B
todo-boards-__sveltekit_v9cwmu.app-server-esm 2.85MB 2.85MB 0B
todo-boards-__sveltekit_znjpv5.app-client-esm 3.26MB 3.26MB 0B
todo-boards-__sveltekit_znjpv5.app-server-esm 2.85MB 2.85MB 0B

This then gets incorrectly reported as a large change, even though it isn't:

Image

It seems like this is the code at fault:

https://github.com/codecov/codecov-javascript-bundler-plugins/blob/af1b7a9dadd9d2ceba9dba9d28e165d1f5a71a89/packages/sveltekit-plugin/src/sveltekit-bundle-analysis/sveltekitBundleAnalysisPlugin.ts#L24-L29

here, options.name is __sveltekit_1uzgg2h.app, changing on every build.

Workaround

Patch (can be applied for example using yarn patch):

diff --git a/dist/index.mjs b/dist/index.mjs
index af4d577bb316858597a9f420574129e0e799684f..6dfaaedd4fddf5a4edd5e2fbc49bb1485913943f 100644
--- a/dist/index.mjs
+++ b/dist/index.mjs
@@ -31,7 +31,6 @@ const sveltekitBundleAnalysisPlugin = ({
         output.originalBundleName,
         options.dir,
         options.format,
-        options.name
       );
       output.unlockBundleName();
       output.setBundleName(name);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at packages/sveltekit-plugin/src/sveltekit-bundle-analysis/sveltekitBundleAnalysisPlugin.ts, especially lines 24-29 linked in the report, and inspect how the bundle name is assembled. Compare the behavior with the provided workaround and verify that repeated builds produce stable bundle names without duplicate false size changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
performance, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.