From 99686988f4a0fe32514f9d5c8ab229a4b102d9fc Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Mon, 18 Nov 2024 16:13:36 -0400 Subject: [PATCH] fix: Bundle names not being reset properly (#209) --- .changeset/neat-jobs-train.md | 14 ++++++++++++++ packages/bundler-plugin-core/src/utils/Output.ts | 8 ++++++-- .../nextJSWebpackBundleAnalysisPlugin.ts | 2 +- .../rollupBundleAnalysisPlugin.ts | 2 +- .../viteBundleAnalysisPlugin.ts | 2 +- .../webpackBundleAnalysisPlugin.ts | 2 +- 6 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 .changeset/neat-jobs-train.md diff --git a/.changeset/neat-jobs-train.md b/.changeset/neat-jobs-train.md new file mode 100644 index 00000000..f78a1bab --- /dev/null +++ b/.changeset/neat-jobs-train.md @@ -0,0 +1,14 @@ +--- +"@codecov/nextjs-webpack-plugin": patch +"@codecov/bundler-plugin-core": patch +"@codecov/webpack-plugin": patch +"@codecov/rollup-plugin": patch +"@codecov/vite-plugin": patch +"@codecov/bundle-analyzer": patch +"@codecov/nuxt-plugin": patch +"@codecov/remix-vite-plugin": patch +"@codecov/solidstart-plugin": patch +"@codecov/sveltekit-plugin": patch +--- + +Fix issue with bundle names not being reset in nextjs, rollup, vite, and webpack plugins. diff --git a/packages/bundler-plugin-core/src/utils/Output.ts b/packages/bundler-plugin-core/src/utils/Output.ts index fb7d8b38..7c9d569f 100644 --- a/packages/bundler-plugin-core/src/utils/Output.ts +++ b/packages/bundler-plugin-core/src/utils/Output.ts @@ -26,7 +26,7 @@ class Output { }; debug: boolean; gitService?: ValidGitService; - originalBundleName: string; + #internalOriginalBundleName: string; // uploader overrides branch?: string; build?: string; @@ -65,7 +65,7 @@ class Output { this.uploadToken = userOptions.uploadToken; this.debug = userOptions.debug; this.gitService = userOptions.gitService; - this.originalBundleName = userOptions.bundleName; + this.#internalOriginalBundleName = userOptions.bundleName; this.oidc = userOptions.oidc; if (userOptions.uploadOverrides) { @@ -107,6 +107,10 @@ class Output { return this.#internalBundleName; } + get originalBundleName() { + return this.#internalOriginalBundleName; + } + setPlugin(pluginName: string, pluginVersion: string) { if (!this.#internalLocks.pluginDetails) { this.#internalPlugin = { diff --git a/packages/nextjs-webpack-plugin/src/nextjs-webpack-bundle-analysis/nextJSWebpackBundleAnalysisPlugin.ts b/packages/nextjs-webpack-plugin/src/nextjs-webpack-bundle-analysis/nextJSWebpackBundleAnalysisPlugin.ts index 3acd8c33..8e4f35cf 100644 --- a/packages/nextjs-webpack-plugin/src/nextjs-webpack-bundle-analysis/nextJSWebpackBundleAnalysisPlugin.ts +++ b/packages/nextjs-webpack-plugin/src/nextjs-webpack-bundle-analysis/nextJSWebpackBundleAnalysisPlugin.ts @@ -43,7 +43,7 @@ export const nextJSWebpackBundleAnalysisPlugin: ExtendedBAUploadPlugin<{ stage: webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT, }, async () => { - output.setBundleName(output.bundleName); + output.setBundleName(output.originalBundleName); // Webpack base chunk format options: https://webpack.js.org/configuration/output/#outputchunkformat if (typeof compilation.outputOptions.chunkFormat === "string") { if (compilation.name && compilation.name !== "") { diff --git a/packages/rollup-plugin/src/rollup-bundle-analysis/rollupBundleAnalysisPlugin.ts b/packages/rollup-plugin/src/rollup-bundle-analysis/rollupBundleAnalysisPlugin.ts index 061ed048..cfb4c947 100644 --- a/packages/rollup-plugin/src/rollup-bundle-analysis/rollupBundleAnalysisPlugin.ts +++ b/packages/rollup-plugin/src/rollup-bundle-analysis/rollupBundleAnalysisPlugin.ts @@ -38,7 +38,7 @@ export const rollupBundleAnalysisPlugin: BundleAnalysisUploadPlugin = ({ return; } - output.setBundleName(output.bundleName); + output.setBundleName(output.originalBundleName); if (options.name && options.name !== "") { output.setBundleName(`${output.bundleName}-${options.name}`); } diff --git a/packages/vite-plugin/src/vite-bundle-analysis/viteBundleAnalysisPlugin.ts b/packages/vite-plugin/src/vite-bundle-analysis/viteBundleAnalysisPlugin.ts index 8d53ecdc..c47ea035 100644 --- a/packages/vite-plugin/src/vite-bundle-analysis/viteBundleAnalysisPlugin.ts +++ b/packages/vite-plugin/src/vite-bundle-analysis/viteBundleAnalysisPlugin.ts @@ -38,7 +38,7 @@ export const viteBundleAnalysisPlugin: BundleAnalysisUploadPlugin = ({ return; } - output.setBundleName(output.bundleName); + output.setBundleName(output.originalBundleName); // add in bundle name if present if (options.name && options.name !== "") { output.setBundleName(`${output.bundleName}-${options.name}`); diff --git a/packages/webpack-plugin/src/webpack-bundle-analysis/webpackBundleAnalysisPlugin.ts b/packages/webpack-plugin/src/webpack-bundle-analysis/webpackBundleAnalysisPlugin.ts index 446455ab..87f4b473 100644 --- a/packages/webpack-plugin/src/webpack-bundle-analysis/webpackBundleAnalysisPlugin.ts +++ b/packages/webpack-plugin/src/webpack-bundle-analysis/webpackBundleAnalysisPlugin.ts @@ -36,7 +36,7 @@ export const webpackBundleAnalysisPlugin: BundleAnalysisUploadPlugin = ({ stage: webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT, }, async () => { - output.setBundleName(output.bundleName); + output.setBundleName(output.originalBundleName); // Webpack base chunk format options: https://webpack.js.org/configuration/output/#outputchunkformat if (typeof compilation.outputOptions.chunkFormat === "string") { if (compilation.name && compilation.name !== "") {