Skip to content

Commit 043b250

Browse files
fix: Legacy Vite build hashes not being normalized (#247)
fix: Legacy Vite build hashes not being normalized.
1 parent 392003d commit 043b250

File tree

73 files changed

+1847
-1285
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1847
-1285
lines changed

.changeset/empty-hounds-grow.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
"@codecov/nextjs-webpack-plugin": minor
3+
"@codecov/bundler-plugin-core": minor
4+
"@codecov/remix-vite-plugin": minor
5+
"@codecov/solidstart-plugin": minor
6+
"@codecov/sveltekit-plugin": minor
7+
"@codecov/bundle-analyzer": minor
8+
"@codecov/webpack-plugin": minor
9+
"@codecov/rollup-plugin": minor
10+
"@codecov/astro-plugin": minor
11+
"@codecov/nuxt-plugin": minor
12+
"@codecov/vite-plugin": minor
13+
---
14+
15+
Update normalizePath to handle Vite legacy builds as they currently are not being normalized

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"typedoc": "^0.27.5",
4747
"typescript": "^5.3.3",
4848
"vite": "^6.0.3",
49-
"vitest": "^2.1.8"
49+
"vitest": "^2.1.9"
5050
},
5151
"lint-staged": {
5252
"*.{js,jsx,ts,tsx,json,css,scss,md,json}": [

packages/astro-plugin/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"devDependencies": {
5959
"@rollup/plugin-replace": "^5.0.5",
6060
"@types/node": "^20.11.15",
61-
"@vitest/coverage-v8": "^2.1.8",
61+
"@vitest/coverage-v8": "^2.1.9",
6262
"astro": "^5.0.9",
6363
"codecovProdRollupPlugin": "npm:@codecov/[email protected]",
6464
"msw": "^2.7.0",
@@ -67,7 +67,7 @@
6767
"typescript": "^5.3.3",
6868
"unbuild": "^2.0.0",
6969
"vite": "^6.0.3",
70-
"vitest": "^2.1.8"
70+
"vitest": "^2.1.9"
7171
},
7272
"peerDependencies": {
7373
"astro": "4.x || 5.x"

packages/astro-plugin/src/astro-bundle-analysis/__tests__/astroBundleAnalysisPlugin.test.ts

+13-10
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,19 @@ describe("astroBundleAnalysisPlugin", () => {
1212
it("returns a plugin object", () => {
1313
const plugin = astroBundleAnalysisPlugin({
1414
target: "client",
15-
output: new Output({
16-
apiUrl: "http://localhost",
17-
bundleName: "test-bundle",
18-
debug: false,
19-
dryRun: true,
20-
enableBundleAnalysis: true,
21-
retryCount: 1,
22-
uploadToken: "test-token",
23-
telemetry: false,
24-
}),
15+
output: new Output(
16+
{
17+
apiUrl: "http://localhost",
18+
bundleName: "test-bundle",
19+
debug: false,
20+
dryRun: true,
21+
enableBundleAnalysis: true,
22+
retryCount: 1,
23+
uploadToken: "test-token",
24+
telemetry: false,
25+
},
26+
{ metaFramework: "vite" },
27+
),
2528
pluginName: PLUGIN_NAME,
2629
pluginVersion: PLUGIN_VERSION,
2730
});

packages/astro-plugin/src/index.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ const astroPluginFactory = createVitePlugin<AstroPluginFactoryOptions, true>(
5151
bundler: unpluginMetaContext.framework,
5252
metaFramework: "astro",
5353
});
54-
const output = new Output(options, sentryConfig);
54+
55+
const output = new Output(
56+
options,
57+
{ metaFramework: unpluginMetaContext.framework },
58+
sentryConfig,
59+
);
60+
5561
if (options.enableBundleAnalysis) {
5662
plugins.push(
5763
telemetryPlugin({

packages/bundle-analyzer/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@
6363
"@types/micromatch": "^4.0.9",
6464
"@types/node": "^20.11.15",
6565
"@types/yargs": "^17.0.33",
66-
"@vitest/coverage-v8": "^2.1.8",
66+
"@vitest/coverage-v8": "^2.1.9",
6767
"codecovProdRollupPlugin": "npm:@codecov/[email protected]",
6868
"msw": "^2.7.0",
6969
"ts-node": "^10.9.2",
7070
"typedoc": "^0.27.5",
7171
"unbuild": "^2.0.0",
7272
"vite": "^6.0.3",
73-
"vitest": "^2.1.8"
73+
"vitest": "^2.1.9"
7474
},
7575
"volta": {
7676
"extends": "../../package.json"

packages/bundle-analyzer/src/assets.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ describe("getAsset", () => {
105105
expect(normalizePath).toHaveBeenCalledWith(
106106
path.relative(mockParentPath, mockFilePath),
107107
"",
108+
"bundle-analyzer",
108109
);
109110
expect(asset).toEqual({
110111
name: path.relative(mockParentPath, mockFilePath),
@@ -127,6 +128,7 @@ describe("getAsset", () => {
127128
expect(normalizePath).toHaveBeenCalledWith(
128129
path.relative(mockParentPath, mockFilePath),
129130
inputPattern,
131+
"bundle-analyzer",
130132
);
131133

132134
expect(asset.normalized).toBe(expectedNormalizedName);

packages/bundle-analyzer/src/assets.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ export const getAsset = async (
5555

5656
// normalize the file name if a pattern is provided. By default (when pattern is ""), this
5757
// will replace anything "hashlike" with *. For example index-1dca144e.js --> index-*.js
58-
const normalizedName = normalizePath(fileName, normalizeAssetsPattern);
58+
const normalizedName = normalizePath(
59+
fileName,
60+
normalizeAssetsPattern,
61+
"bundle-analyzer",
62+
);
5963

6064
return {
6165
name: fileName,

packages/bundle-analyzer/src/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ const createReport = async (
9090
normalizedBundleAnalyzerOptions: NormalizedBundleAnalyzerOptions,
9191
): Promise<Output> => {
9292
// initialize report
93-
const output: Output = new Output(normalizedCoreOptions);
93+
const output: Output = new Output(normalizedCoreOptions, {
94+
metaFramework: "bundle-analyzer",
95+
});
9496
output.start();
9597
output.setPlugin(PLUGIN_NAME, PLUGIN_VERSION);
9698

packages/bundler-plugin-core/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"@sentry/core": "^8.42.0",
5252
"@types/node": "^20.11.15",
5353
"@types/semver": "^7.5.6",
54-
"@vitest/coverage-v8": "^2.1.8",
54+
"@vitest/coverage-v8": "^2.1.9",
5555
"codecovProdRollupPlugin": "npm:@codecov/[email protected]",
5656
"msw": "^2.7.0",
5757
"testdouble": "^3.20.1",
@@ -60,7 +60,7 @@
6060
"typedoc": "^0.27.5",
6161
"typescript": "^5.3.3",
6262
"unbuild": "^2.0.0",
63-
"vitest": "^2.1.8"
63+
"vitest": "^2.1.9"
6464
},
6565
"volta": {
6666
"extends": "../../package.json"

packages/bundler-plugin-core/src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
type ExtendedBAUploadPlugin,
99
type Chunk,
1010
type Module,
11+
type MetaFramework,
1112
type Options,
1213
type ProviderUtilInputs,
1314
type UploadOverrides,
@@ -38,6 +39,7 @@ export type {
3839
ExtendedBAUploadArgs,
3940
ExtendedBAUploadPlugin,
4041
Chunk,
42+
MetaFramework,
4143
Module,
4244
Options,
4345
NormalizedOptions,

packages/bundler-plugin-core/src/types.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type UnpluginOptions } from "unplugin";
1+
import { type UnpluginContextMeta, type UnpluginOptions } from "unplugin";
22
import { type Output } from "./utils/Output";
33
import { type ValidGitService } from "./utils/normalizeOptions";
44

@@ -7,6 +7,10 @@ export interface Dependency {
77
version: string;
88
}
99

10+
export type MetaFramework =
11+
| UnpluginContextMeta["framework"]
12+
| "bundle-analyzer";
13+
1014
export interface Asset {
1115
name: string;
1216
size: number;

packages/bundler-plugin-core/src/utils/Output.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { type Client, type Scope, startSpan } from "@sentry/core";
22
import {
33
type Asset,
44
type Chunk,
5+
type MetaFramework,
56
type Module,
67
type OutputPayload,
78
type ProviderUtilInputs,
@@ -15,6 +16,10 @@ import { type ValidGitService } from "./normalizeOptions";
1516
import { debug } from "./logging.ts";
1617
import { safeFlushTelemetry } from "../sentry/telemetry.ts";
1718

19+
interface OtherOptions {
20+
metaFramework: MetaFramework;
21+
}
22+
1823
interface SentryConfig {
1924
sentryClient?: Client;
2025
sentryScope?: Scope;
@@ -47,6 +52,7 @@ class Output {
4752
name: string;
4853
version: string;
4954
};
55+
metaFramework: MetaFramework;
5056
outputPath?: string;
5157
builtAt?: number;
5258
duration?: number;
@@ -66,7 +72,11 @@ class Output {
6672
sentryClient?: Client;
6773
sentryScope?: Scope;
6874

69-
constructor(userOptions: NormalizedOptions, sentryConfig?: SentryConfig) {
75+
constructor(
76+
userOptions: NormalizedOptions,
77+
otherOptions: OtherOptions,
78+
sentryConfig?: SentryConfig,
79+
) {
7080
this.version = "3";
7181
this.apiUrl = userOptions.apiUrl;
7282
this.dryRun = userOptions.dryRun;
@@ -80,7 +90,7 @@ class Output {
8090
this.telemetry = userOptions.telemetry;
8191
this.sentryClient = sentryConfig?.sentryClient;
8292
this.sentryScope = sentryConfig?.sentryScope;
83-
93+
this.metaFramework = otherOptions.metaFramework;
8494
if (userOptions.uploadOverrides) {
8595
this.branch = userOptions.uploadOverrides.branch;
8696
this.build = userOptions.uploadOverrides.build;

0 commit comments

Comments
 (0)