-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: Create non-bundler plugin #169
Conversation
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found. Additional details and impacted files
☔ View full report in Codecov by Sentry. |
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found.
📢 Thoughts on this report? Let us know! |
Bundle ReportChanges will increase total bundle size by 448.95kB ⬆️
|
Bundle ReportChanges will increase total bundle size by 9.65kB (0.17%) ⬆️. This is within the configured threshold ✅ Detailed changes
|
.changeset/eleven-deers-divide.md
Outdated
--- | ||
"@codecov/bundle-analyzer": minor | ||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you include all the other plugins in here, that way everything gets bumped at the same time and stays on the same version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated!
const coreOpts = { | ||
dryRun: false, | ||
uploadToken: process.env.BUNDLE_ANALYZER_UPLOAD_TOKEN, | ||
retryCount: 3, | ||
apiUrl: "https://api.codecov.io", | ||
bundleName: "@codecov/example-bundle-analyzer-cjs", | ||
enableBundleAnalysis: true, | ||
debug: true, | ||
}; | ||
|
||
const bundleAnalyzerOpts = { | ||
beforeReportUpload: async (original) => original, | ||
ignorePatterns: ["*.map"], | ||
normalizeAssetsPattern: "[name]-[hash].js", | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the future, it would be nice to provide some types here that people can import and use with the satisfies
keyword, so they know they're correct fields and types for those fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah nice. I went through and exported the relevant types in bundle-analyzer
package and converted the ESM example to ts so people can see what that'd look like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Hrrm, iirc these trailing commas are against the JSON spec, can we quickly remove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah sorry that was my linter on save autorun (previously had a change in this file since removed). Our eslint/prettier project settings seem to make it so I have to do git commit --no-verify
to override the linter and get this to come back to the way matching main
😂. Spent 5min but couldn't get the trailingComma
/ comma-dangle
settings to match main - will try again later!
packages/bundle-analyzer/README.md
Outdated
> [!WARNING] | ||
> This bundle-analyzer package is subject to change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this comment, with the move the 1.0.0
this isn't as true as it used to be. This was more of a warning while in alpha/beta that we could break things without notice, which we're not doing anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated!
packages/bundle-analyzer/README.md
Outdated
pnpm add @codecov/bundle-analyzer --save-dev | ||
``` | ||
|
||
## Example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we update this to be something like Example - Custom Analysis Script
and add a heading for the CLI version something like Example - CLI
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated!
@@ -0,0 +1,80 @@ | |||
{ | |||
"name": "@codecov/bundle-analyzer", | |||
"version": "0.0.1-beta.12", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version i think needs to be set to 1.0.1
so that it aligns with what we have currently. Once this is merged and we prepare a publish it will be bumped to 1.0.2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated!
"keywords": [ | ||
"Codecov", | ||
"bundle-analyzer", | ||
"bundler", | ||
"analyzer" | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add cli
, and script
to the keywords 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated!
packages/bundle-analyzer/src/cli.ts
Outdated
.options({ | ||
"dry-run": { | ||
alias: "d", | ||
type: "boolean", | ||
description: "Perform a dry run without uploading", | ||
default: false, | ||
}, | ||
"upload-token": { | ||
alias: "t", | ||
type: "string", | ||
description: "Specify the upload token for authentication", | ||
}, | ||
"api-url": { | ||
alias: "u", | ||
type: "string", | ||
description: "Set the API URL", | ||
default: "https://api.codecov.io", | ||
}, | ||
"bundle-name": { | ||
alias: "n", | ||
type: "string", | ||
description: "Set the bundle identifier in Codecov", | ||
demandOption: true, | ||
}, | ||
debug: { | ||
alias: "v", | ||
type: "boolean", | ||
description: "Enable debug mode for additional logging", | ||
default: false, | ||
}, | ||
"ignore-patterns": { | ||
alias: "i", | ||
type: "array", | ||
description: "Specify file patterns to ignore during the analysis", | ||
}, | ||
"normalize-assets-pattern": { | ||
alias: "p", | ||
type: "string", | ||
description: "Pattern to normalize asset names, e.g., '[name]-[hash].js'", | ||
}, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So sorry for this, but I totally missed that we need to provide the ability for user to override the upload values. We need to do this in case we don't support the CI environment or they want to customize what is being sent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah.. in my pass I had intentionally only exposed some of the many options in the CLI version to keep it simple.
It's true it'll be a more useful tool if there's not a big disparity in the CLI's exposed functionality.
I added the option of a json config file to throw in all the less common configuration options
Description
This PR expands Codecov's Bundle Analysis product offering to those who operate without a standard bundler (e.g., webpack, rollup) in their production build flow.
It offers 2 options for such users:
When invoked, the operation walks through the specified file tree(s) and composes a Bundle Stats report in the expected Codecov format. It then calls existing
bundler-plugin-core
functions to fetch a pre-signed URL then upload the Bundle Stats report to Codecov.It requires the same coreOptions as
bundler-plugin-core
and also offers abeforeReportUpload
that allows users to overwrite fields in the Output as desired, before upload to Codecov. Other options includeignorePatterns
which lets you specify glob pattern files to ignore andnormalizeAssetsPattern
which lets you specify how Codecov should create a normalized name.Closes codecov/engineering-team#1652
Notable Changes
packages/bundle-analyzer
, which is built and published alongside all the existing plugins usingunbuild
androllup
.bundle-analyzer
package functionality.examples/bundle-analyzer
for both thecli
andlibrary-import
variants. Forlibrary-import
there are example tests for cjs and esm environments. All examples have bundle stats reports generated and pushed to Codecov as an end-to-end test.integration-tests/fixtures/generate-bundle-stats/bundle-analyzer
andintegration-tests/test-apps/bundle-analyzer
. These run against a mock API that can run in docker.pnpm run generate:typedoc
from the monorepo project root (docs get generated at./typedoc
).