Skip to content

Commit c0fd1df

Browse files
committed
disable debugId upload
1 parent 26a4840 commit c0fd1df

File tree

5 files changed

+71
-18
lines changed

5 files changed

+71
-18
lines changed

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -126,24 +126,24 @@ export function sentryUnpluginFactory({
126126

127127
if (!options.sourcemaps?.disable) {
128128
plugins.push(debugIdInjectionPlugin(logger));
129-
}
130129

131-
// This option is only strongly typed for the webpack plugin, where it is used. It has no effect on other plugins
132-
const webpack_forceExitOnBuildComplete =
133-
typeof options._experiments["forceExitOnBuildCompletion"] === "boolean"
134-
? options._experiments["forceExitOnBuildCompletion"]
135-
: undefined;
136-
137-
plugins.push(
138-
debugIdUploadPlugin(
139-
createDebugIdUploadFunction({
140-
sentryBuildPluginManager,
141-
}),
142-
logger,
143-
sentryBuildPluginManager.createDependencyOnBuildArtifacts,
144-
webpack_forceExitOnBuildComplete
145-
)
146-
);
130+
// This option is only strongly typed for the webpack plugin, where it is used. It has no effect on other plugins
131+
const webpack_forceExitOnBuildComplete =
132+
typeof options._experiments["forceExitOnBuildCompletion"] === "boolean"
133+
? options._experiments["forceExitOnBuildCompletion"]
134+
: undefined;
135+
136+
plugins.push(
137+
debugIdUploadPlugin(
138+
createDebugIdUploadFunction({
139+
sentryBuildPluginManager,
140+
}),
141+
logger,
142+
sentryBuildPluginManager.createDependencyOnBuildArtifacts,
143+
webpack_forceExitOnBuildComplete
144+
)
145+
);
146+
}
147147

148148
if (options.reactComponentAnnotation) {
149149
if (!options.reactComponentAnnotation.enabled) {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import path from "path";
2+
3+
import * as rollup from "rollup";
4+
import { sentryRollupPlugin } from "@sentry/rollup-plugin";
5+
6+
function getGlobalWithDebugIdUploads(): typeof global & {
7+
__SENTRY_DEBUG_ID_UPLOAD_TEST__?: boolean;
8+
} {
9+
return global;
10+
}
11+
12+
test("should not call upload plugin when sourcemaps are disabled", async () => {
13+
const gbl = getGlobalWithDebugIdUploads();
14+
gbl.__SENTRY_DEBUG_ID_UPLOAD_TEST__ = false;
15+
16+
await rollup.rollup({
17+
input: { bundle1: path.resolve(__dirname, "input", "bundle.js") },
18+
plugins: [
19+
sentryRollupPlugin({
20+
telemetry: false,
21+
sourcemaps: {
22+
disable: true,
23+
},
24+
}),
25+
],
26+
});
27+
28+
expect(gbl.__SENTRY_DEBUG_ID_UPLOAD_TEST__).toBe(false);
29+
});
30+
31+
test("should call upload plugin when sourcemaps are enabled", async () => {
32+
const gbl = getGlobalWithDebugIdUploads();
33+
gbl.__SENTRY_DEBUG_ID_UPLOAD_TEST__ = false;
34+
35+
await rollup.rollup({
36+
input: { bundle1: path.resolve(__dirname, "input", "bundle.js") },
37+
plugins: [
38+
sentryRollupPlugin({
39+
telemetry: false,
40+
}),
41+
],
42+
});
43+
44+
expect(gbl.__SENTRY_DEBUG_ID_UPLOAD_TEST__).toBe(true);
45+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// eslint-disable-next-line no-console
2+
console.log("Beep!");

packages/integration-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@
4747
"volta": {
4848
"extends": "../../package.json"
4949
}
50-
}
50+
}

packages/rollup-plugin/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ function rollupDebugIdUploadPlugin(
4545
logger: Logger,
4646
createDependencyOnBuildArtifacts: () => () => void
4747
): UnpluginOptions {
48+
// Only for testing purposes
49+
if (process.env["NODE_ENV"] === "test") {
50+
if ("__SENTRY_DEBUG_ID_UPLOAD_TEST__" in global) {
51+
global.__SENTRY_DEBUG_ID_UPLOAD_TEST__ = true;
52+
}
53+
}
4854
return {
4955
name: "sentry-rollup-debug-id-upload-plugin",
5056
rollup: createRollupDebugIdUploadHooks(upload, logger, createDependencyOnBuildArtifacts),

0 commit comments

Comments
 (0)