@sentry/bundler-plugin-core 4.0.2 → 4.1.0

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.
@@ -396,6 +396,31 @@ function _defineProperty(obj, key, value) {
396
396
  }
397
397
  return obj;
398
398
  }
399
+ function _toConsumableArray(arr) {
400
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
401
+ }
402
+ function _arrayWithoutHoles(arr) {
403
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
404
+ }
405
+ function _iterableToArray(iter) {
406
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
407
+ }
408
+ function _unsupportedIterableToArray(o, minLen) {
409
+ if (!o) return;
410
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
411
+ var n = Object.prototype.toString.call(o).slice(8, -1);
412
+ if (n === "Object" && o.constructor) n = o.constructor.name;
413
+ if (n === "Map" || n === "Set") return Array.from(o);
414
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
415
+ }
416
+ function _arrayLikeToArray(arr, len) {
417
+ if (len == null || len > arr.length) len = arr.length;
418
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
419
+ return arr2;
420
+ }
421
+ function _nonIterableSpread() {
422
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
423
+ }
399
424
  function _toPrimitive(input, hint) {
400
425
  if (typeof input !== "object" || input === null) return input;
401
426
  var prim = input[Symbol.toPrimitive];
@@ -2500,6 +2525,15 @@ function objectToBaggageHeader(object) {
2500
2525
  }, '');
2501
2526
  }
2502
2527
 
2528
+ // eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor -- RegExp is used for readability here
2529
+ const TRACEPARENT_REGEXP = new RegExp(
2530
+ '^[ \\t]*' + // whitespace
2531
+ '([0-9a-f]{32})?' + // trace_id
2532
+ '-?([0-9a-f]{16})?' + // span_id
2533
+ '-?([01])?' + // sampled
2534
+ '[ \\t]*$', // whitespace
2535
+ );
2536
+
2503
2537
  /**
2504
2538
  * Create sentry-trace header from span context values.
2505
2539
  */
@@ -7575,6 +7609,82 @@ function applySdkMetadata(options, name, names = [name], source = 'npm') {
7575
7609
  options._metadata = metadata;
7576
7610
  }
7577
7611
 
7612
+ /**
7613
+ * Extracts trace propagation data from the current span or from the client's scope (via transaction or propagation
7614
+ * context) and serializes it to `sentry-trace` and `baggage` values to strings. These values can be used to propagate
7615
+ * a trace via our tracing Http headers or Html `<meta>` tags.
7616
+ *
7617
+ * This function also applies some validation to the generated sentry-trace and baggage values to ensure that
7618
+ * only valid strings are returned.
7619
+ *
7620
+ * @returns an object with the tracing data values. The object keys are the name of the tracing key to be used as header
7621
+ * or meta tag name.
7622
+ */
7623
+ function getTraceData() {
7624
+ const carrier = getMainCarrier();
7625
+ const acs = getAsyncContextStrategy(carrier);
7626
+ if (acs.getTraceData) {
7627
+ return acs.getTraceData();
7628
+ }
7629
+
7630
+ const client = getClient();
7631
+ const scope = getCurrentScope();
7632
+ const span = getActiveSpan();
7633
+
7634
+ const { dsc, sampled, traceId } = scope.getPropagationContext();
7635
+ const rootSpan = span && getRootSpan(span);
7636
+
7637
+ const sentryTrace = span ? spanToTraceHeader(span) : generateSentryTraceHeader(traceId, undefined, sampled);
7638
+
7639
+ const dynamicSamplingContext = rootSpan
7640
+ ? getDynamicSamplingContextFromSpan(rootSpan)
7641
+ : dsc
7642
+ ? dsc
7643
+ : client
7644
+ ? getDynamicSamplingContextFromClient(traceId, client)
7645
+ : undefined;
7646
+
7647
+ const baggage = dynamicSamplingContextToSentryBaggageHeader(dynamicSamplingContext);
7648
+
7649
+ const isValidSentryTraceHeader = TRACEPARENT_REGEXP.test(sentryTrace);
7650
+ if (!isValidSentryTraceHeader) {
7651
+ logger.warn('Invalid sentry-trace data. Cannot generate trace data');
7652
+ return {};
7653
+ }
7654
+
7655
+ const validBaggage = isValidBaggageString(baggage);
7656
+ if (!validBaggage) {
7657
+ logger.warn('Invalid baggage data. Not returning "baggage" value');
7658
+ }
7659
+
7660
+ return {
7661
+ 'sentry-trace': sentryTrace,
7662
+ ...(validBaggage && { baggage }),
7663
+ };
7664
+ }
7665
+
7666
+ /**
7667
+ * Tests string against baggage spec as defined in:
7668
+ *
7669
+ * - W3C Baggage grammar: https://www.w3.org/TR/baggage/#definition
7670
+ * - RFC7230 token definition: https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6
7671
+ *
7672
+ * exported for testing
7673
+ */
7674
+ function isValidBaggageString(baggage) {
7675
+ if (!baggage || !baggage.length) {
7676
+ return false;
7677
+ }
7678
+ const keyRegex = "[-!#$%&'*+.^_`|~A-Za-z0-9]+";
7679
+ const valueRegex = '[!#-+-./0-9:<=>?@A-Z\\[\\]a-z{-}]+';
7680
+ const spaces = '\\s*';
7681
+ // eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor -- RegExp for readability, no user input
7682
+ const baggageRegex = new RegExp(
7683
+ `^${keyRegex}${spaces}=${spaces}${valueRegex}(${spaces},${spaces}${keyRegex}${spaces}=${spaces}${valueRegex})*$`,
7684
+ );
7685
+ return baggageRegex.test(baggage);
7686
+ }
7687
+
7578
7688
  /**
7579
7689
  * Checks whether the given input is already an array, and if it isn't, wraps it in one.
7580
7690
  *
@@ -7816,13 +7926,13 @@ function generateGlobalInjectorCode(_ref2) {
7816
7926
  injectBuildInformation = _ref2.injectBuildInformation;
7817
7927
  // The code below is mostly ternary operators because it saves bundle size.
7818
7928
  // The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
7819
- var code = "!function(){var e=\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:{};";
7929
+ var code = "!function(){try{var e=\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:{};";
7820
7930
  code += "e.SENTRY_RELEASE={id:".concat(JSON.stringify(release), "};");
7821
7931
  if (injectBuildInformation) {
7822
7932
  var buildInfo = getBuildInformation();
7823
7933
  code += "e.SENTRY_BUILD_INFO=".concat(JSON.stringify(buildInfo), ";");
7824
7934
  }
7825
- code += "}();";
7935
+ code += "}catch(e){}}();";
7826
7936
  return code;
7827
7937
  }
7828
7938
 
@@ -7831,7 +7941,8 @@ function generateModuleMetadataInjectorCode(metadata) {
7831
7941
  // The code below is mostly ternary operators because it saves bundle size.
7832
7942
  // The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
7833
7943
  // We are merging the metadata objects in case modules are bundled twice with the plugin
7834
- 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), ")}();");
7944
+ // Use try-catch to avoid issues when bundlers rename global variables like 'window' to 'k'
7945
+ 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){}}();");
7835
7946
  }
7836
7947
  function getBuildInformation() {
7837
7948
  var packageJson = getPackageJson();
@@ -8159,7 +8270,7 @@ function createSentryInstance(options, shouldSendTelemetry, buildTool) {
8159
8270
  dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
8160
8271
  tracesSampleRate: 1,
8161
8272
  sampleRate: 1,
8162
- release: "4.0.2",
8273
+ release: "4.1.0",
8163
8274
  integrations: [],
8164
8275
  tracePropagationTargets: ["sentry.io/api"],
8165
8276
  stackParser: stackParser,
@@ -8596,6 +8707,18 @@ function defaultRewriteSourcesHook(source) {
8596
8707
  }
8597
8708
  }
8598
8709
 
8710
+ function createCliInstance(options) {
8711
+ return new SentryCli(null, {
8712
+ authToken: options.authToken,
8713
+ org: options.org,
8714
+ project: options.project,
8715
+ silent: options.silent,
8716
+ url: options.url,
8717
+ vcsRemote: options.release.vcsRemote,
8718
+ headers: _objectSpread2({}, getTraceData())
8719
+ });
8720
+ }
8721
+
8599
8722
  /**
8600
8723
  * Creates a build plugin manager that exposes primitives for everything that a Sentry JavaScript SDK or build tooling may do during a build.
8601
8724
  *
@@ -8700,7 +8823,22 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8700
8823
  return function () {
8701
8824
  /* noop */
8702
8825
  };
8703
- }
8826
+ },
8827
+ injectDebugIds: function () {
8828
+ var _injectDebugIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
8829
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
8830
+ while (1) switch (_context5.prev = _context5.next) {
8831
+ case 0:
8832
+ case "end":
8833
+ return _context5.stop();
8834
+ }
8835
+ }, _callee5);
8836
+ }));
8837
+ function injectDebugIds() {
8838
+ return _injectDebugIds.apply(this, arguments);
8839
+ }
8840
+ return injectDebugIds;
8841
+ }()
8704
8842
  };
8705
8843
  }
8706
8844
  var shouldSendTelemetry = allowedToSendTelemetry(options);
@@ -8735,7 +8873,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8735
8873
  });
8736
8874
 
8737
8875
  // Set the User-Agent that Sentry CLI will use when interacting with Sentry
8738
- process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.0.2");
8876
+ process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.1.0");
8739
8877
 
8740
8878
  // Not a bulletproof check but should be good enough to at least sometimes determine
8741
8879
  // if the plugin is called in dev/watch mode or for a prod build. The important part
@@ -8896,15 +9034,15 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8896
9034
  * Emits a `Sentry Bundler Plugin execution` signal.
8897
9035
  */
8898
9036
  emitBundlerPluginExecutionSignal: function emitBundlerPluginExecutionSignal() {
8899
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
8900
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
8901
- while (1) switch (_context5.prev = _context5.next) {
9037
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
9038
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
9039
+ while (1) switch (_context6.prev = _context6.next) {
8902
9040
  case 0:
8903
- _context5.next = 2;
9041
+ _context6.next = 2;
8904
9042
  return shouldSendTelemetry;
8905
9043
  case 2:
8906
- if (!_context5.sent) {
8907
- _context5.next = 7;
9044
+ if (!_context6.sent) {
9045
+ _context6.next = 7;
8908
9046
  break;
8909
9047
  }
8910
9048
  logger.info("Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`.");
@@ -8914,13 +9052,13 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8914
9052
  }, function () {
8915
9053
  //
8916
9054
  });
8917
- _context5.next = 7;
9055
+ _context6.next = 7;
8918
9056
  return safeFlushTelemetry(sentryClient);
8919
9057
  case 7:
8920
9058
  case "end":
8921
- return _context5.stop();
9059
+ return _context6.stop();
8922
9060
  }
8923
- }, _callee5);
9061
+ }, _callee6);
8924
9062
  }))();
8925
9063
  }
8926
9064
  },
@@ -8934,68 +9072,60 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8934
9072
  * - adds deploy information
8935
9073
  */
8936
9074
  createRelease: function createRelease() {
8937
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
9075
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
8938
9076
  var freeWriteBundleInvocationDependencyOnSourcemapFiles, cliInstance, normalizedInclude;
8939
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
8940
- while (1) switch (_context6.prev = _context6.next) {
9077
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
9078
+ while (1) switch (_context7.prev = _context7.next) {
8941
9079
  case 0:
8942
9080
  if (options.release.name) {
8943
- _context6.next = 5;
9081
+ _context7.next = 5;
8944
9082
  break;
8945
9083
  }
8946
9084
  logger.debug("No release name provided. Will not create release. Please set the `release.name` option to identify your release.");
8947
- return _context6.abrupt("return");
9085
+ return _context7.abrupt("return");
8948
9086
  case 5:
8949
9087
  if (!isDevMode) {
8950
- _context6.next = 10;
9088
+ _context7.next = 10;
8951
9089
  break;
8952
9090
  }
8953
9091
  logger.debug("Running in development mode. Will not create release.");
8954
- return _context6.abrupt("return");
9092
+ return _context7.abrupt("return");
8955
9093
  case 10:
8956
9094
  if (options.authToken) {
8957
- _context6.next = 15;
9095
+ _context7.next = 15;
8958
9096
  break;
8959
9097
  }
8960
9098
  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"));
8961
- return _context6.abrupt("return");
9099
+ return _context7.abrupt("return");
8962
9100
  case 15:
8963
9101
  if (!(!options.org && !options.authToken.startsWith("sntrys_"))) {
8964
- _context6.next = 20;
9102
+ _context7.next = 20;
8965
9103
  break;
8966
9104
  }
8967
9105
  logger.warn("No organization slug provided. Will not create release. Please set the `org` option to your Sentry organization slug." + getTurborepoEnvPassthroughWarning("SENTRY_ORG"));
8968
- return _context6.abrupt("return");
9106
+ return _context7.abrupt("return");
8969
9107
  case 20:
8970
9108
  if (options.project) {
8971
- _context6.next = 23;
9109
+ _context7.next = 23;
8972
9110
  break;
8973
9111
  }
8974
9112
  logger.warn("No project provided. Will not create release. Please set the `project` option to your Sentry project slug." + getTurborepoEnvPassthroughWarning("SENTRY_PROJECT"));
8975
- return _context6.abrupt("return");
9113
+ return _context7.abrupt("return");
8976
9114
  case 23:
8977
9115
  // 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`)
8978
9116
  // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.
8979
9117
  freeWriteBundleInvocationDependencyOnSourcemapFiles = createDependencyOnBuildArtifacts();
8980
- _context6.prev = 24;
8981
- cliInstance = new SentryCli(null, {
8982
- authToken: options.authToken,
8983
- org: options.org,
8984
- project: options.project,
8985
- silent: options.silent,
8986
- url: options.url,
8987
- vcsRemote: options.release.vcsRemote,
8988
- headers: options.headers
8989
- });
9118
+ _context7.prev = 24;
9119
+ cliInstance = createCliInstance(options);
8990
9120
  if (!options.release.create) {
8991
- _context6.next = 29;
9121
+ _context7.next = 29;
8992
9122
  break;
8993
9123
  }
8994
- _context6.next = 29;
9124
+ _context7.next = 29;
8995
9125
  return cliInstance.releases["new"](options.release.name);
8996
9126
  case 29:
8997
9127
  if (!options.release.uploadLegacySourcemaps) {
8998
- _context6.next = 33;
9128
+ _context7.next = 33;
8999
9129
  break;
9000
9130
  }
9001
9131
  normalizedInclude = arrayify(options.release.uploadLegacySourcemaps).map(function (includeItem) {
@@ -9012,7 +9142,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9012
9142
  ignore: includeEntry.ignore ? arrayify(includeEntry.ignore) : undefined
9013
9143
  });
9014
9144
  });
9015
- _context6.next = 33;
9145
+ _context7.next = 33;
9016
9146
  return cliInstance.releases.uploadSourceMaps(options.release.name, {
9017
9147
  include: normalizedInclude,
9018
9148
  dist: options.release.dist,
@@ -9022,124 +9152,176 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9022
9152
  });
9023
9153
  case 33:
9024
9154
  if (!(options.release.setCommits !== false)) {
9025
- _context6.next = 46;
9155
+ _context7.next = 46;
9026
9156
  break;
9027
9157
  }
9028
- _context6.prev = 34;
9029
- _context6.next = 37;
9158
+ _context7.prev = 34;
9159
+ _context7.next = 37;
9030
9160
  return cliInstance.releases.setCommits(options.release.name,
9031
9161
  // set commits always exists due to the normalize function
9032
9162
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
9033
9163
  options.release.setCommits);
9034
9164
  case 37:
9035
- _context6.next = 46;
9165
+ _context7.next = 46;
9036
9166
  break;
9037
9167
  case 39:
9038
- _context6.prev = 39;
9039
- _context6.t0 = _context6["catch"](34);
9168
+ _context7.prev = 39;
9169
+ _context7.t0 = _context7["catch"](34);
9040
9170
  if (!(options.release.setCommits && "shouldNotThrowOnFailure" in options.release.setCommits && options.release.setCommits.shouldNotThrowOnFailure)) {
9041
- _context6.next = 45;
9171
+ _context7.next = 45;
9042
9172
  break;
9043
9173
  }
9044
- logger.debug("An error occurred setting commits on release (this message can be ignored unless you commits on release are desired):", _context6.t0);
9045
- _context6.next = 46;
9174
+ logger.debug("An error occurred setting commits on release (this message can be ignored unless you commits on release are desired):", _context7.t0);
9175
+ _context7.next = 46;
9046
9176
  break;
9047
9177
  case 45:
9048
- throw _context6.t0;
9178
+ throw _context7.t0;
9049
9179
  case 46:
9050
9180
  if (!options.release.finalize) {
9051
- _context6.next = 49;
9181
+ _context7.next = 49;
9052
9182
  break;
9053
9183
  }
9054
- _context6.next = 49;
9184
+ _context7.next = 49;
9055
9185
  return cliInstance.releases.finalize(options.release.name);
9056
9186
  case 49:
9057
9187
  if (!options.release.deploy) {
9058
- _context6.next = 52;
9188
+ _context7.next = 52;
9059
9189
  break;
9060
9190
  }
9061
- _context6.next = 52;
9191
+ _context7.next = 52;
9062
9192
  return cliInstance.releases.newDeploy(options.release.name, options.release.deploy);
9063
9193
  case 52:
9064
- _context6.next = 60;
9194
+ _context7.next = 60;
9065
9195
  break;
9066
9196
  case 54:
9067
- _context6.prev = 54;
9068
- _context6.t1 = _context6["catch"](24);
9197
+ _context7.prev = 54;
9198
+ _context7.t1 = _context7["catch"](24);
9069
9199
  sentryScope.captureException('Error in "releaseManagementPlugin" writeBundle hook');
9070
- _context6.next = 59;
9200
+ _context7.next = 59;
9071
9201
  return safeFlushTelemetry(sentryClient);
9072
9202
  case 59:
9073
- handleRecoverableError(_context6.t1, false);
9203
+ handleRecoverableError(_context7.t1, false);
9074
9204
  case 60:
9075
- _context6.prev = 60;
9205
+ _context7.prev = 60;
9076
9206
  freeWriteBundleInvocationDependencyOnSourcemapFiles();
9077
- return _context6.finish(60);
9207
+ return _context7.finish(60);
9078
9208
  case 63:
9079
9209
  case "end":
9080
- return _context6.stop();
9210
+ return _context7.stop();
9081
9211
  }
9082
- }, _callee6, null, [[24, 54, 60, 63], [34, 39]]);
9212
+ }, _callee7, null, [[24, 54, 60, 63], [34, 39]]);
9213
+ }))();
9214
+ },
9215
+ /*
9216
+ Injects debug IDs into the build artifacts.
9217
+ This is a separate function from `uploadSourcemaps` because that needs to run before the sourcemaps are uploaded.
9218
+ Usually the respective bundler-plugin will take care of this before the sourcemaps are uploaded.
9219
+ Only use this if you need to manually inject debug IDs into the build artifacts.
9220
+ */
9221
+ injectDebugIds: function injectDebugIds(buildArtifactPaths) {
9222
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
9223
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
9224
+ while (1) switch (_context9.prev = _context9.next) {
9225
+ case 0:
9226
+ _context9.next = 2;
9227
+ return startSpan({
9228
+ name: "inject-debug-ids",
9229
+ scope: sentryScope,
9230
+ forceTransaction: true
9231
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
9232
+ var _options$debug, cliInstance;
9233
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
9234
+ while (1) switch (_context8.prev = _context8.next) {
9235
+ case 0:
9236
+ _context8.prev = 0;
9237
+ cliInstance = createCliInstance(options);
9238
+ _context8.next = 4;
9239
+ return cliInstance.execute(["sourcemaps", "inject"].concat(_toConsumableArray(buildArtifactPaths)), (_options$debug = options.debug) !== null && _options$debug !== void 0 ? _options$debug : false);
9240
+ case 4:
9241
+ _context8.next = 10;
9242
+ break;
9243
+ case 6:
9244
+ _context8.prev = 6;
9245
+ _context8.t0 = _context8["catch"](0);
9246
+ sentryScope.captureException('Error in "debugIdInjectionPlugin" writeBundle hook');
9247
+ handleRecoverableError(_context8.t0, false);
9248
+ case 10:
9249
+ _context8.prev = 10;
9250
+ _context8.next = 13;
9251
+ return safeFlushTelemetry(sentryClient);
9252
+ case 13:
9253
+ return _context8.finish(10);
9254
+ case 14:
9255
+ case "end":
9256
+ return _context8.stop();
9257
+ }
9258
+ }, _callee8, null, [[0, 6, 10, 14]]);
9259
+ })));
9260
+ case 2:
9261
+ case "end":
9262
+ return _context9.stop();
9263
+ }
9264
+ }, _callee9);
9083
9265
  }))();
9084
9266
  },
9085
9267
  /**
9086
9268
  * Uploads sourcemaps using the "Debug ID" method. This function takes a list of build artifact paths that will be uploaded
9087
9269
  */
9088
9270
  uploadSourcemaps: function uploadSourcemaps(buildArtifactPaths) {
9089
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
9090
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
9091
- while (1) switch (_context15.prev = _context15.next) {
9271
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
9272
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
9273
+ while (1) switch (_context18.prev = _context18.next) {
9092
9274
  case 0:
9093
9275
  if (canUploadSourceMaps(options, logger, isDevMode)) {
9094
- _context15.next = 2;
9276
+ _context18.next = 2;
9095
9277
  break;
9096
9278
  }
9097
- return _context15.abrupt("return");
9279
+ return _context18.abrupt("return");
9098
9280
  case 2:
9099
- _context15.next = 4;
9281
+ _context18.next = 4;
9100
9282
  return startSpan(
9101
9283
  // This is `forceTransaction`ed because this span is used in dashboards in the form of indexed transactions.
9102
9284
  {
9103
9285
  name: "debug-id-sourcemap-upload",
9104
9286
  scope: sentryScope,
9105
9287
  forceTransaction: true
9106
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
9288
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
9107
9289
  var folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps, tmpUploadFolder, assets, globAssets, globResult, debugIdChunkFilePaths, numUploadedFiles, _process$env2;
9108
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
9109
- while (1) switch (_context14.prev = _context14.next) {
9290
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
9291
+ while (1) switch (_context17.prev = _context17.next) {
9110
9292
  case 0:
9111
9293
  // 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`)
9112
9294
  // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.
9113
9295
  freeUploadDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
9114
- _context14.prev = 1;
9115
- _context14.next = 4;
9296
+ _context17.prev = 1;
9297
+ _context17.next = 4;
9116
9298
  return startSpan({
9117
9299
  name: "mkdtemp",
9118
9300
  scope: sentryScope
9119
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
9301
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
9120
9302
  var _process$env;
9121
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
9122
- while (1) switch (_context7.prev = _context7.next) {
9303
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
9304
+ while (1) switch (_context10.prev = _context10.next) {
9123
9305
  case 0:
9124
- _context7.t0 = (_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env["SENTRY_TEST_OVERRIDE_TEMP_DIR"];
9125
- if (_context7.t0) {
9126
- _context7.next = 5;
9306
+ _context10.t0 = (_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env["SENTRY_TEST_OVERRIDE_TEMP_DIR"];
9307
+ if (_context10.t0) {
9308
+ _context10.next = 5;
9127
9309
  break;
9128
9310
  }
9129
- _context7.next = 4;
9311
+ _context10.next = 4;
9130
9312
  return fs.promises.mkdtemp(path.join(os.tmpdir(), "sentry-bundler-plugin-upload-"));
9131
9313
  case 4:
9132
- _context7.t0 = _context7.sent;
9314
+ _context10.t0 = _context10.sent;
9133
9315
  case 5:
9134
- return _context7.abrupt("return", _context7.t0);
9316
+ return _context10.abrupt("return", _context10.t0);
9135
9317
  case 6:
9136
9318
  case "end":
9137
- return _context7.stop();
9319
+ return _context10.stop();
9138
9320
  }
9139
- }, _callee7);
9321
+ }, _callee10);
9140
9322
  })));
9141
9323
  case 4:
9142
- tmpUploadFolder = _context14.sent;
9324
+ tmpUploadFolder = _context17.sent;
9143
9325
  folderToCleanUp = tmpUploadFolder;
9144
9326
  assets = (_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.assets;
9145
9327
  if (assets) {
@@ -9148,281 +9330,264 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9148
9330
  logger.debug("No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.");
9149
9331
  globAssets = buildArtifactPaths;
9150
9332
  }
9151
- _context14.next = 10;
9333
+ _context17.next = 10;
9152
9334
  return startSpan({
9153
9335
  name: "glob",
9154
9336
  scope: sentryScope
9155
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
9337
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
9156
9338
  var _options$sourcemaps2;
9157
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
9158
- while (1) switch (_context8.prev = _context8.next) {
9339
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
9340
+ while (1) switch (_context11.prev = _context11.next) {
9159
9341
  case 0:
9160
- _context8.next = 2;
9342
+ _context11.next = 2;
9161
9343
  return glob(globAssets, {
9162
9344
  absolute: true,
9163
9345
  nodir: true,
9164
9346
  ignore: (_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.ignore
9165
9347
  });
9166
9348
  case 2:
9167
- return _context8.abrupt("return", _context8.sent);
9349
+ return _context11.abrupt("return", _context11.sent);
9168
9350
  case 3:
9169
9351
  case "end":
9170
- return _context8.stop();
9352
+ return _context11.stop();
9171
9353
  }
9172
- }, _callee8);
9354
+ }, _callee11);
9173
9355
  })));
9174
9356
  case 10:
9175
- globResult = _context14.sent;
9357
+ globResult = _context17.sent;
9176
9358
  debugIdChunkFilePaths = globResult.filter(function (debugIdChunkFilePath) {
9177
9359
  return !!stripQueryAndHashFromPath(debugIdChunkFilePath).match(/\.(js|mjs|cjs)$/);
9178
9360
  }); // The order of the files output by glob() is not deterministic
9179
9361
  // Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent
9180
9362
  debugIdChunkFilePaths.sort();
9181
9363
  if (!(Array.isArray(assets) && assets.length === 0)) {
9182
- _context14.next = 17;
9364
+ _context17.next = 17;
9183
9365
  break;
9184
9366
  }
9185
9367
  logger.debug("Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.");
9186
- _context14.next = 25;
9368
+ _context17.next = 25;
9187
9369
  break;
9188
9370
  case 17:
9189
9371
  if (!(debugIdChunkFilePaths.length === 0)) {
9190
- _context14.next = 21;
9372
+ _context17.next = 21;
9191
9373
  break;
9192
9374
  }
9193
9375
  logger.warn("Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.");
9194
- _context14.next = 25;
9376
+ _context17.next = 25;
9195
9377
  break;
9196
9378
  case 21:
9197
- _context14.next = 23;
9379
+ _context17.next = 23;
9198
9380
  return startSpan({
9199
9381
  name: "prepare-bundles",
9200
9382
  scope: sentryScope
9201
9383
  }, /*#__PURE__*/function () {
9202
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(prepBundlesSpan) {
9384
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(prepBundlesSpan) {
9203
9385
  var preparationTasks, workers, worker, workerIndex, files, stats, uploadSize;
9204
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
9205
- while (1) switch (_context12.prev = _context12.next) {
9386
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
9387
+ while (1) switch (_context15.prev = _context15.next) {
9206
9388
  case 0:
9207
9389
  // Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so
9208
9390
  // instead we do it with a maximum of 16 concurrent workers
9209
9391
  preparationTasks = debugIdChunkFilePaths.map(function (chunkFilePath, chunkIndex) {
9210
- return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
9392
+ return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
9211
9393
  var _options$sourcemaps$r, _options$sourcemaps3, _options$sourcemaps4;
9212
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
9213
- while (1) switch (_context9.prev = _context9.next) {
9394
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
9395
+ while (1) switch (_context12.prev = _context12.next) {
9214
9396
  case 0:
9215
- _context9.next = 2;
9397
+ _context12.next = 2;
9216
9398
  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);
9217
9399
  case 2:
9218
9400
  case "end":
9219
- return _context9.stop();
9401
+ return _context12.stop();
9220
9402
  }
9221
- }, _callee9);
9403
+ }, _callee12);
9222
9404
  }));
9223
9405
  });
9224
9406
  workers = [];
9225
9407
  worker = /*#__PURE__*/function () {
9226
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
9408
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
9227
9409
  var task;
9228
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
9229
- while (1) switch (_context10.prev = _context10.next) {
9410
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
9411
+ while (1) switch (_context13.prev = _context13.next) {
9230
9412
  case 0:
9231
9413
  if (!(preparationTasks.length > 0)) {
9232
- _context10.next = 7;
9414
+ _context13.next = 7;
9233
9415
  break;
9234
9416
  }
9235
9417
  task = preparationTasks.shift();
9236
9418
  if (!task) {
9237
- _context10.next = 5;
9419
+ _context13.next = 5;
9238
9420
  break;
9239
9421
  }
9240
- _context10.next = 5;
9422
+ _context13.next = 5;
9241
9423
  return task();
9242
9424
  case 5:
9243
- _context10.next = 0;
9425
+ _context13.next = 0;
9244
9426
  break;
9245
9427
  case 7:
9246
9428
  case "end":
9247
- return _context10.stop();
9429
+ return _context13.stop();
9248
9430
  }
9249
- }, _callee10);
9431
+ }, _callee13);
9250
9432
  }));
9251
9433
  return function worker() {
9252
- return _ref6.apply(this, arguments);
9434
+ return _ref7.apply(this, arguments);
9253
9435
  };
9254
9436
  }();
9255
9437
  for (workerIndex = 0; workerIndex < 16; workerIndex++) {
9256
9438
  workers.push(worker());
9257
9439
  }
9258
- _context12.next = 6;
9440
+ _context15.next = 6;
9259
9441
  return Promise.all(workers);
9260
9442
  case 6:
9261
- _context12.next = 8;
9443
+ _context15.next = 8;
9262
9444
  return fs.promises.readdir(tmpUploadFolder);
9263
9445
  case 8:
9264
- files = _context12.sent;
9446
+ files = _context15.sent;
9265
9447
  stats = files.map(function (file) {
9266
9448
  return fs.promises.stat(path.join(tmpUploadFolder, file));
9267
9449
  });
9268
- _context12.next = 12;
9450
+ _context15.next = 12;
9269
9451
  return Promise.all(stats);
9270
9452
  case 12:
9271
- uploadSize = _context12.sent.reduce(function (accumulator, _ref7) {
9272
- var size = _ref7.size;
9453
+ uploadSize = _context15.sent.reduce(function (accumulator, _ref8) {
9454
+ var size = _ref8.size;
9273
9455
  return accumulator + size;
9274
9456
  }, 0);
9275
9457
  setMeasurement("files", files.length, "none", prepBundlesSpan);
9276
9458
  setMeasurement("upload_size", uploadSize, "byte", prepBundlesSpan);
9277
- _context12.next = 17;
9459
+ _context15.next = 17;
9278
9460
  return startSpan({
9279
9461
  name: "upload",
9280
9462
  scope: sentryScope
9281
- }, /*#__PURE__*/function () {
9282
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(uploadSpan) {
9283
- var _options$release$name;
9284
- var cliInstance;
9285
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
9286
- while (1) switch (_context11.prev = _context11.next) {
9287
- case 0:
9288
- cliInstance = new SentryCli(null, {
9289
- authToken: options.authToken,
9290
- org: options.org,
9291
- project: options.project,
9292
- silent: options.silent,
9293
- url: options.url,
9294
- vcsRemote: options.release.vcsRemote,
9295
- headers: _objectSpread2({
9296
- "sentry-trace": spanToTraceHeader(uploadSpan),
9297
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
9298
- baggage: dynamicSamplingContextToSentryBaggageHeader(getDynamicSamplingContextFromSpan(uploadSpan))
9299
- }, options.headers)
9300
- });
9301
- _context11.next = 3;
9302
- return cliInstance.releases.uploadSourceMaps((_options$release$name = options.release.name) !== null && _options$release$name !== void 0 ? _options$release$name : "undefined",
9303
- // unfortunately this needs a value for now but it will not matter since debug IDs overpower releases anyhow
9304
- {
9305
- include: [{
9306
- paths: [tmpUploadFolder],
9307
- rewrite: false,
9308
- dist: options.release.dist
9309
- }],
9310
- // We want this promise to throw if the sourcemaps fail to upload so that we know about it.
9311
- // see: https://github.com/getsentry/sentry-cli/pull/2605
9312
- live: "rejectOnError"
9313
- });
9314
- case 3:
9315
- case "end":
9316
- return _context11.stop();
9317
- }
9318
- }, _callee11);
9319
- }));
9320
- return function (_x2) {
9321
- return _ref8.apply(this, arguments);
9322
- };
9323
- }());
9463
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
9464
+ var _options$release$name;
9465
+ var cliInstance;
9466
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
9467
+ while (1) switch (_context14.prev = _context14.next) {
9468
+ case 0:
9469
+ cliInstance = createCliInstance(options);
9470
+ _context14.next = 3;
9471
+ return cliInstance.releases.uploadSourceMaps((_options$release$name = options.release.name) !== null && _options$release$name !== void 0 ? _options$release$name : "undefined",
9472
+ // unfortunately this needs a value for now but it will not matter since debug IDs overpower releases anyhow
9473
+ {
9474
+ include: [{
9475
+ paths: [tmpUploadFolder],
9476
+ rewrite: false,
9477
+ dist: options.release.dist
9478
+ }],
9479
+ // We want this promise to throw if the sourcemaps fail to upload so that we know about it.
9480
+ // see: https://github.com/getsentry/sentry-cli/pull/2605
9481
+ live: "rejectOnError"
9482
+ });
9483
+ case 3:
9484
+ case "end":
9485
+ return _context14.stop();
9486
+ }
9487
+ }, _callee14);
9488
+ })));
9324
9489
  case 17:
9325
- return _context12.abrupt("return", files.length);
9490
+ return _context15.abrupt("return", files.length);
9326
9491
  case 18:
9327
9492
  case "end":
9328
- return _context12.stop();
9493
+ return _context15.stop();
9329
9494
  }
9330
- }, _callee12);
9495
+ }, _callee15);
9331
9496
  }));
9332
9497
  return function (_x) {
9333
- return _ref4.apply(this, arguments);
9498
+ return _ref5.apply(this, arguments);
9334
9499
  };
9335
9500
  }());
9336
9501
  case 23:
9337
- numUploadedFiles = _context14.sent;
9502
+ numUploadedFiles = _context17.sent;
9338
9503
  if (numUploadedFiles > 0) {
9339
9504
  logger.info("Successfully uploaded source maps to Sentry");
9340
9505
  }
9341
9506
  case 25:
9342
- _context14.next = 31;
9507
+ _context17.next = 31;
9343
9508
  break;
9344
9509
  case 27:
9345
- _context14.prev = 27;
9346
- _context14.t0 = _context14["catch"](1);
9510
+ _context17.prev = 27;
9511
+ _context17.t0 = _context17["catch"](1);
9347
9512
  sentryScope.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
9348
- handleRecoverableError(_context14.t0, false);
9513
+ handleRecoverableError(_context17.t0, false);
9349
9514
  case 31:
9350
- _context14.prev = 31;
9515
+ _context17.prev = 31;
9351
9516
  if (folderToCleanUp && !((_process$env2 = process.env) !== null && _process$env2 !== void 0 && _process$env2["SENTRY_TEST_OVERRIDE_TEMP_DIR"])) {
9352
9517
  void startSpan({
9353
9518
  name: "cleanup",
9354
9519
  scope: sentryScope
9355
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
9356
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
9357
- while (1) switch (_context13.prev = _context13.next) {
9520
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
9521
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
9522
+ while (1) switch (_context16.prev = _context16.next) {
9358
9523
  case 0:
9359
9524
  if (!folderToCleanUp) {
9360
- _context13.next = 3;
9525
+ _context16.next = 3;
9361
9526
  break;
9362
9527
  }
9363
- _context13.next = 3;
9528
+ _context16.next = 3;
9364
9529
  return fs.promises.rm(folderToCleanUp, {
9365
9530
  recursive: true,
9366
9531
  force: true
9367
9532
  });
9368
9533
  case 3:
9369
9534
  case "end":
9370
- return _context13.stop();
9535
+ return _context16.stop();
9371
9536
  }
9372
- }, _callee13);
9537
+ }, _callee16);
9373
9538
  })));
9374
9539
  }
9375
9540
  freeUploadDependencyOnBuildArtifacts();
9376
- _context14.next = 36;
9541
+ _context17.next = 36;
9377
9542
  return safeFlushTelemetry(sentryClient);
9378
9543
  case 36:
9379
- return _context14.finish(31);
9544
+ return _context17.finish(31);
9380
9545
  case 37:
9381
9546
  case "end":
9382
- return _context14.stop();
9547
+ return _context17.stop();
9383
9548
  }
9384
- }, _callee14, null, [[1, 27, 31, 37]]);
9549
+ }, _callee17, null, [[1, 27, 31, 37]]);
9385
9550
  })));
9386
9551
  case 4:
9387
9552
  case "end":
9388
- return _context15.stop();
9553
+ return _context18.stop();
9389
9554
  }
9390
- }, _callee15);
9555
+ }, _callee18);
9391
9556
  }))();
9392
9557
  },
9393
9558
  /**
9394
9559
  * Will delete artifacts based on the passed `sourcemaps.filesToDeleteAfterUpload` option.
9395
9560
  */
9396
9561
  deleteArtifacts: function deleteArtifacts() {
9397
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
9562
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
9398
9563
  var _options$sourcemaps5, filesToDelete, filePathsToDelete;
9399
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
9400
- while (1) switch (_context16.prev = _context16.next) {
9564
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
9565
+ while (1) switch (_context19.prev = _context19.next) {
9401
9566
  case 0:
9402
- _context16.prev = 0;
9403
- _context16.next = 3;
9567
+ _context19.prev = 0;
9568
+ _context19.next = 3;
9404
9569
  return (_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.filesToDeleteAfterUpload;
9405
9570
  case 3:
9406
- filesToDelete = _context16.sent;
9571
+ filesToDelete = _context19.sent;
9407
9572
  if (!(filesToDelete !== undefined)) {
9408
- _context16.next = 14;
9573
+ _context19.next = 14;
9409
9574
  break;
9410
9575
  }
9411
- _context16.next = 7;
9576
+ _context19.next = 7;
9412
9577
  return glob(filesToDelete, {
9413
9578
  absolute: true,
9414
9579
  nodir: true
9415
9580
  });
9416
9581
  case 7:
9417
- filePathsToDelete = _context16.sent;
9582
+ filePathsToDelete = _context19.sent;
9418
9583
  logger.debug("Waiting for dependencies on generated files to be freed before deleting...");
9419
- _context16.next = 11;
9584
+ _context19.next = 11;
9420
9585
  return waitUntilBuildArtifactDependenciesAreFreed();
9421
9586
  case 11:
9422
9587
  filePathsToDelete.forEach(function (filePathToDelete) {
9423
9588
  logger.debug("Deleting asset after upload: ".concat(filePathToDelete));
9424
9589
  });
9425
- _context16.next = 14;
9590
+ _context19.next = 14;
9426
9591
  return Promise.all(filePathsToDelete.map(function (filePathToDelete) {
9427
9592
  return fs.promises.rm(filePathToDelete, {
9428
9593
  force: true
@@ -9432,23 +9597,23 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9432
9597
  });
9433
9598
  }));
9434
9599
  case 14:
9435
- _context16.next = 22;
9600
+ _context19.next = 22;
9436
9601
  break;
9437
9602
  case 16:
9438
- _context16.prev = 16;
9439
- _context16.t0 = _context16["catch"](0);
9603
+ _context19.prev = 16;
9604
+ _context19.t0 = _context19["catch"](0);
9440
9605
  sentryScope.captureException('Error in "sentry-file-deletion-plugin" buildEnd hook');
9441
- _context16.next = 21;
9606
+ _context19.next = 21;
9442
9607
  return safeFlushTelemetry(sentryClient);
9443
9608
  case 21:
9444
9609
  // We throw by default if we get here b/c not being able to delete
9445
9610
  // source maps could leak them to production
9446
- handleRecoverableError(_context16.t0, true);
9611
+ handleRecoverableError(_context19.t0, true);
9447
9612
  case 22:
9448
9613
  case "end":
9449
- return _context16.stop();
9614
+ return _context19.stop();
9450
9615
  }
9451
- }, _callee16, null, [[0, 16]]);
9616
+ }, _callee19, null, [[0, 16]]);
9452
9617
  }))();
9453
9618
  },
9454
9619
  createDependencyOnBuildArtifacts: createDependencyOnBuildArtifacts
@@ -9571,14 +9736,16 @@ function sentryUnpluginFactory(_ref) {
9571
9736
  }))();
9572
9737
  }
9573
9738
  });
9574
- if (!((_options$sourcemaps = options.sourcemaps) !== null && _options$sourcemaps !== void 0 && _options$sourcemaps.disable)) {
9739
+ if (((_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.disable) !== true) {
9740
+ var _options$sourcemaps2;
9575
9741
  plugins.push(debugIdInjectionPlugin(logger));
9576
-
9577
- // This option is only strongly typed for the webpack plugin, where it is used. It has no effect on other plugins
9578
- var _webpack_forceExitOnBuildComplete = typeof options._experiments["forceExitOnBuildCompletion"] === "boolean" ? options._experiments["forceExitOnBuildCompletion"] : undefined;
9579
- plugins.push(debugIdUploadPlugin(createDebugIdUploadFunction({
9580
- sentryBuildPluginManager: sentryBuildPluginManager
9581
- }), logger, sentryBuildPluginManager.createDependencyOnBuildArtifacts, _webpack_forceExitOnBuildComplete));
9742
+ if (((_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.disable) !== "disable-upload") {
9743
+ // This option is only strongly typed for the webpack plugin, where it is used. It has no effect on other plugins
9744
+ var _webpack_forceExitOnBuildComplete = typeof options._experiments["forceExitOnBuildCompletion"] === "boolean" ? options._experiments["forceExitOnBuildCompletion"] : undefined;
9745
+ plugins.push(debugIdUploadPlugin(createDebugIdUploadFunction({
9746
+ sentryBuildPluginManager: sentryBuildPluginManager
9747
+ }), logger, sentryBuildPluginManager.createDependencyOnBuildArtifacts, _webpack_forceExitOnBuildComplete));
9748
+ }
9582
9749
  }
9583
9750
  if (options.reactComponentAnnotation) {
9584
9751
  if (!options.reactComponentAnnotation.enabled) {