Skip to content

Commit 9e4b9d1

Browse files
committed
chore: Add CodeCov bundle analysis
1 parent 18f7107 commit 9e4b9d1

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"
@@ -8086,6 +8103,11 @@ acorn@^8.10.0:
80868103
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5"
80878104
integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==
80888105

8106+
acorn@^8.11.3:
8107+
version "8.11.3"
8108+
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a"
8109+
integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==
8110+
80898111
acorn@^8.2.4, acorn@^8.4.1, acorn@^8.5.0, acorn@^8.7.0, acorn@^8.7.1:
80908112
version "8.8.0"
80918113
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.0.tgz#88c0187620435c7f6015803f5539dae05a9dbea8"
@@ -11368,6 +11390,14 @@ [email protected]:
1136811390
ansi-styles "^4.1.0"
1136911391
supports-color "^7.1.0"
1137011392

11393+
[email protected], chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2:
11394+
version "4.1.2"
11395+
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
11396+
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
11397+
dependencies:
11398+
ansi-styles "^4.1.0"
11399+
supports-color "^7.1.0"
11400+
1137111401
chalk@^1.0.0, chalk@^1.1.3:
1137211402
version "1.1.3"
1137311403
resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
@@ -11379,14 +11409,6 @@ chalk@^1.0.0, chalk@^1.1.3:
1137911409
strip-ansi "^3.0.0"
1138011410
supports-color "^2.0.0"
1138111411

11382-
chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2:
11383-
version "4.1.2"
11384-
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
11385-
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
11386-
dependencies:
11387-
ansi-styles "^4.1.0"
11388-
supports-color "^7.1.0"
11389-
1139011412
chalk@^5.0.0, chalk@^5.2.0, chalk@^5.3.0:
1139111413
version "5.3.0"
1139211414
resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.3.0.tgz#67c20a7ebef70e7f3970a01f90fa210cb6860385"
@@ -31618,6 +31640,16 @@ [email protected]:
3161831640
webpack-sources "^3.2.3"
3161931641
webpack-virtual-modules "^0.5.0"
3162031642

31643+
unplugin@^1.6.0:
31644+
version "1.7.1"
31645+
resolved "https://registry.yarnpkg.com/unplugin/-/unplugin-1.7.1.tgz#009571e3128640f4e327f33680d2db27afaf1e11"
31646+
integrity sha512-JqzORDAPxxs8ErLV4x+LL7bk5pk3YlcWqpSNsIkAZj972KzFZLClc/ekppahKkOczGkwIG6ElFgdOgOlK4tXZw==
31647+
dependencies:
31648+
acorn "^8.11.3"
31649+
chokidar "^3.5.3"
31650+
webpack-sources "^3.2.3"
31651+
webpack-virtual-modules "^0.6.1"
31652+
3162131653
unquote@~1.1.1:
3162231654
version "1.1.1"
3162331655
resolved "https://registry.yarnpkg.com/unquote/-/unquote-1.1.1.tgz#8fded7324ec6e88a0ff8b905e7c098cdc086d544"
@@ -32515,6 +32547,11 @@ webpack-virtual-modules@^0.5.0:
3251532547
resolved "https://registry.yarnpkg.com/webpack-virtual-modules/-/webpack-virtual-modules-0.5.0.tgz#362f14738a56dae107937ab98ea7062e8bdd3b6c"
3251632548
integrity sha512-kyDivFZ7ZM0BVOUteVbDFhlRt7Ah/CSPwJdi8hBpkK7QLumUqdLtVfm/PX/hkcnrvr0i77fO5+TjZ94Pe+C9iw==
3251732549

32550+
webpack-virtual-modules@^0.6.1:
32551+
version "0.6.1"
32552+
resolved "https://registry.yarnpkg.com/webpack-virtual-modules/-/webpack-virtual-modules-0.6.1.tgz#ac6fdb9c5adb8caecd82ec241c9631b7a3681b6f"
32553+
integrity sha512-poXpCylU7ExuvZK8z+On3kX+S8o/2dQ/SVYueKA0D4WEMXROXgY8Ez50/bQEUmvoSMMrWcrJqCHuhAbsiwg7Dg==
32554+
3251832555
3251932556
version "4.44.1"
3252032557
resolved "https://registry.yarnpkg.com/webpack/-/webpack-4.44.1.tgz#17e69fff9f321b8f117d1fda714edfc0b939cc21"

0 commit comments

Comments
 (0)