-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bundle Analysis Configuration Feedback #270
Comments
|
It would also be nice to set a threshold change to not trigger a comment. We use Vite for our builds and it seems there is often a 10-35kB variation between builds even without any substantive changes to the code or dependencies. Being able to only have the comment appear when the change matters would help to avoid people from learning to ignore it when it shows up every time. |
@houserx-jmcc thank you for the feedback 🙏
I've added the update proposal to this WIP issue: codecov/engineering-team#1350 |
We've been running this for a few weeks now and it was really easy to setup and has worked fine. However, something that would be really useful is some way to filter or split bundles when reporting. In its simplest form an option to specify which file extensions to include/exclude would suffice. We are using Vite for our project and import our styles into the entry JS file, however when building for deployment we split out the CSS stuff into a separate file. This removes the styles themselves from the bundle analysis, but all the other stuff such as images and fonts that were included are still there. I'm only interested in the javascript parts (or possibly having a separate bundle for the styles/assets). Right now our bundle reports as 490kb which would be way to large for our scripts, but seeing as it is fonts in several formats and a few SVGs the size is quite OK. It makes it really hard to differentiates on changes though. Something like this would be great to be able to do. export default defineConfig({
plugins: [
codecovVitePlugin({
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
bundleName: 'script-bundle',
uploadToken: process.env.CODECOV_TOKEN,
extensions: [
'.js'
]
}),
codecovVitePlugin({
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
bundleName: 'style-bundle',
uploadToken: process.env.CODECOV_TOKEN,
extensions: [
'.css',
'.woff',
'.woff2',
'.svg',
'.png',
]
})
]
}); Also, if you look at the screenshot above the gzip size is completely wrong for some reason. |
@karl-sjogren thanks for the great feedback! 🙏
From my understanding of your feedback, based on that I created this issue here: codecov/engineering-team#1562. Would you say this accurately captures the issue? If TLDR, the goal is for you to specify the files you'd like to group to have analysis of size / changes. This way the reporting is more focused on what's important to you (generic filters for JS, etc don't do the job) - Is this understanding right? |
Yes that looks good to me! Thanks! |
Hi. I've been using this plugin but Codecov doesn't show any data yet, only the "Configure bundle analysis" info. Wondering what can be wrong in my setup (with Nx). Is this plugin generating some manifest file that is than uploaded to Codecov? How can I debug it. Thanks |
@estevaolucas are you able to share your repo/config? If it's working you should be seeing logs in your build informing you of what the plugin is doing, there is also a |
@nicholas-codecov thanks for you reply! I didn't notice there's a |
@estevaolucas Glad you got everything all sorted! If you run into any issues let us know. |
Great work on this feature! Just a minor comment on the documentation and a question about future implementation methods... The documentation references Angular in the webpack plugin but I don't think this is accurate for two reasons:
I am iffy about switching to a custom builder to use this feature. Are there plans to support source maps or |
Hey @grantwforsythe thanks for reaching out! We have on our roadmap to look into supporting We haven't looked into using source maps or |
Looking forward to it! Thanks for the clarification, @nicholas-codecov |
I'm trying to test this out as a POC and I'm getting this error [codecov] `get-pre-signed-url` fetch attempt 0 failed
[codecov] Attempting to fetch `get-pre-signed-url`, attempt: 1
[codecov] `get-pre-signed-url` fetch attempt 1 failed
[codecov] Attempting to fetch `get-pre-signed-url`, attempt: 2
[codecov] `get-pre-signed-url` fetch attempt 2 failed
[codecov] `get-pre-signed-url` failed after 2 attempts
[codecov] Failed to get pre-signed URL, bad response I'm using vite and my config looks like this import {defineConfig} from 'vite';
import {hydrogen} from '@shopify/hydrogen/vite';
import {oxygen} from '@shopify/mini-oxygen/vite';
import {vitePlugin as remix} from '@remix-run/dev';
import tsconfigPaths from 'vite-tsconfig-paths';
import {codecovVitePlugin} from '@codecov/vite-plugin';
export default defineConfig({
plugins: [
hydrogen(),
oxygen(),
remix({
presets: [hydrogen.preset()],
ignoredRouteFiles: ['**/.*', '**/*.test.*', '**/styleguide.tsx'],
future: {
v3_fetcherPersist: false,
v3_relativeSplatPath: false,
v3_throwAbortReason: false,
},
}),
tsconfigPaths(),
// Put the Codecov vite plugin after all other plugins
codecovVitePlugin({
debug: true,
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
bundleName: 'dist',
uploadToken: process.env.CODECOV_TOKEN,
}),
],
}); I've confirmed that my What am I missing? |
Hey @kayluhb! Hrrm first i just to note that we don't fully support Remix yet, as Vite does some funky things when it comes to client and server bundles that we'll be tackling shortly. Can you provide some info such as the repo you're trying to connect so we can filter our logs a bit more easily? |
Ah, bummer... Sure thing it's the tecovas-com/tecovas-hydrogen-storefront repo that I was playing around with it on. Thanks! |
I wanted to echo the same idea for esbuild, except esbuild generates a To elaborate, right now to enable bundle analysis for bundler X, a user would need to
With @grantwforsythe's suggestion, a user would need to
|
Hi. I just took a quick, ultimately unsuccessful run at this. Nothing I couldn't solve with a bit of a closer look. I was just trying to sneak this into an existing piece of work on my project, without giving it too much thought. I'm using Vite, running in Docker (via Docker Compose). Building with GitHub Actions.
I'll take another look at getting it running later. I'm not looking to waste anyone's time with 'solving' these ostensibly quite trivial issues for me. I'm just voicing this because it seems like a valuable first-run experience recount. |
Hi I'm facing difficulty using "vite": "5.2.7",
"@codecov/vite-plugin": "^1.1.0", // vite.config.mts
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
import react from '@vitejs/plugin-react-swc';
import { codecovVitePlugin } from '@codecov/vite-plugin';
export default defineConfig({
// ...other configs
plugins: [
react(),
nxViteTsPaths(),
codecovVitePlugin({
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
bundleName: 'dist',
uploadToken: process.env.CODECOV_TOKEN,
}),
],
}); [codecov] `get-pre-signed-url` fetch attempt 1 failed
[codecov] Attempting to fetch `get-pre-signed-url`, attempt: 2
[codecov] `get-pre-signed-url` fetch attempt 2 failed
[codecov] Attempting to fetch `get-pre-signed-url`, attempt: 3
[codecov] `get-pre-signed-url` fetch attempt 3 failed
[codecov] `get-pre-signed-url` failed after 2 attempts
[codecov] Failed to get pre-signed URL, bad response |
@Lee-Si-Yoon Are you running this locally or in CI? If you're attempting to run this locally, you'll need to update your Vite config to load in the env vars for you, you can read more about this in the Vite env docs, and the There's some issues with |
Hi @nicholas-codecov, thank you for prompt response I am running this locally, if I run build like below // vite.config.mts
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
import react from '@vitejs/plugin-react-swc';
import { codecovVitePlugin } from '@codecov/vite-plugin';
export default defineConfig(() => {
console.log('CODECOV: ', process.env.CODECOV_TOKEN);
return {
// ...other configs
plugins: [
react(),
nxViteTsPaths(),
codecovVitePlugin({
debug: true,
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
bundleName: 'dist',
uploadToken: process.env.CODECOV_TOKEN,
}),
],
};
}); the log I get is > vite build
CODECOV: e******* # <- env is loaded properly
vite v5.2.7 building for production...
...
[codecov] Detecting CI provider
[codecov] Detected CI provider: Local
[codecov] Using commit: null
computing gzip size (0)...
[codecov] Attempting to fetch `get-pre-signed-url`, attempt: 1
...
[codecov] `get-pre-signed-url` fetch attempt 1 failed
[codecov] Attempting to fetch `get-pre-signed-url`, attempt: 2
[codecov] `get-pre-signed-url` fetch attempt 2 failed
[codecov] Attempting to fetch `get-pre-signed-url`, attempt: 3
[codecov] `get-pre-signed-url` fetch attempt 3 failed
[codecov] `get-pre-signed-url` failed after 2 attempts
[codecov] Failed to get pre-signed URL, bad response I assume |
@Lee-Si-Yoon, yep that's going to be the problem. Hrrm, so when we detect that you're running locally we attempt to run Git commands to collect information from your local Git repository. Do you have any issue executing these commands in the same directory as your app? Collects branch name: git rev-parse --abbrev-ref HEAD Collects commit sha: git rev-parse HEAD Collects repo slug: git config --get remote.origin.url |
@nicholas-codecov, I tested out in github CI with debug mode enabled and by using grabbing the SHA from the GHA event context. But I still have problem uploading bundle. rendering chunks...
[codecov] Detecting CI provider
[codecov] Detected CI provider: GitHub Actions
computing gzip size...
[codecov] Using commit: 3a5c***
[codecov] Using compareSha: f72***
[codecov] Attempting to fetch `get-pre-signed-url`, attempt: 1
...
[codecov] Failed to validate pre-signed URL
✓ built in 40.26s So I also tried out CLI way
But does not work. Coverage is uploaded well so I do not think it is related to wrong access token or commit order. |
@Lee-Si-Yoon hrrm, let me check in with my co-worker to see if we can dive a bit deeper into the backend side of things. |
Any updates on this? Seems like I'm facing same issue. I'm using a private repository. |
@neelrocketbots and @Lee-Si-Yoon we've rolled out a fix for a small bug we believe may be causing this, this morning. Let us know if you continue to see this. |
Hey, @nicholas-codecov Still facing same issue |
Hi, |
Hey @neelrocketbots, @sweden-snow, sorry about this we need to update our docs a bit more on this, but if you're running locally with Vite you'll need to use their way of loading envs locally. If you're running in CI however, if my memory serves me correctly cc @aj-codecov we need to update our docs/onboarding with these caveats. |
I tried to set this up for webpack4 but it looks like it is not supported - I get a I don't think I see the webpack version requirements in your documentation so I think the docs should be updated to specify webpack5 only. |
Thanks for the feedback @md384, I have updated the docs to make this a bit clearer. |
Apologies, false alarm. Turns out the issue is related to an Nx command — not the Codecov plugin.I've spent the last while trying to integrate the Webpack plugin with CircleCI and it's not gone well. The Circle agents keep running out of memory, at it seems as though the problem is related to the mismatch between Circle's host agents' reported CPU count (32) vs the actually available CPUs (2). The Webpack bundle analysis tool tries to use a bunch of CPUs that aren't actually available, and we get a situation like the following, which blows the machine up: I think we need a param in the plugin to restrict/disable parallelization, or something of the sort. |
@kwonoj I am fairly certain that timeseries is required to get the chart working on this page. @JerrySentry can you confirm that? |
Hello I would love to use bundle analysis with my npm package which is a NestJS bundle relying on TSC rather than the bundlers listed. How can i set this up |
Hey @brunobuddy 👋 Have you taken a peek at our I think that may meet your requirements, as it does not require a bundler to operate! |
Hello, we are unable to upload the bundle for analysis. We are using GitHub Actions, and I have attached the following errors with debugging turned on.
|
Hello @nicholas-codecov Thank you for this information. I made it with the package ! However for some reason it seams that it only checks the master branch. In all PRs the bundle bot appears to say that the bundle has not changed (which is false). Once the PR is merged to master it does take the bundle change in account though. Ex:
My GitHub Action seems fine: - name: Build App
run: npm run build
- name: Bundle analysis
run: npx @codecov/bundle-analyzer ./dist --bundle-name=manifest --upload-token=${{ secrets.CODECOV_TOKEN }}
working-directory: ./packages/core/manifest Is there something I did not get or is it a bug ? |
Hey @brunobuddy! Yeah, testing locally with the CLI the numbers align with what you say (or even slightly better), I will check with my team member to see if anything funky happened in the backend and get back to you! |
Thanks for dropping by! 👋
We'd love your feedback about the bundle analysis configuration and tool generally..
We greatly appreciate your time and thoughts - looking forward to hearing from you ❤
Codecov team
This issue is intended to share and collect feedback about the tool. If you have support needs or questions, please see our support page.
The text was updated successfully, but these errors were encountered: