diff --git a/packages/bundler-plugin-core/src/index.ts b/packages/bundler-plugin-core/src/index.ts index d487483b..25ed91e2 100644 --- a/packages/bundler-plugin-core/src/index.ts +++ b/packages/bundler-plugin-core/src/index.ts @@ -126,24 +126,24 @@ export function sentryUnpluginFactory({ if (!options.sourcemaps?.disable) { plugins.push(debugIdInjectionPlugin(logger)); - } - // This option is only strongly typed for the webpack plugin, where it is used. It has no effect on other plugins - const webpack_forceExitOnBuildComplete = - typeof options._experiments["forceExitOnBuildCompletion"] === "boolean" - ? options._experiments["forceExitOnBuildCompletion"] - : undefined; - - plugins.push( - debugIdUploadPlugin( - createDebugIdUploadFunction({ - sentryBuildPluginManager, - }), - logger, - sentryBuildPluginManager.createDependencyOnBuildArtifacts, - webpack_forceExitOnBuildComplete - ) - ); + // This option is only strongly typed for the webpack plugin, where it is used. It has no effect on other plugins + const webpack_forceExitOnBuildComplete = + typeof options._experiments["forceExitOnBuildCompletion"] === "boolean" + ? options._experiments["forceExitOnBuildCompletion"] + : undefined; + + plugins.push( + debugIdUploadPlugin( + createDebugIdUploadFunction({ + sentryBuildPluginManager, + }), + logger, + sentryBuildPluginManager.createDependencyOnBuildArtifacts, + webpack_forceExitOnBuildComplete + ) + ); + } if (options.reactComponentAnnotation) { if (!options.reactComponentAnnotation.enabled) { diff --git a/packages/integration-tests/fixtures/disabled-sourcemaps-upload/disabled-sourcemaps-upload.test.ts b/packages/integration-tests/fixtures/disabled-sourcemaps-upload/disabled-sourcemaps-upload.test.ts new file mode 100644 index 00000000..dd22ef31 --- /dev/null +++ b/packages/integration-tests/fixtures/disabled-sourcemaps-upload/disabled-sourcemaps-upload.test.ts @@ -0,0 +1,26 @@ +import { sentryRollupPlugin } from "@sentry/rollup-plugin"; + +const debugIdUploadPluginName = "sentry-rollup-debug-id-upload-plugin"; + +test("should not call upload plugin when sourcemaps are disabled", () => { + const plugins = sentryRollupPlugin({ + telemetry: false, + sourcemaps: { + disable: true, + }, + }) as Array<{ name: string }>; + + const debugIdUploadPlugin = plugins.find((plugin) => plugin.name === debugIdUploadPluginName); + + expect(debugIdUploadPlugin).toBeUndefined(); +}); + +test("should call upload plugin when sourcemaps are enabled", () => { + const plugins = sentryRollupPlugin({ + telemetry: false, + }) as Array<{ name: string }>; + + const debugIdUploadPlugin = plugins.find((plugin) => plugin.name === debugIdUploadPluginName); + + expect(debugIdUploadPlugin).toBeDefined(); +}); diff --git a/packages/integration-tests/fixtures/disabled-sourcemaps-upload/input/bundle.js b/packages/integration-tests/fixtures/disabled-sourcemaps-upload/input/bundle.js new file mode 100644 index 00000000..85b0fd2b --- /dev/null +++ b/packages/integration-tests/fixtures/disabled-sourcemaps-upload/input/bundle.js @@ -0,0 +1,2 @@ +// eslint-disable-next-line no-console +console.log("Beep!");