Skip to content

Commit 5ad4bfa

Browse files
authored
ref: Remove source maps from bundle stats (#111)
Update plugins to remove files with the .map extension clearing out source maps from bundle stats.
1 parent 6c02b73 commit 5ad4bfa

File tree

15 files changed

+627
-26
lines changed

15 files changed

+627
-26
lines changed

.changeset/chilled-eagles-protect.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@codecov/bundler-plugin-core": patch
3+
"@codecov/webpack-plugin": patch
4+
"@codecov/rollup-plugin": patch
5+
"@codecov/vite-plugin": patch
6+
---
7+
8+
Update plugins to remove sourcemaps from bundle stats data

integration-tests/fixtures/generate-bundle-stats/rollup/__snapshots__/rollup-plugin.test.ts.snap

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,3 +1367,155 @@ exports[`Generating rollup stats 4 {"format":"systemjs","expected":"system"} mat
13671367
"version": "1",
13681368
}
13691369
`;
1370+
1371+
exports[`Generating rollup stats 3 source maps are enabled does not include any source maps 1`] = `
1372+
{
1373+
"assets": [
1374+
{
1375+
"name": "main-6ff1e9ca.js",
1376+
"normalized": "main-*.js",
1377+
"size": 560913,
1378+
},
1379+
],
1380+
"builtAt": Any<Number>,
1381+
"bundleName": StringNotContaining ".map",
1382+
"bundler": {
1383+
"name": "rollup",
1384+
"version": "3.29.4",
1385+
},
1386+
"chunks": [
1387+
{
1388+
"entry": true,
1389+
"files": [
1390+
"main-6ff1e9ca.js",
1391+
],
1392+
"id": "main",
1393+
"initial": false,
1394+
"names": [
1395+
"main",
1396+
],
1397+
"uniqueId": "0-main",
1398+
},
1399+
],
1400+
"duration": Any<Number>,
1401+
"modules": [
1402+
{
1403+
"chunkUniqueIds": [
1404+
"0-main",
1405+
],
1406+
"name": "./commonjsHelpers.js",
1407+
"size": 334,
1408+
},
1409+
{
1410+
"chunkUniqueIds": [
1411+
"0-main",
1412+
],
1413+
"name": "../node_modules/.pnpm/[email protected]/node_modules/lodash/lodash.js?commonjs-module",
1414+
"size": 27,
1415+
},
1416+
{
1417+
"chunkUniqueIds": [
1418+
"0-main",
1419+
],
1420+
"name": "../node_modules/.pnpm/[email protected]/node_modules/lodash/lodash.js",
1421+
"size": 560240,
1422+
},
1423+
{
1424+
"chunkUniqueIds": [
1425+
"0-main",
1426+
],
1427+
"name": "./test-apps/rollup/src/getRandomNumber.js",
1428+
"size": 98,
1429+
},
1430+
{
1431+
"chunkUniqueIds": [
1432+
"0-main",
1433+
],
1434+
"name": "./test-apps/rollup/src/main.js",
1435+
"size": 163,
1436+
},
1437+
],
1438+
"outputPath": StringContaining "/distV3",
1439+
"plugin": {
1440+
"name": "codecov-rollup-bundle-analysis-plugin",
1441+
"version": "1.0.0",
1442+
},
1443+
"version": "1",
1444+
}
1445+
`;
1446+
1447+
exports[`Generating rollup stats 4 source maps are enabled does not include any source maps 1`] = `
1448+
{
1449+
"assets": [
1450+
{
1451+
"name": "main-v-vWaFyT.js",
1452+
"normalized": "main-*.js",
1453+
"size": 560913,
1454+
},
1455+
],
1456+
"builtAt": Any<Number>,
1457+
"bundleName": StringNotContaining ".map",
1458+
"bundler": {
1459+
"name": "rollup",
1460+
"version": "4.9.6",
1461+
},
1462+
"chunks": [
1463+
{
1464+
"entry": true,
1465+
"files": [
1466+
"main-v-vWaFyT.js",
1467+
],
1468+
"id": "main",
1469+
"initial": false,
1470+
"names": [
1471+
"main",
1472+
],
1473+
"uniqueId": "0-main",
1474+
},
1475+
],
1476+
"duration": Any<Number>,
1477+
"modules": [
1478+
{
1479+
"chunkUniqueIds": [
1480+
"0-main",
1481+
],
1482+
"name": "./commonjsHelpers.js",
1483+
"size": 334,
1484+
},
1485+
{
1486+
"chunkUniqueIds": [
1487+
"0-main",
1488+
],
1489+
"name": "../node_modules/.pnpm/[email protected]/node_modules/lodash/lodash.js?commonjs-module",
1490+
"size": 27,
1491+
},
1492+
{
1493+
"chunkUniqueIds": [
1494+
"0-main",
1495+
],
1496+
"name": "../node_modules/.pnpm/[email protected]/node_modules/lodash/lodash.js",
1497+
"size": 560240,
1498+
},
1499+
{
1500+
"chunkUniqueIds": [
1501+
"0-main",
1502+
],
1503+
"name": "./test-apps/rollup/src/getRandomNumber.js",
1504+
"size": 98,
1505+
},
1506+
{
1507+
"chunkUniqueIds": [
1508+
"0-main",
1509+
],
1510+
"name": "./test-apps/rollup/src/main.js",
1511+
"size": 163,
1512+
},
1513+
],
1514+
"outputPath": StringContaining "/distV4",
1515+
"plugin": {
1516+
"name": "codecov-rollup-bundle-analysis-plugin",
1517+
"version": "1.0.0",
1518+
},
1519+
"version": "1",
1520+
}
1521+
`;

integration-tests/fixtures/generate-bundle-stats/rollup/rollup-base.config.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = defineConfig({
1212
dir: `${rollupPath}/distV3`,
1313
format: "esm",
1414
entryFileNames: "[name]-[hash].js",
15+
sourcemap: false,
1516
},
1617
plugins: [
1718
resolve(), // tells Rollup how to find date-fns in node_modules

integration-tests/fixtures/generate-bundle-stats/rollup/rollup-plugin.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ describe("Generating rollup stats", () => {
3535
version: `v${version}`,
3636
detectVersion: "v3",
3737
file_format: "cjs",
38+
enableSourceMaps: false,
3839
});
3940
});
4041

@@ -68,5 +69,47 @@ describe("Generating rollup stats", () => {
6869
});
6970
});
7071
});
72+
73+
describe("source maps are enabled", () => {
74+
beforeEach(async () => {
75+
await createConfig({
76+
bundler: "rollup",
77+
format: "esm",
78+
detectFormat: "esm",
79+
version: `v${version}`,
80+
detectVersion: "v3",
81+
file_format: "cjs",
82+
enableSourceMaps: true,
83+
});
84+
});
85+
86+
afterEach(async () => {
87+
await $`rm -rf ${rollupConfig(version, "esm")}`;
88+
await $`rm -rf ${rollupApp}/distV${version}`;
89+
});
90+
91+
it("does not include any source maps", async () => {
92+
const id = `rollup-v${version}-sourcemaps-${Date.now()}`;
93+
const rollup = rollupPath(version);
94+
const configFile = rollupConfig(version, "esm");
95+
const API_URL = `http://localhost:8000/test-url/${id}/200/false`;
96+
97+
// build the app
98+
await $`API_URL=${API_URL} node ${rollup} -c ${configFile}`;
99+
100+
// fetch stats from the server
101+
const res = await fetch(`http://localhost:8000/get-stats/${id}`);
102+
const data = (await res.json()) as { stats: string };
103+
const stats = JSON.parse(data.stats) as unknown;
104+
105+
// assert the stats
106+
expect(stats).toMatchSnapshot({
107+
builtAt: expect.any(Number),
108+
duration: expect.any(Number),
109+
outputPath: expect.stringContaining(`/distV${version}`),
110+
bundleName: expect.not.stringContaining(".map"),
111+
});
112+
});
113+
});
71114
});
72115
});

0 commit comments

Comments
 (0)