Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions packages/bundler-plugin-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import path from "path";

import * as rollup from "rollup";
import { sentryRollupPlugin } from "@sentry/rollup-plugin";

function getGlobalWithDebugIdUploads(): typeof global & {
__SENTRY_DEBUG_ID_UPLOAD_TEST__?: boolean;
} {
return global;
}

test("should not call upload plugin when sourcemaps are disabled", async () => {
process.env["SENTRY_NODE_ENV"] = "test";
const gbl = getGlobalWithDebugIdUploads();
gbl.__SENTRY_DEBUG_ID_UPLOAD_TEST__ = false;

await rollup.rollup({
input: { bundle1: path.resolve(__dirname, "input", "bundle.js") },
plugins: [
sentryRollupPlugin({
telemetry: false,
sourcemaps: {
disable: true,
},
}),
],
});

expect(gbl.__SENTRY_DEBUG_ID_UPLOAD_TEST__).toBe(false);
delete process.env["SENTRY_NODE_ENV"];
});

test("should call upload plugin when sourcemaps are enabled", async () => {
process.env["SENTRY_NODE_ENV"] = "test";
const gbl = getGlobalWithDebugIdUploads();
gbl.__SENTRY_DEBUG_ID_UPLOAD_TEST__ = false;

await rollup.rollup({
input: { bundle1: path.resolve(__dirname, "input", "bundle.js") },
plugins: [
sentryRollupPlugin({
telemetry: false,
}),
],
});

expect(gbl.__SENTRY_DEBUG_ID_UPLOAD_TEST__).toBe(true);
delete process.env["SENTRY_NODE_ENV"];
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line no-console
console.log("Beep!");
6 changes: 6 additions & 0 deletions packages/rollup-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ function rollupDebugIdUploadPlugin(
logger: Logger,
createDependencyOnBuildArtifacts: () => () => void
): UnpluginOptions {
// Only for testing purposes
if (process.env["SENTRY_NODE_ENV"] === "test") {
if ("__SENTRY_DEBUG_ID_UPLOAD_TEST__" in global) {
global.__SENTRY_DEBUG_ID_UPLOAD_TEST__ = true;
}
}
return {
name: "sentry-rollup-debug-id-upload-plugin",
rollup: createRollupDebugIdUploadHooks(upload, logger, createDependencyOnBuildArtifacts),
Expand Down
Loading