-
Notifications
You must be signed in to change notification settings - Fork 2
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: Add in bundle name config option #26
Conversation
Codecov ReportAttention:
Additional details and impacted files
☔ View full report in Codecov by Sentry. |
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.
The changes in the git diff seem to be about the addition of a new bundleName
option to the bundling plugins. The bundleName
is set in the tests, function calls, and is added to the Output interface, but there is no clear use of it in the plugins themselves except for some condition checks and warning logging. The description or purpose behind this bundleName
addition is not clear from the git diff alone and it could be helpful to provide more information on its usage.
codecovRollupPlugin({ | ||
enableBundleAnalysis: true, | ||
dryRun: true, | ||
bundleName: "rollup-test", |
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.
The bundleName
option is added to the plugin, but it is not clear what it means or how it is used within the plugin itself. It could be helpful to add comments explaining what it does.
@@ -89,4 +93,8 @@ | |||
it("sets the correct bundler information", () => { | |||
expect(stats.bundler).toStrictEqual(expectedStats.bundler); | |||
}); | |||
|
|||
it("sets the correct bundle name", () => { |
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.
The test checks if the bundleName
in the stats is correctly set to the one provided in the plugin options. However, it is not clear how this bundleName
is used in the test or the functionality it provides.
const output: Output = { | ||
version: "1", | ||
bundleName: userOptions.bundleName ?? "", | ||
}; |
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.
The bundleName
is added to the Output object here. It would be useful to know where this object is used and what effect the bundleName
has on it.
@@ -21,7 +21,7 @@ interface CodecovUnpluginFactoryOptions { | |||
bundleAnalysisUploadPlugin: BundleAnalysisUploadPlugin; | |||
} | |||
|
|||
export function codecovUnpluginFactory({ | |||
function codecovUnpluginFactory({ | |||
bundleAnalysisUploadPlugin, |
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.
The codecovUnpluginFactory function is sightly modified, and it's not clear why. Perhaps it is related to the bundleName
implementation but it needs clarification.
@@ -28,6 +28,7 @@ export interface Module { | |||
|
|||
export interface Output { | |||
version?: string; | |||
bundleName: string; |
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.
The bundleName
field is added to the Output Interface. But, It seems to be mandatory in the Interface which might not be sensible as it's optional in Options Interface (and can be undefined).
* Required for uploading bundle analysis information. | ||
* | ||
* Example: `rollup-package` | ||
*/ |
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.
The bundleName
field is added to the Options Interface, but it's marked as optional. It should be mandatory if it's required for uploading bundle analysis information.
@@ -17,6 +18,12 @@ | |||
pluginVersion: "1.0.0", | |||
rollup: { | |||
generateBundle(this, options, bundle) { | |||
// don't need to do anything if the bundle name is not present or empty | |||
if (!userOptions.bundleName || userOptions.bundleName === "") { |
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.
If bundleName
is not provided or is an empty string, red text stating 'Bundle name is not present or empty. Skipping upload.' is logged to the console. However, it's not sure if this behavior of skipping upload when bundleName is missing suits all use-cases.
red("Bundle name is not present or empty. Skipping upload."); | ||
return; | ||
} | ||
|
||
const customOptions = { |
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.
Again here, the upload is skipped if bundleName is not present. There seems to be a pattern of operational changes depending on whether the bundleName
exists.
import { type BundleAnalysisUploadPlugin } from "@codecov/bundler-plugin-core"; | ||
import { | ||
type BundleAnalysisUploadPlugin, | ||
red, |
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.
Red is imported but unused. This needs to be reviewed and removed if it's not needed.
@@ -18,6 +21,12 @@ | |||
stage: webpack4or5.Compilation.PROCESS_ASSETS_STAGE_REPORT, | |||
}, | |||
() => { | |||
// don't need to do anything if the bundle name is not present or empty | |||
if (!userOptions.bundleName || userOptions.bundleName === "") { |
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.
Without the context of what this bundleName
is meant to contribute to the functionality of the plugins, the addition of it at so many points throughout these files lessens the readability and understanding.
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.
CodecovAI submitted a new review for 3930adc
Description
This PR adds in a new configuration option
bundleName
which is required when using the bundle analysis plugin. If not provided then an error message will be emitted and the core plugin will not attempt and upload.Code Example
Notable Changes
bundleName
config optionbundleName
to stats JSON output