Skip to content

Commit 392003d

Browse files
authored
feat: Inline @sentry/core dependency (#242)
Inline `@sentry/core` dependency in `@codecov/bundler-plugin-core`
1 parent 553176a commit 392003d

File tree

5 files changed

+196
-95
lines changed

5 files changed

+196
-95
lines changed

.changeset/brown-ears-check.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
"@codecov/bundler-plugin-core": minor
3+
"@codecov/astro-plugin": minor
4+
"@codecov/bundle-analyzer": minor
5+
"@codecov/nextjs-webpack-plugin": minor
6+
"@codecov/nuxt-plugin": minor
7+
"@codecov/remix-vite-plugin": minor
8+
"@codecov/rollup-plugin": minor
9+
"@codecov/solidstart-plugin": minor
10+
"@codecov/sveltekit-plugin": minor
11+
"@codecov/vite-plugin": minor
12+
"@codecov/webpack-plugin": minor
13+
---
14+
15+
Inline @sentry/core dependency

examples/bundle-analyzer-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
"type": "module",
2020
"scripts": {
21-
"build": "rollup -c && pnpm bundle-analyzer ./dist -v --bundle-name=@codecov/example-bundle-analyzer-cli --upload-token=$BUNDLE_ANALYZER_UPLOAD_TOKEN --api-url=$BUNDLE_ANALYZER_API_URL --config-file=./baconfig.json"
21+
"build": "rollup -c && pnpm bundle-analyzer ./dist -v --bundle-name=@codecov/example-bundle-analyzer-cli --upload-token=$BUNDLE_ANALYZER_UPLOAD_TOKEN --api-url=$BUNDLE_ANALYZER_API_URL --config-file=./baconfig.json --debug"
2222
},
2323
"devDependencies": {
2424
"@codecov/bundle-analyzer": "workspace:^",

packages/bundler-plugin-core/build.config.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,25 @@ export default defineBuildConfig({
1919
},
2020
},
2121
hooks: {
22-
"rollup:options": (_ctx, opts) => {
22+
"rollup:options": (ctx, opts) => {
23+
// We want to ensure that `@sentry/core` is not externalized
24+
// So we do not ship this dependency to users, as this may lead to conflicts with their installed Sentry versions
25+
// TODO: When unbuild is updated to 3.3.0, this can be simplified by configuring `inlineDependencies`
26+
// See: https://github.com/unjs/unbuild/releases/tag/v3.3.0
27+
// Inspired by https://github.com/nuxt/nuxt/blob/f0ce20388d2ab533eba016de0565c150ea3c5172/packages/schema/build.config.ts#L23-L34
28+
ctx.options.rollup.dts.respectExternal = false;
29+
const isExternal = opts.external as (
30+
id: string,
31+
importer?: string,
32+
isResolved?: boolean,
33+
) => boolean;
34+
opts.external = (source, importer, isResolved) => {
35+
if (source === "@sentry/core") {
36+
return false;
37+
}
38+
return isExternal(source, importer, isResolved);
39+
};
40+
2341
if (process.env.PLUGIN_CODECOV_TOKEN && Array.isArray(opts.plugins)) {
2442
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-floating-promises
2543
opts.plugins = [

packages/bundler-plugin-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@
4141
"dependencies": {
4242
"@actions/core": "^1.10.1",
4343
"@actions/github": "^6.0.0",
44-
"@sentry/core": "^8.42.0",
4544
"chalk": "4.1.2",
4645
"semver": "^7.5.4",
4746
"unplugin": "^1.10.1",
4847
"zod": "^3.22.4"
4948
},
5049
"devDependencies": {
5150
"@octokit/webhooks-definitions": "^3.67.3",
51+
"@sentry/core": "^8.42.0",
5252
"@types/node": "^20.11.15",
5353
"@types/semver": "^7.5.6",
5454
"@vitest/coverage-v8": "^2.1.8",

0 commit comments

Comments
 (0)