Skip to content

Commit 59683b6

Browse files
committed
chore: Add CodeCov bundle analysis
1 parent 551aa86 commit 59683b6

File tree

5 files changed

+71
-9
lines changed

5 files changed

+71
-9
lines changed

dev-packages/rollup-utils/npmHelpers.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import deepMerge from 'deepmerge';
1010

1111
import {
1212
makeCleanupPlugin,
13+
makeCodeCovPlugin,
1314
makeDebugBuildStatementReplacePlugin,
1415
makeExtractPolyfillsPlugin,
1516
makeNodeResolvePlugin,
@@ -28,6 +29,7 @@ export function makeBaseNPMConfig(options = {}) {
2829
hasBundles = false,
2930
packageSpecificConfig = {},
3031
addPolyfills = true,
32+
bundleAnalysis,
3133
} = options;
3234

3335
const nodeResolvePlugin = makeNodeResolvePlugin();
@@ -111,13 +113,20 @@ export function makeBaseNPMConfig(options = {}) {
111113
defaultBaseConfig.plugins.push(extractPolyfillsPlugin);
112114
}
113115

116+
if (bundleAnalysis && bundleAnalysis.length) {
117+
defaultBaseConfig.plugins.push(makeCodeCovPlugin(bundleAnalysis));
118+
}
119+
114120
return deepMerge(defaultBaseConfig, packageSpecificConfig, {
115121
// Plugins have to be in the correct order or everything breaks, so when merging we have to manually re-order them
116122
customMerge: key => (key === 'plugins' ? mergePlugins : undefined),
117123
});
118124
}
119125

120126
export function makeNPMConfigVariants(baseConfig) {
127+
baseConfig.plugins = baseConfig.plugins || [];
128+
baseConfig.plugins.push()
129+
121130
const variantSpecificConfigs = [
122131
{ output: { format: 'cjs', dir: path.join(baseConfig.output.dir, 'cjs') } },
123132
{ output: { format: 'esm', dir: path.join(baseConfig.output.dir, 'esm') } },

dev-packages/rollup-utils/plugins/npmPlugins.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Sucrase plugin docs: https://github.com/rollup/plugins/tree/master/packages/sucrase
88
*/
99

10+
import { codecovRollupPlugin } from '@codecov/rollup-plugin';
1011
import replace from '@rollup/plugin-replace';
1112
import sucrase from '@rollup/plugin-sucrase';
1213
import cleanup from 'rollup-plugin-cleanup';
@@ -131,4 +132,16 @@ export function makeRrwebBuildPlugin({ excludeShadowDom, excludeIframe } = {}) {
131132
});
132133
}
133134

135+
/**
136+
* Plugin that uploads bundle analysis to codecov.
137+
*/
138+
export function makeCodeCovPlugin(bundleName) {
139+
console.log(process.env.GITHUB_ACTIONS, process.env.CODECOV_TOKEN === undefined)
140+
return codecovRollupPlugin({
141+
enableBundleAnalysis: process.env.GITHUB_ACTIONS === 'true' && process.env.CODECOV_TOKEN,
142+
bundleName,
143+
uploadToken: process.env.CODECOV_TOKEN,
144+
})
145+
}
146+
134147
export { makeExtractPolyfillsPlugin } from './extractPolyfillsPlugin.mjs';

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,8 @@
148148
"proseWrap": "always",
149149
"singleQuote": true,
150150
"trailingComma": "all"
151+
},
152+
"dependencies": {
153+
"@codecov/rollup-plugin": "^0.0.1-beta.0"
151154
}
152155
}

packages/core/rollup.npm.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollup-utils';
22

3-
export default makeNPMConfigVariants(makeBaseNPMConfig());
3+
export default makeNPMConfigVariants(makeBaseNPMConfig({ bundleAnalysis: 'npm:@sentry/core' }));

yarn.lock

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2527,6 +2527,23 @@
25272527
exec-sh "^0.3.2"
25282528
minimist "^1.2.0"
25292529

2530+
"@codecov/bundler-plugin-core@^0.0.1-beta.0":
2531+
version "0.0.1-beta.0"
2532+
resolved "https://registry.yarnpkg.com/@codecov/bundler-plugin-core/-/bundler-plugin-core-0.0.1-beta.0.tgz#b8c2bd4513c6d5ea5b2f1ca241b58b0d48a9453f"
2533+
integrity sha512-b3b2fZs9r9COefZEZYzGbLf0gab4HWKudwr6pkyUzXJEq061gIgQomeMxsBSRGVWkXtY6k9zzMDzkcVtj7A6GA==
2534+
dependencies:
2535+
chalk "4.1.2"
2536+
semver "^7.5.4"
2537+
unplugin "^1.6.0"
2538+
zod "^3.22.4"
2539+
2540+
"@codecov/rollup-plugin@^0.0.1-beta.0":
2541+
version "0.0.1-beta.0"
2542+
resolved "https://registry.yarnpkg.com/@codecov/rollup-plugin/-/rollup-plugin-0.0.1-beta.0.tgz#6d9dd52f751053171fb1576702646d1b912916fc"
2543+
integrity sha512-W0a/k8KG7FC534F/C9QrsSgH9Q07xHgvMAFm6PoUMJBdvYR8FS0NhdtUuyQTuo/zYBIone8UCYWDxnQbvmjAbQ==
2544+
dependencies:
2545+
"@codecov/bundler-plugin-core" "^0.0.1-beta.0"
2546+
25302547
25312548
version "1.5.0"
25322549
resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9"
@@ -8035,6 +8052,11 @@ acorn@^8.10.0:
80358052
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5"
80368053
integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==
80378054

8055+
acorn@^8.11.3:
8056+
version "8.11.3"
8057+
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a"
8058+
integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==
8059+
80388060
acorn@^8.2.4, acorn@^8.4.1, acorn@^8.5.0, acorn@^8.7.0, acorn@^8.7.1:
80398061
version "8.8.0"
80408062
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.0.tgz#88c0187620435c7f6015803f5539dae05a9dbea8"
@@ -11313,6 +11335,14 @@ [email protected]:
1131311335
ansi-styles "^4.1.0"
1131411336
supports-color "^7.1.0"
1131511337

11338+
[email protected], chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2:
11339+
version "4.1.2"
11340+
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
11341+
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
11342+
dependencies:
11343+
ansi-styles "^4.1.0"
11344+
supports-color "^7.1.0"
11345+
1131611346
chalk@^1.0.0, chalk@^1.1.3:
1131711347
version "1.1.3"
1131811348
resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
@@ -11324,14 +11354,6 @@ chalk@^1.0.0, chalk@^1.1.3:
1132411354
strip-ansi "^3.0.0"
1132511355
supports-color "^2.0.0"
1132611356

11327-
chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2:
11328-
version "4.1.2"
11329-
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
11330-
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
11331-
dependencies:
11332-
ansi-styles "^4.1.0"
11333-
supports-color "^7.1.0"
11334-
1133511357
chalk@^5.0.0, chalk@^5.2.0, chalk@^5.3.0:
1133611358
version "5.3.0"
1133711359
resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.3.0.tgz#67c20a7ebef70e7f3970a01f90fa210cb6860385"
@@ -31481,6 +31503,16 @@ [email protected]:
3148131503
webpack-sources "^3.2.3"
3148231504
webpack-virtual-modules "^0.5.0"
3148331505

31506+
unplugin@^1.6.0:
31507+
version "1.7.1"
31508+
resolved "https://registry.yarnpkg.com/unplugin/-/unplugin-1.7.1.tgz#009571e3128640f4e327f33680d2db27afaf1e11"
31509+
integrity sha512-JqzORDAPxxs8ErLV4x+LL7bk5pk3YlcWqpSNsIkAZj972KzFZLClc/ekppahKkOczGkwIG6ElFgdOgOlK4tXZw==
31510+
dependencies:
31511+
acorn "^8.11.3"
31512+
chokidar "^3.5.3"
31513+
webpack-sources "^3.2.3"
31514+
webpack-virtual-modules "^0.6.1"
31515+
3148431516
unquote@~1.1.1:
3148531517
version "1.1.1"
3148631518
resolved "https://registry.yarnpkg.com/unquote/-/unquote-1.1.1.tgz#8fded7324ec6e88a0ff8b905e7c098cdc086d544"
@@ -32378,6 +32410,11 @@ webpack-virtual-modules@^0.5.0:
3237832410
resolved "https://registry.yarnpkg.com/webpack-virtual-modules/-/webpack-virtual-modules-0.5.0.tgz#362f14738a56dae107937ab98ea7062e8bdd3b6c"
3237932411
integrity sha512-kyDivFZ7ZM0BVOUteVbDFhlRt7Ah/CSPwJdi8hBpkK7QLumUqdLtVfm/PX/hkcnrvr0i77fO5+TjZ94Pe+C9iw==
3238032412

32413+
webpack-virtual-modules@^0.6.1:
32414+
version "0.6.1"
32415+
resolved "https://registry.yarnpkg.com/webpack-virtual-modules/-/webpack-virtual-modules-0.6.1.tgz#ac6fdb9c5adb8caecd82ec241c9631b7a3681b6f"
32416+
integrity sha512-poXpCylU7ExuvZK8z+On3kX+S8o/2dQ/SVYueKA0D4WEMXROXgY8Ez50/bQEUmvoSMMrWcrJqCHuhAbsiwg7Dg==
32417+
3238132418
3238232419
version "4.44.1"
3238332420
resolved "https://registry.yarnpkg.com/webpack/-/webpack-4.44.1.tgz#17e69fff9f321b8f117d1fda714edfc0b939cc21"

0 commit comments

Comments
 (0)