@sentry/bundler-plugin-core 4.0.2 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -433,6 +433,31 @@ function _defineProperty(obj, key, value) {
433
433
  }
434
434
  return obj;
435
435
  }
436
+ function _toConsumableArray(arr) {
437
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
438
+ }
439
+ function _arrayWithoutHoles(arr) {
440
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
441
+ }
442
+ function _iterableToArray(iter) {
443
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
444
+ }
445
+ function _unsupportedIterableToArray(o, minLen) {
446
+ if (!o) return;
447
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
448
+ var n = Object.prototype.toString.call(o).slice(8, -1);
449
+ if (n === "Object" && o.constructor) n = o.constructor.name;
450
+ if (n === "Map" || n === "Set") return Array.from(o);
451
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
452
+ }
453
+ function _arrayLikeToArray(arr, len) {
454
+ if (len == null || len > arr.length) len = arr.length;
455
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
456
+ return arr2;
457
+ }
458
+ function _nonIterableSpread() {
459
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
460
+ }
436
461
  function _toPrimitive(input, hint) {
437
462
  if (typeof input !== "object" || input === null) return input;
438
463
  var prim = input[Symbol.toPrimitive];
@@ -2537,6 +2562,15 @@ function objectToBaggageHeader(object) {
2537
2562
  }, '');
2538
2563
  }
2539
2564
 
2565
+ // eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor -- RegExp is used for readability here
2566
+ const TRACEPARENT_REGEXP = new RegExp(
2567
+ '^[ \\t]*' + // whitespace
2568
+ '([0-9a-f]{32})?' + // trace_id
2569
+ '-?([0-9a-f]{16})?' + // span_id
2570
+ '-?([01])?' + // sampled
2571
+ '[ \\t]*$', // whitespace
2572
+ );
2573
+
2540
2574
  /**
2541
2575
  * Create sentry-trace header from span context values.
2542
2576
  */
@@ -7612,6 +7646,82 @@ function applySdkMetadata(options, name, names = [name], source = 'npm') {
7612
7646
  options._metadata = metadata;
7613
7647
  }
7614
7648
 
7649
+ /**
7650
+ * Extracts trace propagation data from the current span or from the client's scope (via transaction or propagation
7651
+ * context) and serializes it to `sentry-trace` and `baggage` values to strings. These values can be used to propagate
7652
+ * a trace via our tracing Http headers or Html `<meta>` tags.
7653
+ *
7654
+ * This function also applies some validation to the generated sentry-trace and baggage values to ensure that
7655
+ * only valid strings are returned.
7656
+ *
7657
+ * @returns an object with the tracing data values. The object keys are the name of the tracing key to be used as header
7658
+ * or meta tag name.
7659
+ */
7660
+ function getTraceData() {
7661
+ const carrier = getMainCarrier();
7662
+ const acs = getAsyncContextStrategy(carrier);
7663
+ if (acs.getTraceData) {
7664
+ return acs.getTraceData();
7665
+ }
7666
+
7667
+ const client = getClient();
7668
+ const scope = getCurrentScope();
7669
+ const span = getActiveSpan();
7670
+
7671
+ const { dsc, sampled, traceId } = scope.getPropagationContext();
7672
+ const rootSpan = span && getRootSpan(span);
7673
+
7674
+ const sentryTrace = span ? spanToTraceHeader(span) : generateSentryTraceHeader(traceId, undefined, sampled);
7675
+
7676
+ const dynamicSamplingContext = rootSpan
7677
+ ? getDynamicSamplingContextFromSpan(rootSpan)
7678
+ : dsc
7679
+ ? dsc
7680
+ : client
7681
+ ? getDynamicSamplingContextFromClient(traceId, client)
7682
+ : undefined;
7683
+
7684
+ const baggage = dynamicSamplingContextToSentryBaggageHeader(dynamicSamplingContext);
7685
+
7686
+ const isValidSentryTraceHeader = TRACEPARENT_REGEXP.test(sentryTrace);
7687
+ if (!isValidSentryTraceHeader) {
7688
+ logger.warn('Invalid sentry-trace data. Cannot generate trace data');
7689
+ return {};
7690
+ }
7691
+
7692
+ const validBaggage = isValidBaggageString(baggage);
7693
+ if (!validBaggage) {
7694
+ logger.warn('Invalid baggage data. Not returning "baggage" value');
7695
+ }
7696
+
7697
+ return {
7698
+ 'sentry-trace': sentryTrace,
7699
+ ...(validBaggage && { baggage }),
7700
+ };
7701
+ }
7702
+
7703
+ /**
7704
+ * Tests string against baggage spec as defined in:
7705
+ *
7706
+ * - W3C Baggage grammar: https://www.w3.org/TR/baggage/#definition
7707
+ * - RFC7230 token definition: https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6
7708
+ *
7709
+ * exported for testing
7710
+ */
7711
+ function isValidBaggageString(baggage) {
7712
+ if (!baggage || !baggage.length) {
7713
+ return false;
7714
+ }
7715
+ const keyRegex = "[-!#$%&'*+.^_`|~A-Za-z0-9]+";
7716
+ const valueRegex = '[!#-+-./0-9:<=>?@A-Z\\[\\]a-z{-}]+';
7717
+ const spaces = '\\s*';
7718
+ // eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor -- RegExp for readability, no user input
7719
+ const baggageRegex = new RegExp(
7720
+ `^${keyRegex}${spaces}=${spaces}${valueRegex}(${spaces},${spaces}${keyRegex}${spaces}=${spaces}${valueRegex})*$`,
7721
+ );
7722
+ return baggageRegex.test(baggage);
7723
+ }
7724
+
7615
7725
  /**
7616
7726
  * Checks whether the given input is already an array, and if it isn't, wraps it in one.
7617
7727
  *
@@ -7853,13 +7963,13 @@ function generateGlobalInjectorCode(_ref2) {
7853
7963
  injectBuildInformation = _ref2.injectBuildInformation;
7854
7964
  // The code below is mostly ternary operators because it saves bundle size.
7855
7965
  // The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
7856
- var code = "!function(){var e=\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:{};";
7966
+ var code = "!function(){try{var e=\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:{};";
7857
7967
  code += "e.SENTRY_RELEASE={id:".concat(JSON.stringify(release), "};");
7858
7968
  if (injectBuildInformation) {
7859
7969
  var buildInfo = getBuildInformation();
7860
7970
  code += "e.SENTRY_BUILD_INFO=".concat(JSON.stringify(buildInfo), ";");
7861
7971
  }
7862
- code += "}();";
7972
+ code += "}catch(e){}}();";
7863
7973
  return code;
7864
7974
  }
7865
7975
 
@@ -7868,7 +7978,8 @@ function generateModuleMetadataInjectorCode(metadata) {
7868
7978
  // The code below is mostly ternary operators because it saves bundle size.
7869
7979
  // The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
7870
7980
  // We are merging the metadata objects in case modules are bundled twice with the plugin
7871
- return "!function(){var e=\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])}return e}({},e._sentryModuleMetadata[(new e.Error).stack],".concat(JSON.stringify(metadata), ")}();");
7981
+ // Use try-catch to avoid issues when bundlers rename global variables like 'window' to 'k'
7982
+ return "!function(){try{var e=\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])}return e}({},e._sentryModuleMetadata[(new e.Error).stack],".concat(JSON.stringify(metadata), ")}catch(e){}}();");
7872
7983
  }
7873
7984
  function getBuildInformation() {
7874
7985
  var packageJson = getPackageJson();
@@ -8196,7 +8307,7 @@ function createSentryInstance(options, shouldSendTelemetry, buildTool) {
8196
8307
  dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
8197
8308
  tracesSampleRate: 1,
8198
8309
  sampleRate: 1,
8199
- release: "4.0.2",
8310
+ release: "4.1.1",
8200
8311
  integrations: [],
8201
8312
  tracePropagationTargets: ["sentry.io/api"],
8202
8313
  stackParser: stackParser,
@@ -8633,6 +8744,18 @@ function defaultRewriteSourcesHook(source) {
8633
8744
  }
8634
8745
  }
8635
8746
 
8747
+ function createCliInstance(options) {
8748
+ return new SentryCli__default["default"](null, {
8749
+ authToken: options.authToken,
8750
+ org: options.org,
8751
+ project: options.project,
8752
+ silent: options.silent,
8753
+ url: options.url,
8754
+ vcsRemote: options.release.vcsRemote,
8755
+ headers: _objectSpread2({}, getTraceData())
8756
+ });
8757
+ }
8758
+
8636
8759
  /**
8637
8760
  * Creates a build plugin manager that exposes primitives for everything that a Sentry JavaScript SDK or build tooling may do during a build.
8638
8761
  *
@@ -8737,7 +8860,22 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8737
8860
  return function () {
8738
8861
  /* noop */
8739
8862
  };
8740
- }
8863
+ },
8864
+ injectDebugIds: function () {
8865
+ var _injectDebugIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
8866
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
8867
+ while (1) switch (_context5.prev = _context5.next) {
8868
+ case 0:
8869
+ case "end":
8870
+ return _context5.stop();
8871
+ }
8872
+ }, _callee5);
8873
+ }));
8874
+ function injectDebugIds() {
8875
+ return _injectDebugIds.apply(this, arguments);
8876
+ }
8877
+ return injectDebugIds;
8878
+ }()
8741
8879
  };
8742
8880
  }
8743
8881
  var shouldSendTelemetry = allowedToSendTelemetry(options);
@@ -8772,7 +8910,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8772
8910
  });
8773
8911
 
8774
8912
  // Set the User-Agent that Sentry CLI will use when interacting with Sentry
8775
- process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.0.2");
8913
+ process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.1.1");
8776
8914
 
8777
8915
  // Not a bulletproof check but should be good enough to at least sometimes determine
8778
8916
  // if the plugin is called in dev/watch mode or for a prod build. The important part
@@ -8933,15 +9071,15 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8933
9071
  * Emits a `Sentry Bundler Plugin execution` signal.
8934
9072
  */
8935
9073
  emitBundlerPluginExecutionSignal: function emitBundlerPluginExecutionSignal() {
8936
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
8937
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
8938
- while (1) switch (_context5.prev = _context5.next) {
9074
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
9075
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
9076
+ while (1) switch (_context6.prev = _context6.next) {
8939
9077
  case 0:
8940
- _context5.next = 2;
9078
+ _context6.next = 2;
8941
9079
  return shouldSendTelemetry;
8942
9080
  case 2:
8943
- if (!_context5.sent) {
8944
- _context5.next = 7;
9081
+ if (!_context6.sent) {
9082
+ _context6.next = 7;
8945
9083
  break;
8946
9084
  }
8947
9085
  logger.info("Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`.");
@@ -8951,13 +9089,13 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8951
9089
  }, function () {
8952
9090
  //
8953
9091
  });
8954
- _context5.next = 7;
9092
+ _context6.next = 7;
8955
9093
  return safeFlushTelemetry(sentryClient);
8956
9094
  case 7:
8957
9095
  case "end":
8958
- return _context5.stop();
9096
+ return _context6.stop();
8959
9097
  }
8960
- }, _callee5);
9098
+ }, _callee6);
8961
9099
  }))();
8962
9100
  }
8963
9101
  },
@@ -8971,68 +9109,60 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8971
9109
  * - adds deploy information
8972
9110
  */
8973
9111
  createRelease: function createRelease() {
8974
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
9112
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
8975
9113
  var freeWriteBundleInvocationDependencyOnSourcemapFiles, cliInstance, normalizedInclude;
8976
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
8977
- while (1) switch (_context6.prev = _context6.next) {
9114
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
9115
+ while (1) switch (_context7.prev = _context7.next) {
8978
9116
  case 0:
8979
9117
  if (options.release.name) {
8980
- _context6.next = 5;
9118
+ _context7.next = 5;
8981
9119
  break;
8982
9120
  }
8983
9121
  logger.debug("No release name provided. Will not create release. Please set the `release.name` option to identify your release.");
8984
- return _context6.abrupt("return");
9122
+ return _context7.abrupt("return");
8985
9123
  case 5:
8986
9124
  if (!isDevMode) {
8987
- _context6.next = 10;
9125
+ _context7.next = 10;
8988
9126
  break;
8989
9127
  }
8990
9128
  logger.debug("Running in development mode. Will not create release.");
8991
- return _context6.abrupt("return");
9129
+ return _context7.abrupt("return");
8992
9130
  case 10:
8993
9131
  if (options.authToken) {
8994
- _context6.next = 15;
9132
+ _context7.next = 15;
8995
9133
  break;
8996
9134
  }
8997
9135
  logger.warn("No auth token provided. Will not create release. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/" + getTurborepoEnvPassthroughWarning("SENTRY_AUTH_TOKEN"));
8998
- return _context6.abrupt("return");
9136
+ return _context7.abrupt("return");
8999
9137
  case 15:
9000
9138
  if (!(!options.org && !options.authToken.startsWith("sntrys_"))) {
9001
- _context6.next = 20;
9139
+ _context7.next = 20;
9002
9140
  break;
9003
9141
  }
9004
9142
  logger.warn("No organization slug provided. Will not create release. Please set the `org` option to your Sentry organization slug." + getTurborepoEnvPassthroughWarning("SENTRY_ORG"));
9005
- return _context6.abrupt("return");
9143
+ return _context7.abrupt("return");
9006
9144
  case 20:
9007
9145
  if (options.project) {
9008
- _context6.next = 23;
9146
+ _context7.next = 23;
9009
9147
  break;
9010
9148
  }
9011
9149
  logger.warn("No project provided. Will not create release. Please set the `project` option to your Sentry project slug." + getTurborepoEnvPassthroughWarning("SENTRY_PROJECT"));
9012
- return _context6.abrupt("return");
9150
+ return _context7.abrupt("return");
9013
9151
  case 23:
9014
9152
  // It is possible that this writeBundle hook is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)
9015
9153
  // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.
9016
9154
  freeWriteBundleInvocationDependencyOnSourcemapFiles = createDependencyOnBuildArtifacts();
9017
- _context6.prev = 24;
9018
- cliInstance = new SentryCli__default["default"](null, {
9019
- authToken: options.authToken,
9020
- org: options.org,
9021
- project: options.project,
9022
- silent: options.silent,
9023
- url: options.url,
9024
- vcsRemote: options.release.vcsRemote,
9025
- headers: options.headers
9026
- });
9155
+ _context7.prev = 24;
9156
+ cliInstance = createCliInstance(options);
9027
9157
  if (!options.release.create) {
9028
- _context6.next = 29;
9158
+ _context7.next = 29;
9029
9159
  break;
9030
9160
  }
9031
- _context6.next = 29;
9161
+ _context7.next = 29;
9032
9162
  return cliInstance.releases["new"](options.release.name);
9033
9163
  case 29:
9034
9164
  if (!options.release.uploadLegacySourcemaps) {
9035
- _context6.next = 33;
9165
+ _context7.next = 33;
9036
9166
  break;
9037
9167
  }
9038
9168
  normalizedInclude = arrayify(options.release.uploadLegacySourcemaps).map(function (includeItem) {
@@ -9049,7 +9179,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9049
9179
  ignore: includeEntry.ignore ? arrayify(includeEntry.ignore) : undefined
9050
9180
  });
9051
9181
  });
9052
- _context6.next = 33;
9182
+ _context7.next = 33;
9053
9183
  return cliInstance.releases.uploadSourceMaps(options.release.name, {
9054
9184
  include: normalizedInclude,
9055
9185
  dist: options.release.dist,
@@ -9059,124 +9189,176 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9059
9189
  });
9060
9190
  case 33:
9061
9191
  if (!(options.release.setCommits !== false)) {
9062
- _context6.next = 46;
9192
+ _context7.next = 46;
9063
9193
  break;
9064
9194
  }
9065
- _context6.prev = 34;
9066
- _context6.next = 37;
9195
+ _context7.prev = 34;
9196
+ _context7.next = 37;
9067
9197
  return cliInstance.releases.setCommits(options.release.name,
9068
9198
  // set commits always exists due to the normalize function
9069
9199
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
9070
9200
  options.release.setCommits);
9071
9201
  case 37:
9072
- _context6.next = 46;
9202
+ _context7.next = 46;
9073
9203
  break;
9074
9204
  case 39:
9075
- _context6.prev = 39;
9076
- _context6.t0 = _context6["catch"](34);
9205
+ _context7.prev = 39;
9206
+ _context7.t0 = _context7["catch"](34);
9077
9207
  if (!(options.release.setCommits && "shouldNotThrowOnFailure" in options.release.setCommits && options.release.setCommits.shouldNotThrowOnFailure)) {
9078
- _context6.next = 45;
9208
+ _context7.next = 45;
9079
9209
  break;
9080
9210
  }
9081
- logger.debug("An error occurred setting commits on release (this message can be ignored unless you commits on release are desired):", _context6.t0);
9082
- _context6.next = 46;
9211
+ logger.debug("An error occurred setting commits on release (this message can be ignored unless you commits on release are desired):", _context7.t0);
9212
+ _context7.next = 46;
9083
9213
  break;
9084
9214
  case 45:
9085
- throw _context6.t0;
9215
+ throw _context7.t0;
9086
9216
  case 46:
9087
9217
  if (!options.release.finalize) {
9088
- _context6.next = 49;
9218
+ _context7.next = 49;
9089
9219
  break;
9090
9220
  }
9091
- _context6.next = 49;
9221
+ _context7.next = 49;
9092
9222
  return cliInstance.releases.finalize(options.release.name);
9093
9223
  case 49:
9094
9224
  if (!options.release.deploy) {
9095
- _context6.next = 52;
9225
+ _context7.next = 52;
9096
9226
  break;
9097
9227
  }
9098
- _context6.next = 52;
9228
+ _context7.next = 52;
9099
9229
  return cliInstance.releases.newDeploy(options.release.name, options.release.deploy);
9100
9230
  case 52:
9101
- _context6.next = 60;
9231
+ _context7.next = 60;
9102
9232
  break;
9103
9233
  case 54:
9104
- _context6.prev = 54;
9105
- _context6.t1 = _context6["catch"](24);
9234
+ _context7.prev = 54;
9235
+ _context7.t1 = _context7["catch"](24);
9106
9236
  sentryScope.captureException('Error in "releaseManagementPlugin" writeBundle hook');
9107
- _context6.next = 59;
9237
+ _context7.next = 59;
9108
9238
  return safeFlushTelemetry(sentryClient);
9109
9239
  case 59:
9110
- handleRecoverableError(_context6.t1, false);
9240
+ handleRecoverableError(_context7.t1, false);
9111
9241
  case 60:
9112
- _context6.prev = 60;
9242
+ _context7.prev = 60;
9113
9243
  freeWriteBundleInvocationDependencyOnSourcemapFiles();
9114
- return _context6.finish(60);
9244
+ return _context7.finish(60);
9115
9245
  case 63:
9116
9246
  case "end":
9117
- return _context6.stop();
9247
+ return _context7.stop();
9118
9248
  }
9119
- }, _callee6, null, [[24, 54, 60, 63], [34, 39]]);
9249
+ }, _callee7, null, [[24, 54, 60, 63], [34, 39]]);
9250
+ }))();
9251
+ },
9252
+ /*
9253
+ Injects debug IDs into the build artifacts.
9254
+ This is a separate function from `uploadSourcemaps` because that needs to run before the sourcemaps are uploaded.
9255
+ Usually the respective bundler-plugin will take care of this before the sourcemaps are uploaded.
9256
+ Only use this if you need to manually inject debug IDs into the build artifacts.
9257
+ */
9258
+ injectDebugIds: function injectDebugIds(buildArtifactPaths) {
9259
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
9260
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
9261
+ while (1) switch (_context9.prev = _context9.next) {
9262
+ case 0:
9263
+ _context9.next = 2;
9264
+ return startSpan({
9265
+ name: "inject-debug-ids",
9266
+ scope: sentryScope,
9267
+ forceTransaction: true
9268
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
9269
+ var _options$debug, cliInstance;
9270
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
9271
+ while (1) switch (_context8.prev = _context8.next) {
9272
+ case 0:
9273
+ _context8.prev = 0;
9274
+ cliInstance = createCliInstance(options);
9275
+ _context8.next = 4;
9276
+ return cliInstance.execute(["sourcemaps", "inject"].concat(_toConsumableArray(buildArtifactPaths)), (_options$debug = options.debug) !== null && _options$debug !== void 0 ? _options$debug : false);
9277
+ case 4:
9278
+ _context8.next = 10;
9279
+ break;
9280
+ case 6:
9281
+ _context8.prev = 6;
9282
+ _context8.t0 = _context8["catch"](0);
9283
+ sentryScope.captureException('Error in "debugIdInjectionPlugin" writeBundle hook');
9284
+ handleRecoverableError(_context8.t0, false);
9285
+ case 10:
9286
+ _context8.prev = 10;
9287
+ _context8.next = 13;
9288
+ return safeFlushTelemetry(sentryClient);
9289
+ case 13:
9290
+ return _context8.finish(10);
9291
+ case 14:
9292
+ case "end":
9293
+ return _context8.stop();
9294
+ }
9295
+ }, _callee8, null, [[0, 6, 10, 14]]);
9296
+ })));
9297
+ case 2:
9298
+ case "end":
9299
+ return _context9.stop();
9300
+ }
9301
+ }, _callee9);
9120
9302
  }))();
9121
9303
  },
9122
9304
  /**
9123
9305
  * Uploads sourcemaps using the "Debug ID" method. This function takes a list of build artifact paths that will be uploaded
9124
9306
  */
9125
9307
  uploadSourcemaps: function uploadSourcemaps(buildArtifactPaths) {
9126
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
9127
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
9128
- while (1) switch (_context15.prev = _context15.next) {
9308
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
9309
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
9310
+ while (1) switch (_context18.prev = _context18.next) {
9129
9311
  case 0:
9130
9312
  if (canUploadSourceMaps(options, logger, isDevMode)) {
9131
- _context15.next = 2;
9313
+ _context18.next = 2;
9132
9314
  break;
9133
9315
  }
9134
- return _context15.abrupt("return");
9316
+ return _context18.abrupt("return");
9135
9317
  case 2:
9136
- _context15.next = 4;
9318
+ _context18.next = 4;
9137
9319
  return startSpan(
9138
9320
  // This is `forceTransaction`ed because this span is used in dashboards in the form of indexed transactions.
9139
9321
  {
9140
9322
  name: "debug-id-sourcemap-upload",
9141
9323
  scope: sentryScope,
9142
9324
  forceTransaction: true
9143
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
9325
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
9144
9326
  var folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps, tmpUploadFolder, assets, globAssets, globResult, debugIdChunkFilePaths, numUploadedFiles, _process$env2;
9145
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
9146
- while (1) switch (_context14.prev = _context14.next) {
9327
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
9328
+ while (1) switch (_context17.prev = _context17.next) {
9147
9329
  case 0:
9148
9330
  // It is possible that this writeBundle hook (which calls this function) is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)
9149
9331
  // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.
9150
9332
  freeUploadDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
9151
- _context14.prev = 1;
9152
- _context14.next = 4;
9333
+ _context17.prev = 1;
9334
+ _context17.next = 4;
9153
9335
  return startSpan({
9154
9336
  name: "mkdtemp",
9155
9337
  scope: sentryScope
9156
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
9338
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
9157
9339
  var _process$env;
9158
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
9159
- while (1) switch (_context7.prev = _context7.next) {
9340
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
9341
+ while (1) switch (_context10.prev = _context10.next) {
9160
9342
  case 0:
9161
- _context7.t0 = (_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env["SENTRY_TEST_OVERRIDE_TEMP_DIR"];
9162
- if (_context7.t0) {
9163
- _context7.next = 5;
9343
+ _context10.t0 = (_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env["SENTRY_TEST_OVERRIDE_TEMP_DIR"];
9344
+ if (_context10.t0) {
9345
+ _context10.next = 5;
9164
9346
  break;
9165
9347
  }
9166
- _context7.next = 4;
9348
+ _context10.next = 4;
9167
9349
  return fs__namespace.promises.mkdtemp(path__namespace.join(os__namespace.tmpdir(), "sentry-bundler-plugin-upload-"));
9168
9350
  case 4:
9169
- _context7.t0 = _context7.sent;
9351
+ _context10.t0 = _context10.sent;
9170
9352
  case 5:
9171
- return _context7.abrupt("return", _context7.t0);
9353
+ return _context10.abrupt("return", _context10.t0);
9172
9354
  case 6:
9173
9355
  case "end":
9174
- return _context7.stop();
9356
+ return _context10.stop();
9175
9357
  }
9176
- }, _callee7);
9358
+ }, _callee10);
9177
9359
  })));
9178
9360
  case 4:
9179
- tmpUploadFolder = _context14.sent;
9361
+ tmpUploadFolder = _context17.sent;
9180
9362
  folderToCleanUp = tmpUploadFolder;
9181
9363
  assets = (_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.assets;
9182
9364
  if (assets) {
@@ -9185,281 +9367,264 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9185
9367
  logger.debug("No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.");
9186
9368
  globAssets = buildArtifactPaths;
9187
9369
  }
9188
- _context14.next = 10;
9370
+ _context17.next = 10;
9189
9371
  return startSpan({
9190
9372
  name: "glob",
9191
9373
  scope: sentryScope
9192
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
9374
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
9193
9375
  var _options$sourcemaps2;
9194
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
9195
- while (1) switch (_context8.prev = _context8.next) {
9376
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
9377
+ while (1) switch (_context11.prev = _context11.next) {
9196
9378
  case 0:
9197
- _context8.next = 2;
9379
+ _context11.next = 2;
9198
9380
  return glob.glob(globAssets, {
9199
9381
  absolute: true,
9200
9382
  nodir: true,
9201
9383
  ignore: (_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.ignore
9202
9384
  });
9203
9385
  case 2:
9204
- return _context8.abrupt("return", _context8.sent);
9386
+ return _context11.abrupt("return", _context11.sent);
9205
9387
  case 3:
9206
9388
  case "end":
9207
- return _context8.stop();
9389
+ return _context11.stop();
9208
9390
  }
9209
- }, _callee8);
9391
+ }, _callee11);
9210
9392
  })));
9211
9393
  case 10:
9212
- globResult = _context14.sent;
9394
+ globResult = _context17.sent;
9213
9395
  debugIdChunkFilePaths = globResult.filter(function (debugIdChunkFilePath) {
9214
9396
  return !!stripQueryAndHashFromPath(debugIdChunkFilePath).match(/\.(js|mjs|cjs)$/);
9215
9397
  }); // The order of the files output by glob() is not deterministic
9216
9398
  // Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent
9217
9399
  debugIdChunkFilePaths.sort();
9218
9400
  if (!(Array.isArray(assets) && assets.length === 0)) {
9219
- _context14.next = 17;
9401
+ _context17.next = 17;
9220
9402
  break;
9221
9403
  }
9222
9404
  logger.debug("Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.");
9223
- _context14.next = 25;
9405
+ _context17.next = 25;
9224
9406
  break;
9225
9407
  case 17:
9226
9408
  if (!(debugIdChunkFilePaths.length === 0)) {
9227
- _context14.next = 21;
9409
+ _context17.next = 21;
9228
9410
  break;
9229
9411
  }
9230
9412
  logger.warn("Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.");
9231
- _context14.next = 25;
9413
+ _context17.next = 25;
9232
9414
  break;
9233
9415
  case 21:
9234
- _context14.next = 23;
9416
+ _context17.next = 23;
9235
9417
  return startSpan({
9236
9418
  name: "prepare-bundles",
9237
9419
  scope: sentryScope
9238
9420
  }, /*#__PURE__*/function () {
9239
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(prepBundlesSpan) {
9421
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(prepBundlesSpan) {
9240
9422
  var preparationTasks, workers, worker, workerIndex, files, stats, uploadSize;
9241
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
9242
- while (1) switch (_context12.prev = _context12.next) {
9423
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
9424
+ while (1) switch (_context15.prev = _context15.next) {
9243
9425
  case 0:
9244
9426
  // Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so
9245
9427
  // instead we do it with a maximum of 16 concurrent workers
9246
9428
  preparationTasks = debugIdChunkFilePaths.map(function (chunkFilePath, chunkIndex) {
9247
- return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
9429
+ return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
9248
9430
  var _options$sourcemaps$r, _options$sourcemaps3, _options$sourcemaps4;
9249
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
9250
- while (1) switch (_context9.prev = _context9.next) {
9431
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
9432
+ while (1) switch (_context12.prev = _context12.next) {
9251
9433
  case 0:
9252
- _context9.next = 2;
9434
+ _context12.next = 2;
9253
9435
  return prepareBundleForDebugIdUpload(chunkFilePath, tmpUploadFolder, chunkIndex, logger, (_options$sourcemaps$r = (_options$sourcemaps3 = options.sourcemaps) === null || _options$sourcemaps3 === void 0 ? void 0 : _options$sourcemaps3.rewriteSources) !== null && _options$sourcemaps$r !== void 0 ? _options$sourcemaps$r : defaultRewriteSourcesHook, (_options$sourcemaps4 = options.sourcemaps) === null || _options$sourcemaps4 === void 0 ? void 0 : _options$sourcemaps4.resolveSourceMap);
9254
9436
  case 2:
9255
9437
  case "end":
9256
- return _context9.stop();
9438
+ return _context12.stop();
9257
9439
  }
9258
- }, _callee9);
9440
+ }, _callee12);
9259
9441
  }));
9260
9442
  });
9261
9443
  workers = [];
9262
9444
  worker = /*#__PURE__*/function () {
9263
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
9445
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
9264
9446
  var task;
9265
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
9266
- while (1) switch (_context10.prev = _context10.next) {
9447
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
9448
+ while (1) switch (_context13.prev = _context13.next) {
9267
9449
  case 0:
9268
9450
  if (!(preparationTasks.length > 0)) {
9269
- _context10.next = 7;
9451
+ _context13.next = 7;
9270
9452
  break;
9271
9453
  }
9272
9454
  task = preparationTasks.shift();
9273
9455
  if (!task) {
9274
- _context10.next = 5;
9456
+ _context13.next = 5;
9275
9457
  break;
9276
9458
  }
9277
- _context10.next = 5;
9459
+ _context13.next = 5;
9278
9460
  return task();
9279
9461
  case 5:
9280
- _context10.next = 0;
9462
+ _context13.next = 0;
9281
9463
  break;
9282
9464
  case 7:
9283
9465
  case "end":
9284
- return _context10.stop();
9466
+ return _context13.stop();
9285
9467
  }
9286
- }, _callee10);
9468
+ }, _callee13);
9287
9469
  }));
9288
9470
  return function worker() {
9289
- return _ref6.apply(this, arguments);
9471
+ return _ref7.apply(this, arguments);
9290
9472
  };
9291
9473
  }();
9292
9474
  for (workerIndex = 0; workerIndex < 16; workerIndex++) {
9293
9475
  workers.push(worker());
9294
9476
  }
9295
- _context12.next = 6;
9477
+ _context15.next = 6;
9296
9478
  return Promise.all(workers);
9297
9479
  case 6:
9298
- _context12.next = 8;
9480
+ _context15.next = 8;
9299
9481
  return fs__namespace.promises.readdir(tmpUploadFolder);
9300
9482
  case 8:
9301
- files = _context12.sent;
9483
+ files = _context15.sent;
9302
9484
  stats = files.map(function (file) {
9303
9485
  return fs__namespace.promises.stat(path__namespace.join(tmpUploadFolder, file));
9304
9486
  });
9305
- _context12.next = 12;
9487
+ _context15.next = 12;
9306
9488
  return Promise.all(stats);
9307
9489
  case 12:
9308
- uploadSize = _context12.sent.reduce(function (accumulator, _ref7) {
9309
- var size = _ref7.size;
9490
+ uploadSize = _context15.sent.reduce(function (accumulator, _ref8) {
9491
+ var size = _ref8.size;
9310
9492
  return accumulator + size;
9311
9493
  }, 0);
9312
9494
  setMeasurement("files", files.length, "none", prepBundlesSpan);
9313
9495
  setMeasurement("upload_size", uploadSize, "byte", prepBundlesSpan);
9314
- _context12.next = 17;
9496
+ _context15.next = 17;
9315
9497
  return startSpan({
9316
9498
  name: "upload",
9317
9499
  scope: sentryScope
9318
- }, /*#__PURE__*/function () {
9319
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(uploadSpan) {
9320
- var _options$release$name;
9321
- var cliInstance;
9322
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
9323
- while (1) switch (_context11.prev = _context11.next) {
9324
- case 0:
9325
- cliInstance = new SentryCli__default["default"](null, {
9326
- authToken: options.authToken,
9327
- org: options.org,
9328
- project: options.project,
9329
- silent: options.silent,
9330
- url: options.url,
9331
- vcsRemote: options.release.vcsRemote,
9332
- headers: _objectSpread2({
9333
- "sentry-trace": spanToTraceHeader(uploadSpan),
9334
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
9335
- baggage: dynamicSamplingContextToSentryBaggageHeader(getDynamicSamplingContextFromSpan(uploadSpan))
9336
- }, options.headers)
9337
- });
9338
- _context11.next = 3;
9339
- return cliInstance.releases.uploadSourceMaps((_options$release$name = options.release.name) !== null && _options$release$name !== void 0 ? _options$release$name : "undefined",
9340
- // unfortunately this needs a value for now but it will not matter since debug IDs overpower releases anyhow
9341
- {
9342
- include: [{
9343
- paths: [tmpUploadFolder],
9344
- rewrite: false,
9345
- dist: options.release.dist
9346
- }],
9347
- // We want this promise to throw if the sourcemaps fail to upload so that we know about it.
9348
- // see: https://github.com/getsentry/sentry-cli/pull/2605
9349
- live: "rejectOnError"
9350
- });
9351
- case 3:
9352
- case "end":
9353
- return _context11.stop();
9354
- }
9355
- }, _callee11);
9356
- }));
9357
- return function (_x2) {
9358
- return _ref8.apply(this, arguments);
9359
- };
9360
- }());
9500
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
9501
+ var _options$release$name;
9502
+ var cliInstance;
9503
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
9504
+ while (1) switch (_context14.prev = _context14.next) {
9505
+ case 0:
9506
+ cliInstance = createCliInstance(options);
9507
+ _context14.next = 3;
9508
+ return cliInstance.releases.uploadSourceMaps((_options$release$name = options.release.name) !== null && _options$release$name !== void 0 ? _options$release$name : "undefined",
9509
+ // unfortunately this needs a value for now but it will not matter since debug IDs overpower releases anyhow
9510
+ {
9511
+ include: [{
9512
+ paths: [tmpUploadFolder],
9513
+ rewrite: false,
9514
+ dist: options.release.dist
9515
+ }],
9516
+ // We want this promise to throw if the sourcemaps fail to upload so that we know about it.
9517
+ // see: https://github.com/getsentry/sentry-cli/pull/2605
9518
+ live: "rejectOnError"
9519
+ });
9520
+ case 3:
9521
+ case "end":
9522
+ return _context14.stop();
9523
+ }
9524
+ }, _callee14);
9525
+ })));
9361
9526
  case 17:
9362
- return _context12.abrupt("return", files.length);
9527
+ return _context15.abrupt("return", files.length);
9363
9528
  case 18:
9364
9529
  case "end":
9365
- return _context12.stop();
9530
+ return _context15.stop();
9366
9531
  }
9367
- }, _callee12);
9532
+ }, _callee15);
9368
9533
  }));
9369
9534
  return function (_x) {
9370
- return _ref4.apply(this, arguments);
9535
+ return _ref5.apply(this, arguments);
9371
9536
  };
9372
9537
  }());
9373
9538
  case 23:
9374
- numUploadedFiles = _context14.sent;
9539
+ numUploadedFiles = _context17.sent;
9375
9540
  if (numUploadedFiles > 0) {
9376
9541
  logger.info("Successfully uploaded source maps to Sentry");
9377
9542
  }
9378
9543
  case 25:
9379
- _context14.next = 31;
9544
+ _context17.next = 31;
9380
9545
  break;
9381
9546
  case 27:
9382
- _context14.prev = 27;
9383
- _context14.t0 = _context14["catch"](1);
9547
+ _context17.prev = 27;
9548
+ _context17.t0 = _context17["catch"](1);
9384
9549
  sentryScope.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
9385
- handleRecoverableError(_context14.t0, false);
9550
+ handleRecoverableError(_context17.t0, false);
9386
9551
  case 31:
9387
- _context14.prev = 31;
9552
+ _context17.prev = 31;
9388
9553
  if (folderToCleanUp && !((_process$env2 = process.env) !== null && _process$env2 !== void 0 && _process$env2["SENTRY_TEST_OVERRIDE_TEMP_DIR"])) {
9389
9554
  void startSpan({
9390
9555
  name: "cleanup",
9391
9556
  scope: sentryScope
9392
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
9393
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
9394
- while (1) switch (_context13.prev = _context13.next) {
9557
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
9558
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
9559
+ while (1) switch (_context16.prev = _context16.next) {
9395
9560
  case 0:
9396
9561
  if (!folderToCleanUp) {
9397
- _context13.next = 3;
9562
+ _context16.next = 3;
9398
9563
  break;
9399
9564
  }
9400
- _context13.next = 3;
9565
+ _context16.next = 3;
9401
9566
  return fs__namespace.promises.rm(folderToCleanUp, {
9402
9567
  recursive: true,
9403
9568
  force: true
9404
9569
  });
9405
9570
  case 3:
9406
9571
  case "end":
9407
- return _context13.stop();
9572
+ return _context16.stop();
9408
9573
  }
9409
- }, _callee13);
9574
+ }, _callee16);
9410
9575
  })));
9411
9576
  }
9412
9577
  freeUploadDependencyOnBuildArtifacts();
9413
- _context14.next = 36;
9578
+ _context17.next = 36;
9414
9579
  return safeFlushTelemetry(sentryClient);
9415
9580
  case 36:
9416
- return _context14.finish(31);
9581
+ return _context17.finish(31);
9417
9582
  case 37:
9418
9583
  case "end":
9419
- return _context14.stop();
9584
+ return _context17.stop();
9420
9585
  }
9421
- }, _callee14, null, [[1, 27, 31, 37]]);
9586
+ }, _callee17, null, [[1, 27, 31, 37]]);
9422
9587
  })));
9423
9588
  case 4:
9424
9589
  case "end":
9425
- return _context15.stop();
9590
+ return _context18.stop();
9426
9591
  }
9427
- }, _callee15);
9592
+ }, _callee18);
9428
9593
  }))();
9429
9594
  },
9430
9595
  /**
9431
9596
  * Will delete artifacts based on the passed `sourcemaps.filesToDeleteAfterUpload` option.
9432
9597
  */
9433
9598
  deleteArtifacts: function deleteArtifacts() {
9434
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
9599
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
9435
9600
  var _options$sourcemaps5, filesToDelete, filePathsToDelete;
9436
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
9437
- while (1) switch (_context16.prev = _context16.next) {
9601
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
9602
+ while (1) switch (_context19.prev = _context19.next) {
9438
9603
  case 0:
9439
- _context16.prev = 0;
9440
- _context16.next = 3;
9604
+ _context19.prev = 0;
9605
+ _context19.next = 3;
9441
9606
  return (_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.filesToDeleteAfterUpload;
9442
9607
  case 3:
9443
- filesToDelete = _context16.sent;
9608
+ filesToDelete = _context19.sent;
9444
9609
  if (!(filesToDelete !== undefined)) {
9445
- _context16.next = 14;
9610
+ _context19.next = 14;
9446
9611
  break;
9447
9612
  }
9448
- _context16.next = 7;
9613
+ _context19.next = 7;
9449
9614
  return glob.glob(filesToDelete, {
9450
9615
  absolute: true,
9451
9616
  nodir: true
9452
9617
  });
9453
9618
  case 7:
9454
- filePathsToDelete = _context16.sent;
9619
+ filePathsToDelete = _context19.sent;
9455
9620
  logger.debug("Waiting for dependencies on generated files to be freed before deleting...");
9456
- _context16.next = 11;
9621
+ _context19.next = 11;
9457
9622
  return waitUntilBuildArtifactDependenciesAreFreed();
9458
9623
  case 11:
9459
9624
  filePathsToDelete.forEach(function (filePathToDelete) {
9460
9625
  logger.debug("Deleting asset after upload: ".concat(filePathToDelete));
9461
9626
  });
9462
- _context16.next = 14;
9627
+ _context19.next = 14;
9463
9628
  return Promise.all(filePathsToDelete.map(function (filePathToDelete) {
9464
9629
  return fs__namespace.promises.rm(filePathToDelete, {
9465
9630
  force: true
@@ -9469,23 +9634,23 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9469
9634
  });
9470
9635
  }));
9471
9636
  case 14:
9472
- _context16.next = 22;
9637
+ _context19.next = 22;
9473
9638
  break;
9474
9639
  case 16:
9475
- _context16.prev = 16;
9476
- _context16.t0 = _context16["catch"](0);
9640
+ _context19.prev = 16;
9641
+ _context19.t0 = _context19["catch"](0);
9477
9642
  sentryScope.captureException('Error in "sentry-file-deletion-plugin" buildEnd hook');
9478
- _context16.next = 21;
9643
+ _context19.next = 21;
9479
9644
  return safeFlushTelemetry(sentryClient);
9480
9645
  case 21:
9481
9646
  // We throw by default if we get here b/c not being able to delete
9482
9647
  // source maps could leak them to production
9483
- handleRecoverableError(_context16.t0, true);
9648
+ handleRecoverableError(_context19.t0, true);
9484
9649
  case 22:
9485
9650
  case "end":
9486
- return _context16.stop();
9651
+ return _context19.stop();
9487
9652
  }
9488
- }, _callee16, null, [[0, 16]]);
9653
+ }, _callee19, null, [[0, 16]]);
9489
9654
  }))();
9490
9655
  },
9491
9656
  createDependencyOnBuildArtifacts: createDependencyOnBuildArtifacts
@@ -9608,14 +9773,16 @@ function sentryUnpluginFactory(_ref) {
9608
9773
  }))();
9609
9774
  }
9610
9775
  });
9611
- if (!((_options$sourcemaps = options.sourcemaps) !== null && _options$sourcemaps !== void 0 && _options$sourcemaps.disable)) {
9776
+ if (((_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.disable) !== true) {
9777
+ var _options$sourcemaps2;
9612
9778
  plugins.push(debugIdInjectionPlugin(logger));
9613
-
9614
- // This option is only strongly typed for the webpack plugin, where it is used. It has no effect on other plugins
9615
- var _webpack_forceExitOnBuildComplete = typeof options._experiments["forceExitOnBuildCompletion"] === "boolean" ? options._experiments["forceExitOnBuildCompletion"] : undefined;
9616
- plugins.push(debugIdUploadPlugin(createDebugIdUploadFunction({
9617
- sentryBuildPluginManager: sentryBuildPluginManager
9618
- }), logger, sentryBuildPluginManager.createDependencyOnBuildArtifacts, _webpack_forceExitOnBuildComplete));
9779
+ if (((_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.disable) !== "disable-upload") {
9780
+ // This option is only strongly typed for the webpack plugin, where it is used. It has no effect on other plugins
9781
+ var _webpack_forceExitOnBuildComplete = typeof options._experiments["forceExitOnBuildCompletion"] === "boolean" ? options._experiments["forceExitOnBuildCompletion"] : undefined;
9782
+ plugins.push(debugIdUploadPlugin(createDebugIdUploadFunction({
9783
+ sentryBuildPluginManager: sentryBuildPluginManager
9784
+ }), logger, sentryBuildPluginManager.createDependencyOnBuildArtifacts, _webpack_forceExitOnBuildComplete));
9785
+ }
9619
9786
  }
9620
9787
  if (options.reactComponentAnnotation) {
9621
9788
  if (!options.reactComponentAnnotation.enabled) {