@sentry/bundler-plugin-core 3.4.0 → 3.6.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.
package/dist/cjs/index.js CHANGED
@@ -18,6 +18,7 @@ var childProcess = require('child_process');
18
18
  var https = require('node:https');
19
19
  var node_stream = require('node:stream');
20
20
  var node_zlib = require('node:zlib');
21
+ var url = require('url');
21
22
  var util = require('util');
22
23
 
23
24
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -54,6 +55,7 @@ var findUp__default = /*#__PURE__*/_interopDefaultLegacy(findUp);
54
55
  var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
55
56
  var childProcess__default = /*#__PURE__*/_interopDefaultLegacy(childProcess);
56
57
  var https__namespace = /*#__PURE__*/_interopNamespace(https);
58
+ var url__namespace = /*#__PURE__*/_interopNamespace(url);
57
59
  var util__namespace = /*#__PURE__*/_interopNamespace(util);
58
60
 
59
61
  function ownKeys(object, enumerableOnly) {
@@ -8193,7 +8195,7 @@ function createSentryInstance(options, shouldSendTelemetry, buildTool) {
8193
8195
  dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
8194
8196
  tracesSampleRate: 1,
8195
8197
  sampleRate: 1,
8196
- release: "3.4.0",
8198
+ release: "3.6.0",
8197
8199
  integrations: [],
8198
8200
  tracePropagationTargets: ["sentry.io/api"],
8199
8201
  stackParser: stackParser,
@@ -8377,7 +8379,7 @@ function createDebugIdUploadFunction(_ref) {
8377
8379
  };
8378
8380
  }();
8379
8381
  }
8380
- function prepareBundleForDebugIdUpload(_x2, _x3, _x4, _x5, _x6) {
8382
+ function prepareBundleForDebugIdUpload(_x2, _x3, _x4, _x5, _x6, _x7) {
8381
8383
  return _prepareBundleForDebugIdUpload.apply(this, arguments);
8382
8384
  }
8383
8385
 
@@ -8388,7 +8390,7 @@ function prepareBundleForDebugIdUpload(_x2, _x3, _x4, _x5, _x6) {
8388
8390
  * The string pattern is injected via the debug ID injection snipped.
8389
8391
  */
8390
8392
  function _prepareBundleForDebugIdUpload() {
8391
- _prepareBundleForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(bundleFilePath, uploadFolder, chunkIndex, logger, rewriteSourcesHook) {
8393
+ _prepareBundleForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(bundleFilePath, uploadFolder, chunkIndex, logger, rewriteSourcesHook, resolveSourceMapHook) {
8392
8394
  var bundleContent, debugId, uniqueUploadName, writeSourceFilePromise, writeSourceMapFilePromise;
8393
8395
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
8394
8396
  while (1) switch (_context3.prev = _context3.next) {
@@ -8417,7 +8419,7 @@ function _prepareBundleForDebugIdUpload() {
8417
8419
  uniqueUploadName = "".concat(debugId, "-").concat(chunkIndex);
8418
8420
  bundleContent = addDebugIdToBundleSource(bundleContent, debugId);
8419
8421
  writeSourceFilePromise = fs__default["default"].promises.writeFile(path__default["default"].join(uploadFolder, "".concat(uniqueUploadName, ".js")), bundleContent, "utf-8");
8420
- writeSourceMapFilePromise = determineSourceMapPathFromBundle(bundleFilePath, bundleContent, logger).then( /*#__PURE__*/function () {
8422
+ writeSourceMapFilePromise = determineSourceMapPathFromBundle(bundleFilePath, bundleContent, logger, resolveSourceMapHook).then( /*#__PURE__*/function () {
8421
8423
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(sourceMapPath) {
8422
8424
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
8423
8425
  while (1) switch (_context2.prev = _context2.next) {
@@ -8434,7 +8436,7 @@ function _prepareBundleForDebugIdUpload() {
8434
8436
  }
8435
8437
  }, _callee2);
8436
8438
  }));
8437
- return function (_x15) {
8439
+ return function (_x17) {
8438
8440
  return _ref3.apply(this, arguments);
8439
8441
  };
8440
8442
  }());
@@ -8476,75 +8478,89 @@ function addDebugIdToBundleSource(bundleSource, debugId) {
8476
8478
  *
8477
8479
  * @returns the path to the bundle's source map or `undefined` if none could be found.
8478
8480
  */
8479
- function determineSourceMapPathFromBundle(_x7, _x8, _x9) {
8481
+ function determineSourceMapPathFromBundle(_x8, _x9, _x10, _x11) {
8480
8482
  return _determineSourceMapPathFromBundle.apply(this, arguments);
8481
8483
  }
8484
+
8482
8485
  /**
8483
8486
  * Reads a source map, injects debug ID fields, and writes the source map to the target path.
8484
8487
  */
8485
8488
  function _determineSourceMapPathFromBundle() {
8486
- _determineSourceMapPathFromBundle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(bundlePath, bundleSource, logger) {
8487
- var sourceMappingUrlMatch, sourceMappingUrl, isUrl, isSupportedUrl, url, absoluteSourceMapPath, adjacentSourceMapFilePath;
8489
+ _determineSourceMapPathFromBundle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(bundlePath, bundleSource, logger, resolveSourceMapHook) {
8490
+ var sourceMappingUrlMatch, sourceMappingUrl, searchLocations, customPath, parsedUrl, _i, _searchLocations, searchLocation;
8488
8491
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
8489
8492
  while (1) switch (_context4.prev = _context4.next) {
8490
8493
  case 0:
8491
- // 1. try to find source map at `sourceMappingURL` location
8492
8494
  sourceMappingUrlMatch = bundleSource.match(/^\s*\/\/# sourceMappingURL=(.*)$/m);
8493
- if (!sourceMappingUrlMatch) {
8494
- _context4.next = 14;
8495
+ sourceMappingUrl = sourceMappingUrlMatch ? sourceMappingUrlMatch[1] : undefined;
8496
+ searchLocations = [];
8497
+ if (!resolveSourceMapHook) {
8498
+ _context4.next = 10;
8495
8499
  break;
8496
8500
  }
8497
- sourceMappingUrl = path__default["default"].normalize(sourceMappingUrlMatch[1]);
8498
- try {
8499
- url = new URL(sourceMappingUrl);
8500
- isUrl = true;
8501
- isSupportedUrl = url.protocol === "file:";
8502
- } catch (_unused) {
8503
- isUrl = false;
8504
- isSupportedUrl = false;
8501
+ logger.debug("Calling sourcemaps.resolveSourceMap(".concat(JSON.stringify(bundlePath), ", ").concat(JSON.stringify(sourceMappingUrl), ")"));
8502
+ _context4.next = 7;
8503
+ return resolveSourceMapHook(bundlePath, sourceMappingUrl);
8504
+ case 7:
8505
+ customPath = _context4.sent;
8506
+ logger.debug("resolveSourceMap hook returned: ".concat(JSON.stringify(customPath)));
8507
+ if (customPath) {
8508
+ searchLocations.push(customPath);
8505
8509
  }
8506
- if (isSupportedUrl) {
8507
- absoluteSourceMapPath = sourceMappingUrl;
8508
- } else if (isUrl) ; else if (path__default["default"].isAbsolute(sourceMappingUrl)) {
8509
- absoluteSourceMapPath = sourceMappingUrl;
8510
- } else {
8511
- absoluteSourceMapPath = path__default["default"].join(path__default["default"].dirname(bundlePath), sourceMappingUrl);
8510
+ case 10:
8511
+ // 1. try to find source map at `sourceMappingURL` location
8512
+ if (sourceMappingUrl) {
8513
+ try {
8514
+ parsedUrl = new URL(sourceMappingUrl);
8515
+ } catch (_unused) {
8516
+ // noop
8517
+ }
8518
+ if (parsedUrl && parsedUrl.protocol === "file:") {
8519
+ searchLocations.push(url__namespace.fileURLToPath(sourceMappingUrl));
8520
+ } else if (parsedUrl) ; else if (path__default["default"].isAbsolute(sourceMappingUrl)) {
8521
+ searchLocations.push(path__default["default"].normalize(sourceMappingUrl));
8522
+ } else {
8523
+ searchLocations.push(path__default["default"].normalize(path__default["default"].join(path__default["default"].dirname(bundlePath), sourceMappingUrl)));
8524
+ }
8512
8525
  }
8513
- if (!absoluteSourceMapPath) {
8514
- _context4.next = 14;
8526
+
8527
+ // 2. try to find source map at path adjacent to chunk source, but with `.map` appended
8528
+ searchLocations.push(bundlePath + ".map");
8529
+ _i = 0, _searchLocations = searchLocations;
8530
+ case 13:
8531
+ if (!(_i < _searchLocations.length)) {
8532
+ _context4.next = 27;
8515
8533
  break;
8516
8534
  }
8517
- _context4.prev = 6;
8518
- _context4.next = 9;
8519
- return util__namespace.promisify(fs__default["default"].access)(absoluteSourceMapPath);
8520
- case 9:
8521
- return _context4.abrupt("return", absoluteSourceMapPath);
8522
- case 12:
8523
- _context4.prev = 12;
8524
- _context4.t0 = _context4["catch"](6);
8525
- case 14:
8526
- _context4.prev = 14;
8527
- adjacentSourceMapFilePath = bundlePath + ".map";
8535
+ searchLocation = _searchLocations[_i];
8536
+ _context4.prev = 15;
8528
8537
  _context4.next = 18;
8529
- return util__namespace.promisify(fs__default["default"].access)(adjacentSourceMapFilePath);
8538
+ return util__namespace.promisify(fs__default["default"].access)(searchLocation);
8530
8539
  case 18:
8531
- return _context4.abrupt("return", adjacentSourceMapFilePath);
8532
- case 21:
8533
- _context4.prev = 21;
8534
- _context4.t1 = _context4["catch"](14);
8535
- case 23:
8540
+ logger.debug("Source map found for bundle `".concat(bundlePath, "`: `").concat(searchLocation, "`"));
8541
+ return _context4.abrupt("return", searchLocation);
8542
+ case 22:
8543
+ _context4.prev = 22;
8544
+ _context4.t0 = _context4["catch"](15);
8545
+ case 24:
8546
+ _i++;
8547
+ _context4.next = 13;
8548
+ break;
8549
+ case 27:
8536
8550
  // This is just a debug message because it can be quite spammy for some frameworks
8537
- logger.debug("Could not determine source map path for bundle: ".concat(bundlePath, " - Did you turn on source map generation in your bundler?"));
8551
+ logger.debug("Could not determine source map path for bundle `".concat(bundlePath, "`") + " with sourceMappingURL=".concat(sourceMappingUrl === undefined ? "undefined" : "`".concat(sourceMappingUrl, "`")) + " - Did you turn on source map generation in your bundler?" + " (Attempted paths: ".concat(searchLocations.map(function (e) {
8552
+ return "`".concat(e, "`");
8553
+ }).join(", "), ")"));
8538
8554
  return _context4.abrupt("return", undefined);
8539
- case 25:
8555
+ case 29:
8540
8556
  case "end":
8541
8557
  return _context4.stop();
8542
8558
  }
8543
- }, _callee4, null, [[6, 12], [14, 21]]);
8559
+ }, _callee4, null, [[15, 22]]);
8544
8560
  }));
8545
8561
  return _determineSourceMapPathFromBundle.apply(this, arguments);
8546
8562
  }
8547
- function prepareSourceMapForDebugIdUpload(_x10, _x11, _x12, _x13, _x14) {
8563
+ function prepareSourceMapForDebugIdUpload(_x12, _x13, _x14, _x15, _x16) {
8548
8564
  return _prepareSourceMapForDebugIdUpload.apply(this, arguments);
8549
8565
  }
8550
8566
  function _prepareSourceMapForDebugIdUpload() {
@@ -8644,6 +8660,85 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8644
8660
  }
8645
8661
  }
8646
8662
  var options = normalizeUserOptions(userOptions);
8663
+ if (options.disable) {
8664
+ // Early-return a noop build plugin manager instance so that we
8665
+ // don't continue validating options, setting up Sentry, etc.
8666
+ // Otherwise we might create side-effects or log messages that
8667
+ // users don't expect from a disabled plugin.
8668
+ return {
8669
+ normalizedOptions: options,
8670
+ logger: logger,
8671
+ bundleSizeOptimizationReplacementValues: {},
8672
+ telemetry: {
8673
+ emitBundlerPluginExecutionSignal: function () {
8674
+ var _emitBundlerPluginExecutionSignal = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
8675
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
8676
+ while (1) switch (_context.prev = _context.next) {
8677
+ case 0:
8678
+ case "end":
8679
+ return _context.stop();
8680
+ }
8681
+ }, _callee);
8682
+ }));
8683
+ function emitBundlerPluginExecutionSignal() {
8684
+ return _emitBundlerPluginExecutionSignal.apply(this, arguments);
8685
+ }
8686
+ return emitBundlerPluginExecutionSignal;
8687
+ }()
8688
+ },
8689
+ bundleMetadata: {},
8690
+ createRelease: function () {
8691
+ var _createRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
8692
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
8693
+ while (1) switch (_context2.prev = _context2.next) {
8694
+ case 0:
8695
+ case "end":
8696
+ return _context2.stop();
8697
+ }
8698
+ }, _callee2);
8699
+ }));
8700
+ function createRelease() {
8701
+ return _createRelease.apply(this, arguments);
8702
+ }
8703
+ return createRelease;
8704
+ }(),
8705
+ uploadSourcemaps: function () {
8706
+ var _uploadSourcemaps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
8707
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
8708
+ while (1) switch (_context3.prev = _context3.next) {
8709
+ case 0:
8710
+ case "end":
8711
+ return _context3.stop();
8712
+ }
8713
+ }, _callee3);
8714
+ }));
8715
+ function uploadSourcemaps() {
8716
+ return _uploadSourcemaps.apply(this, arguments);
8717
+ }
8718
+ return uploadSourcemaps;
8719
+ }(),
8720
+ deleteArtifacts: function () {
8721
+ var _deleteArtifacts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
8722
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
8723
+ while (1) switch (_context4.prev = _context4.next) {
8724
+ case 0:
8725
+ case "end":
8726
+ return _context4.stop();
8727
+ }
8728
+ }, _callee4);
8729
+ }));
8730
+ function deleteArtifacts() {
8731
+ return _deleteArtifacts.apply(this, arguments);
8732
+ }
8733
+ return deleteArtifacts;
8734
+ }(),
8735
+ createDependencyOnBuildArtifacts: function createDependencyOnBuildArtifacts() {
8736
+ return function () {
8737
+ /* noop */
8738
+ };
8739
+ }
8740
+ };
8741
+ }
8647
8742
  var shouldSendTelemetry = allowedToSendTelemetry(options);
8648
8743
  var _createSentryInstance = createSentryInstance(options, shouldSendTelemetry, bundlerPluginMetaContext.buildTool),
8649
8744
  sentryScope = _createSentryInstance.sentryScope,
@@ -8676,7 +8771,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8676
8771
  });
8677
8772
 
8678
8773
  // Set the User-Agent that Sentry CLI will use when interacting with Sentry
8679
- process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "3.4.0");
8774
+ process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "3.6.0");
8680
8775
 
8681
8776
  // Not a bulletproof check but should be good enough to at least sometimes determine
8682
8777
  // if the plugin is called in dev/watch mode or for a prod build. The important part
@@ -8837,15 +8932,15 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8837
8932
  * Emits a `Sentry Bundler Plugin execution` signal.
8838
8933
  */
8839
8934
  emitBundlerPluginExecutionSignal: function emitBundlerPluginExecutionSignal() {
8840
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
8841
- return _regeneratorRuntime().wrap(function _callee$(_context) {
8842
- while (1) switch (_context.prev = _context.next) {
8935
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
8936
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
8937
+ while (1) switch (_context5.prev = _context5.next) {
8843
8938
  case 0:
8844
- _context.next = 2;
8939
+ _context5.next = 2;
8845
8940
  return shouldSendTelemetry;
8846
8941
  case 2:
8847
- if (!_context.sent) {
8848
- _context.next = 7;
8942
+ if (!_context5.sent) {
8943
+ _context5.next = 7;
8849
8944
  break;
8850
8945
  }
8851
8946
  logger.info("Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`.");
@@ -8855,13 +8950,13 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8855
8950
  }, function () {
8856
8951
  //
8857
8952
  });
8858
- _context.next = 7;
8953
+ _context5.next = 7;
8859
8954
  return safeFlushTelemetry(sentryClient);
8860
8955
  case 7:
8861
8956
  case "end":
8862
- return _context.stop();
8957
+ return _context5.stop();
8863
8958
  }
8864
- }, _callee);
8959
+ }, _callee5);
8865
8960
  }))();
8866
8961
  }
8867
8962
  },
@@ -8875,50 +8970,50 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8875
8970
  * - adds deploy information
8876
8971
  */
8877
8972
  createRelease: function createRelease() {
8878
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
8973
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
8879
8974
  var freeWriteBundleInvocationDependencyOnSourcemapFiles, cliInstance, normalizedInclude;
8880
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
8881
- while (1) switch (_context2.prev = _context2.next) {
8975
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
8976
+ while (1) switch (_context6.prev = _context6.next) {
8882
8977
  case 0:
8883
8978
  if (options.release.name) {
8884
- _context2.next = 5;
8979
+ _context6.next = 5;
8885
8980
  break;
8886
8981
  }
8887
8982
  logger.debug("No release name provided. Will not create release. Please set the `release.name` option to identify your release.");
8888
- return _context2.abrupt("return");
8983
+ return _context6.abrupt("return");
8889
8984
  case 5:
8890
8985
  if (!isDevMode) {
8891
- _context2.next = 10;
8986
+ _context6.next = 10;
8892
8987
  break;
8893
8988
  }
8894
8989
  logger.debug("Running in development mode. Will not create release.");
8895
- return _context2.abrupt("return");
8990
+ return _context6.abrupt("return");
8896
8991
  case 10:
8897
8992
  if (options.authToken) {
8898
- _context2.next = 15;
8993
+ _context6.next = 15;
8899
8994
  break;
8900
8995
  }
8901
8996
  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"));
8902
- return _context2.abrupt("return");
8997
+ return _context6.abrupt("return");
8903
8998
  case 15:
8904
8999
  if (!(!options.org && !options.authToken.startsWith("sntrys_"))) {
8905
- _context2.next = 20;
9000
+ _context6.next = 20;
8906
9001
  break;
8907
9002
  }
8908
9003
  logger.warn("No organization slug provided. Will not create release. Please set the `org` option to your Sentry organization slug." + getTurborepoEnvPassthroughWarning("SENTRY_ORG"));
8909
- return _context2.abrupt("return");
9004
+ return _context6.abrupt("return");
8910
9005
  case 20:
8911
9006
  if (options.project) {
8912
- _context2.next = 23;
9007
+ _context6.next = 23;
8913
9008
  break;
8914
9009
  }
8915
9010
  logger.warn("No project provided. Will not create release. Please set the `project` option to your Sentry project slug." + getTurborepoEnvPassthroughWarning("SENTRY_PROJECT"));
8916
- return _context2.abrupt("return");
9011
+ return _context6.abrupt("return");
8917
9012
  case 23:
8918
9013
  // 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`)
8919
9014
  // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.
8920
9015
  freeWriteBundleInvocationDependencyOnSourcemapFiles = createDependencyOnBuildArtifacts();
8921
- _context2.prev = 24;
9016
+ _context6.prev = 24;
8922
9017
  cliInstance = new SentryCli__default["default"](null, {
8923
9018
  authToken: options.authToken,
8924
9019
  org: options.org,
@@ -8929,14 +9024,14 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8929
9024
  headers: options.headers
8930
9025
  });
8931
9026
  if (!options.release.create) {
8932
- _context2.next = 29;
9027
+ _context6.next = 29;
8933
9028
  break;
8934
9029
  }
8935
- _context2.next = 29;
9030
+ _context6.next = 29;
8936
9031
  return cliInstance.releases["new"](options.release.name);
8937
9032
  case 29:
8938
9033
  if (!options.release.uploadLegacySourcemaps) {
8939
- _context2.next = 33;
9034
+ _context6.next = 33;
8940
9035
  break;
8941
9036
  }
8942
9037
  normalizedInclude = arrayify(options.release.uploadLegacySourcemaps).map(function (includeItem) {
@@ -8953,244 +9048,238 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8953
9048
  ignore: includeEntry.ignore ? arrayify(includeEntry.ignore) : undefined
8954
9049
  });
8955
9050
  });
8956
- _context2.next = 33;
9051
+ _context6.next = 33;
8957
9052
  return cliInstance.releases.uploadSourceMaps(options.release.name, {
8958
9053
  include: normalizedInclude,
8959
9054
  dist: options.release.dist
8960
9055
  });
8961
9056
  case 33:
8962
9057
  if (!(options.release.setCommits !== false)) {
8963
- _context2.next = 46;
9058
+ _context6.next = 46;
8964
9059
  break;
8965
9060
  }
8966
- _context2.prev = 34;
8967
- _context2.next = 37;
9061
+ _context6.prev = 34;
9062
+ _context6.next = 37;
8968
9063
  return cliInstance.releases.setCommits(options.release.name,
8969
9064
  // set commits always exists due to the normalize function
8970
9065
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
8971
9066
  options.release.setCommits);
8972
9067
  case 37:
8973
- _context2.next = 46;
9068
+ _context6.next = 46;
8974
9069
  break;
8975
9070
  case 39:
8976
- _context2.prev = 39;
8977
- _context2.t0 = _context2["catch"](34);
9071
+ _context6.prev = 39;
9072
+ _context6.t0 = _context6["catch"](34);
8978
9073
  if (!(options.release.setCommits && "shouldNotThrowOnFailure" in options.release.setCommits && options.release.setCommits.shouldNotThrowOnFailure)) {
8979
- _context2.next = 45;
9074
+ _context6.next = 45;
8980
9075
  break;
8981
9076
  }
8982
- logger.debug("An error occurred setting commits on release (this message can be ignored unless you commits on release are desired):", _context2.t0);
8983
- _context2.next = 46;
9077
+ logger.debug("An error occurred setting commits on release (this message can be ignored unless you commits on release are desired):", _context6.t0);
9078
+ _context6.next = 46;
8984
9079
  break;
8985
9080
  case 45:
8986
- throw _context2.t0;
9081
+ throw _context6.t0;
8987
9082
  case 46:
8988
9083
  if (!options.release.finalize) {
8989
- _context2.next = 49;
9084
+ _context6.next = 49;
8990
9085
  break;
8991
9086
  }
8992
- _context2.next = 49;
9087
+ _context6.next = 49;
8993
9088
  return cliInstance.releases.finalize(options.release.name);
8994
9089
  case 49:
8995
9090
  if (!options.release.deploy) {
8996
- _context2.next = 52;
9091
+ _context6.next = 52;
8997
9092
  break;
8998
9093
  }
8999
- _context2.next = 52;
9094
+ _context6.next = 52;
9000
9095
  return cliInstance.releases.newDeploy(options.release.name, options.release.deploy);
9001
9096
  case 52:
9002
- _context2.next = 60;
9097
+ _context6.next = 60;
9003
9098
  break;
9004
9099
  case 54:
9005
- _context2.prev = 54;
9006
- _context2.t1 = _context2["catch"](24);
9100
+ _context6.prev = 54;
9101
+ _context6.t1 = _context6["catch"](24);
9007
9102
  sentryScope.captureException('Error in "releaseManagementPlugin" writeBundle hook');
9008
- _context2.next = 59;
9103
+ _context6.next = 59;
9009
9104
  return safeFlushTelemetry(sentryClient);
9010
9105
  case 59:
9011
- handleRecoverableError(_context2.t1, false);
9106
+ handleRecoverableError(_context6.t1, false);
9012
9107
  case 60:
9013
- _context2.prev = 60;
9108
+ _context6.prev = 60;
9014
9109
  freeWriteBundleInvocationDependencyOnSourcemapFiles();
9015
- return _context2.finish(60);
9110
+ return _context6.finish(60);
9016
9111
  case 63:
9017
9112
  case "end":
9018
- return _context2.stop();
9113
+ return _context6.stop();
9019
9114
  }
9020
- }, _callee2, null, [[24, 54, 60, 63], [34, 39]]);
9115
+ }, _callee6, null, [[24, 54, 60, 63], [34, 39]]);
9021
9116
  }))();
9022
9117
  },
9023
9118
  /**
9024
9119
  * Uploads sourcemaps using the "Debug ID" method. This function takes a list of build artifact paths that will be uploaded
9025
9120
  */
9026
9121
  uploadSourcemaps: function uploadSourcemaps(buildArtifactPaths) {
9027
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
9028
- var _options$sourcemaps;
9029
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
9030
- while (1) switch (_context11.prev = _context11.next) {
9122
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
9123
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
9124
+ while (1) switch (_context15.prev = _context15.next) {
9031
9125
  case 0:
9032
- if ((_options$sourcemaps = options.sourcemaps) !== null && _options$sourcemaps !== void 0 && _options$sourcemaps.disable) {
9033
- logger.debug("Source map upload was disabled. Will not upload sourcemaps using debug ID process.");
9034
- } else if (isDevMode) {
9035
- logger.debug("Running in development mode. Will not upload sourcemaps.");
9036
- } else if (!options.authToken) {
9037
- logger.warn("No auth token provided. Will not upload source maps. 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"));
9038
- } else if (!options.org && !options.authToken.startsWith("sntrys_")) {
9039
- logger.warn("No org provided. Will not upload source maps. Please set the `org` option to your Sentry organization slug." + getTurborepoEnvPassthroughWarning("SENTRY_ORG"));
9040
- } else if (!options.project) {
9041
- logger.warn("No project provided. Will not upload source maps. Please set the `project` option to your Sentry project slug." + getTurborepoEnvPassthroughWarning("SENTRY_PROJECT"));
9126
+ if (canUploadSourceMaps(options, logger, isDevMode)) {
9127
+ _context15.next = 2;
9128
+ break;
9042
9129
  }
9043
- _context11.next = 3;
9130
+ return _context15.abrupt("return");
9131
+ case 2:
9132
+ _context15.next = 4;
9044
9133
  return startSpan(
9045
9134
  // This is `forceTransaction`ed because this span is used in dashboards in the form of indexed transactions.
9046
9135
  {
9047
9136
  name: "debug-id-sourcemap-upload",
9048
9137
  scope: sentryScope,
9049
9138
  forceTransaction: true
9050
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
9051
- var folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps2, tmpUploadFolder, assets, globAssets, globResult, debugIdChunkFilePaths, _process$env2;
9052
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
9053
- while (1) switch (_context10.prev = _context10.next) {
9139
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
9140
+ var folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps, tmpUploadFolder, assets, globAssets, globResult, debugIdChunkFilePaths, numUploadedFiles, _process$env2;
9141
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
9142
+ while (1) switch (_context14.prev = _context14.next) {
9054
9143
  case 0:
9055
9144
  // 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`)
9056
9145
  // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.
9057
9146
  freeUploadDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
9058
- _context10.prev = 1;
9059
- _context10.next = 4;
9147
+ _context14.prev = 1;
9148
+ _context14.next = 4;
9060
9149
  return startSpan({
9061
9150
  name: "mkdtemp",
9062
9151
  scope: sentryScope
9063
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
9152
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
9064
9153
  var _process$env;
9065
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
9066
- while (1) switch (_context3.prev = _context3.next) {
9154
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
9155
+ while (1) switch (_context7.prev = _context7.next) {
9067
9156
  case 0:
9068
- _context3.t0 = (_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env["SENTRY_TEST_OVERRIDE_TEMP_DIR"];
9069
- if (_context3.t0) {
9070
- _context3.next = 5;
9157
+ _context7.t0 = (_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env["SENTRY_TEST_OVERRIDE_TEMP_DIR"];
9158
+ if (_context7.t0) {
9159
+ _context7.next = 5;
9071
9160
  break;
9072
9161
  }
9073
- _context3.next = 4;
9162
+ _context7.next = 4;
9074
9163
  return fs__namespace.promises.mkdtemp(path__namespace.join(os__namespace.tmpdir(), "sentry-bundler-plugin-upload-"));
9075
9164
  case 4:
9076
- _context3.t0 = _context3.sent;
9165
+ _context7.t0 = _context7.sent;
9077
9166
  case 5:
9078
- return _context3.abrupt("return", _context3.t0);
9167
+ return _context7.abrupt("return", _context7.t0);
9079
9168
  case 6:
9080
9169
  case "end":
9081
- return _context3.stop();
9170
+ return _context7.stop();
9082
9171
  }
9083
- }, _callee3);
9172
+ }, _callee7);
9084
9173
  })));
9085
9174
  case 4:
9086
- tmpUploadFolder = _context10.sent;
9175
+ tmpUploadFolder = _context14.sent;
9087
9176
  folderToCleanUp = tmpUploadFolder;
9088
- assets = (_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.assets;
9177
+ assets = (_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.assets;
9089
9178
  if (assets) {
9090
9179
  globAssets = assets;
9091
9180
  } else {
9092
9181
  logger.debug("No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.");
9093
9182
  globAssets = buildArtifactPaths;
9094
9183
  }
9095
- _context10.next = 10;
9184
+ _context14.next = 10;
9096
9185
  return startSpan({
9097
9186
  name: "glob",
9098
9187
  scope: sentryScope
9099
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
9100
- var _options$sourcemaps3;
9101
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
9102
- while (1) switch (_context4.prev = _context4.next) {
9188
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
9189
+ var _options$sourcemaps2;
9190
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
9191
+ while (1) switch (_context8.prev = _context8.next) {
9103
9192
  case 0:
9104
- _context4.next = 2;
9193
+ _context8.next = 2;
9105
9194
  return glob.glob(globAssets, {
9106
9195
  absolute: true,
9107
9196
  nodir: true,
9108
- ignore: (_options$sourcemaps3 = options.sourcemaps) === null || _options$sourcemaps3 === void 0 ? void 0 : _options$sourcemaps3.ignore
9197
+ ignore: (_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.ignore
9109
9198
  });
9110
9199
  case 2:
9111
- return _context4.abrupt("return", _context4.sent);
9200
+ return _context8.abrupt("return", _context8.sent);
9112
9201
  case 3:
9113
9202
  case "end":
9114
- return _context4.stop();
9203
+ return _context8.stop();
9115
9204
  }
9116
- }, _callee4);
9205
+ }, _callee8);
9117
9206
  })));
9118
9207
  case 10:
9119
- globResult = _context10.sent;
9208
+ globResult = _context14.sent;
9120
9209
  debugIdChunkFilePaths = globResult.filter(function (debugIdChunkFilePath) {
9121
9210
  return !!stripQueryAndHashFromPath(debugIdChunkFilePath).match(/\.(js|mjs|cjs)$/);
9122
9211
  }); // The order of the files output by glob() is not deterministic
9123
9212
  // Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent
9124
9213
  debugIdChunkFilePaths.sort();
9125
9214
  if (!(Array.isArray(assets) && assets.length === 0)) {
9126
- _context10.next = 17;
9215
+ _context14.next = 17;
9127
9216
  break;
9128
9217
  }
9129
9218
  logger.debug("Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.");
9130
- _context10.next = 24;
9219
+ _context14.next = 25;
9131
9220
  break;
9132
9221
  case 17:
9133
9222
  if (!(debugIdChunkFilePaths.length === 0)) {
9134
- _context10.next = 21;
9223
+ _context14.next = 21;
9135
9224
  break;
9136
9225
  }
9137
9226
  logger.warn("Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.");
9138
- _context10.next = 24;
9227
+ _context14.next = 25;
9139
9228
  break;
9140
9229
  case 21:
9141
- _context10.next = 23;
9230
+ _context14.next = 23;
9142
9231
  return startSpan({
9143
9232
  name: "prepare-bundles",
9144
9233
  scope: sentryScope
9145
9234
  }, /*#__PURE__*/function () {
9146
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(prepBundlesSpan) {
9235
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(prepBundlesSpan) {
9147
9236
  var preparationTasks, workers, worker, workerIndex, files, stats, uploadSize;
9148
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
9149
- while (1) switch (_context8.prev = _context8.next) {
9237
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
9238
+ while (1) switch (_context12.prev = _context12.next) {
9150
9239
  case 0:
9151
9240
  // Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so
9152
9241
  // instead we do it with a maximum of 16 concurrent workers
9153
9242
  preparationTasks = debugIdChunkFilePaths.map(function (chunkFilePath, chunkIndex) {
9154
- return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
9155
- var _options$sourcemaps$r, _options$sourcemaps4;
9156
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
9157
- while (1) switch (_context5.prev = _context5.next) {
9243
+ return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
9244
+ var _options$sourcemaps$r, _options$sourcemaps3, _options$sourcemaps4;
9245
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
9246
+ while (1) switch (_context9.prev = _context9.next) {
9158
9247
  case 0:
9159
- _context5.next = 2;
9160
- return prepareBundleForDebugIdUpload(chunkFilePath, tmpUploadFolder, chunkIndex, logger, (_options$sourcemaps$r = (_options$sourcemaps4 = options.sourcemaps) === null || _options$sourcemaps4 === void 0 ? void 0 : _options$sourcemaps4.rewriteSources) !== null && _options$sourcemaps$r !== void 0 ? _options$sourcemaps$r : defaultRewriteSourcesHook);
9248
+ _context9.next = 2;
9249
+ 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);
9161
9250
  case 2:
9162
9251
  case "end":
9163
- return _context5.stop();
9252
+ return _context9.stop();
9164
9253
  }
9165
- }, _callee5);
9254
+ }, _callee9);
9166
9255
  }));
9167
9256
  });
9168
9257
  workers = [];
9169
9258
  worker = /*#__PURE__*/function () {
9170
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
9259
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
9171
9260
  var task;
9172
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
9173
- while (1) switch (_context6.prev = _context6.next) {
9261
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
9262
+ while (1) switch (_context10.prev = _context10.next) {
9174
9263
  case 0:
9175
9264
  if (!(preparationTasks.length > 0)) {
9176
- _context6.next = 7;
9265
+ _context10.next = 7;
9177
9266
  break;
9178
9267
  }
9179
9268
  task = preparationTasks.shift();
9180
9269
  if (!task) {
9181
- _context6.next = 5;
9270
+ _context10.next = 5;
9182
9271
  break;
9183
9272
  }
9184
- _context6.next = 5;
9273
+ _context10.next = 5;
9185
9274
  return task();
9186
9275
  case 5:
9187
- _context6.next = 0;
9276
+ _context10.next = 0;
9188
9277
  break;
9189
9278
  case 7:
9190
9279
  case "end":
9191
- return _context6.stop();
9280
+ return _context10.stop();
9192
9281
  }
9193
- }, _callee6);
9282
+ }, _callee10);
9194
9283
  }));
9195
9284
  return function worker() {
9196
9285
  return _ref6.apply(this, arguments);
@@ -9199,35 +9288,35 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9199
9288
  for (workerIndex = 0; workerIndex < 16; workerIndex++) {
9200
9289
  workers.push(worker());
9201
9290
  }
9202
- _context8.next = 6;
9291
+ _context12.next = 6;
9203
9292
  return Promise.all(workers);
9204
9293
  case 6:
9205
- _context8.next = 8;
9294
+ _context12.next = 8;
9206
9295
  return fs__namespace.promises.readdir(tmpUploadFolder);
9207
9296
  case 8:
9208
- files = _context8.sent;
9297
+ files = _context12.sent;
9209
9298
  stats = files.map(function (file) {
9210
9299
  return fs__namespace.promises.stat(path__namespace.join(tmpUploadFolder, file));
9211
9300
  });
9212
- _context8.next = 12;
9301
+ _context12.next = 12;
9213
9302
  return Promise.all(stats);
9214
9303
  case 12:
9215
- uploadSize = _context8.sent.reduce(function (accumulator, _ref7) {
9304
+ uploadSize = _context12.sent.reduce(function (accumulator, _ref7) {
9216
9305
  var size = _ref7.size;
9217
9306
  return accumulator + size;
9218
9307
  }, 0);
9219
9308
  setMeasurement("files", files.length, "none", prepBundlesSpan);
9220
9309
  setMeasurement("upload_size", uploadSize, "byte", prepBundlesSpan);
9221
- _context8.next = 17;
9310
+ _context12.next = 17;
9222
9311
  return startSpan({
9223
9312
  name: "upload",
9224
9313
  scope: sentryScope
9225
9314
  }, /*#__PURE__*/function () {
9226
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(uploadSpan) {
9315
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(uploadSpan) {
9227
9316
  var _options$release$name;
9228
9317
  var cliInstance;
9229
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
9230
- while (1) switch (_context7.prev = _context7.next) {
9318
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
9319
+ while (1) switch (_context11.prev = _context11.next) {
9231
9320
  case 0:
9232
9321
  cliInstance = new SentryCli__default["default"](null, {
9233
9322
  authToken: options.authToken,
@@ -9242,7 +9331,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9242
9331
  baggage: dynamicSamplingContextToSentryBaggageHeader(getDynamicSamplingContextFromSpan(uploadSpan))
9243
9332
  }, options.headers)
9244
9333
  });
9245
- _context7.next = 3;
9334
+ _context11.next = 3;
9246
9335
  return cliInstance.releases.uploadSourceMaps((_options$release$name = options.release.name) !== null && _options$release$name !== void 0 ? _options$release$name : "undefined",
9247
9336
  // unfortunately this needs a value for now but it will not matter since debug IDs overpower releases anyhow
9248
9337
  {
@@ -9254,111 +9343,116 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9254
9343
  });
9255
9344
  case 3:
9256
9345
  case "end":
9257
- return _context7.stop();
9346
+ return _context11.stop();
9258
9347
  }
9259
- }, _callee7);
9348
+ }, _callee11);
9260
9349
  }));
9261
9350
  return function (_x2) {
9262
9351
  return _ref8.apply(this, arguments);
9263
9352
  };
9264
9353
  }());
9265
9354
  case 17:
9355
+ return _context12.abrupt("return", files.length);
9356
+ case 18:
9266
9357
  case "end":
9267
- return _context8.stop();
9358
+ return _context12.stop();
9268
9359
  }
9269
- }, _callee8);
9360
+ }, _callee12);
9270
9361
  }));
9271
9362
  return function (_x) {
9272
9363
  return _ref4.apply(this, arguments);
9273
9364
  };
9274
9365
  }());
9275
9366
  case 23:
9276
- logger.info("Successfully uploaded source maps to Sentry");
9277
- case 24:
9278
- _context10.next = 30;
9367
+ numUploadedFiles = _context14.sent;
9368
+ if (numUploadedFiles > 0) {
9369
+ logger.info("Successfully uploaded source maps to Sentry");
9370
+ }
9371
+ case 25:
9372
+ _context14.next = 31;
9279
9373
  break;
9280
- case 26:
9281
- _context10.prev = 26;
9282
- _context10.t0 = _context10["catch"](1);
9374
+ case 27:
9375
+ _context14.prev = 27;
9376
+ _context14.t0 = _context14["catch"](1);
9283
9377
  sentryScope.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
9284
- handleRecoverableError(_context10.t0, false);
9285
- case 30:
9286
- _context10.prev = 30;
9378
+ handleRecoverableError(_context14.t0, false);
9379
+ case 31:
9380
+ _context14.prev = 31;
9287
9381
  if (folderToCleanUp && !((_process$env2 = process.env) !== null && _process$env2 !== void 0 && _process$env2["SENTRY_TEST_OVERRIDE_TEMP_DIR"])) {
9288
9382
  void startSpan({
9289
9383
  name: "cleanup",
9290
9384
  scope: sentryScope
9291
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
9292
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
9293
- while (1) switch (_context9.prev = _context9.next) {
9385
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
9386
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
9387
+ while (1) switch (_context13.prev = _context13.next) {
9294
9388
  case 0:
9295
9389
  if (!folderToCleanUp) {
9296
- _context9.next = 3;
9390
+ _context13.next = 3;
9297
9391
  break;
9298
9392
  }
9299
- _context9.next = 3;
9393
+ _context13.next = 3;
9300
9394
  return fs__namespace.promises.rm(folderToCleanUp, {
9301
9395
  recursive: true,
9302
9396
  force: true
9303
9397
  });
9304
9398
  case 3:
9305
9399
  case "end":
9306
- return _context9.stop();
9400
+ return _context13.stop();
9307
9401
  }
9308
- }, _callee9);
9402
+ }, _callee13);
9309
9403
  })));
9310
9404
  }
9311
9405
  freeUploadDependencyOnBuildArtifacts();
9312
- _context10.next = 35;
9406
+ _context14.next = 36;
9313
9407
  return safeFlushTelemetry(sentryClient);
9314
- case 35:
9315
- return _context10.finish(30);
9316
9408
  case 36:
9409
+ return _context14.finish(31);
9410
+ case 37:
9317
9411
  case "end":
9318
- return _context10.stop();
9412
+ return _context14.stop();
9319
9413
  }
9320
- }, _callee10, null, [[1, 26, 30, 36]]);
9414
+ }, _callee14, null, [[1, 27, 31, 37]]);
9321
9415
  })));
9322
- case 3:
9416
+ case 4:
9323
9417
  case "end":
9324
- return _context11.stop();
9418
+ return _context15.stop();
9325
9419
  }
9326
- }, _callee11);
9420
+ }, _callee15);
9327
9421
  }))();
9328
9422
  },
9329
9423
  /**
9330
9424
  * Will delete artifacts based on the passed `sourcemaps.filesToDeleteAfterUpload` option.
9331
9425
  */
9332
9426
  deleteArtifacts: function deleteArtifacts() {
9333
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
9427
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
9334
9428
  var _options$sourcemaps5, filesToDelete, filePathsToDelete;
9335
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
9336
- while (1) switch (_context12.prev = _context12.next) {
9429
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
9430
+ while (1) switch (_context16.prev = _context16.next) {
9337
9431
  case 0:
9338
- _context12.prev = 0;
9339
- _context12.next = 3;
9432
+ _context16.prev = 0;
9433
+ _context16.next = 3;
9340
9434
  return (_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.filesToDeleteAfterUpload;
9341
9435
  case 3:
9342
- filesToDelete = _context12.sent;
9436
+ filesToDelete = _context16.sent;
9343
9437
  if (!(filesToDelete !== undefined)) {
9344
- _context12.next = 14;
9438
+ _context16.next = 14;
9345
9439
  break;
9346
9440
  }
9347
- _context12.next = 7;
9441
+ _context16.next = 7;
9348
9442
  return glob.glob(filesToDelete, {
9349
9443
  absolute: true,
9350
9444
  nodir: true
9351
9445
  });
9352
9446
  case 7:
9353
- filePathsToDelete = _context12.sent;
9447
+ filePathsToDelete = _context16.sent;
9354
9448
  logger.debug("Waiting for dependencies on generated files to be freed before deleting...");
9355
- _context12.next = 11;
9449
+ _context16.next = 11;
9356
9450
  return waitUntilBuildArtifactDependenciesAreFreed();
9357
9451
  case 11:
9358
9452
  filePathsToDelete.forEach(function (filePathToDelete) {
9359
9453
  logger.debug("Deleting asset after upload: ".concat(filePathToDelete));
9360
9454
  });
9361
- _context12.next = 14;
9455
+ _context16.next = 14;
9362
9456
  return Promise.all(filePathsToDelete.map(function (filePathToDelete) {
9363
9457
  return fs__namespace.promises.rm(filePathToDelete, {
9364
9458
  force: true
@@ -9368,28 +9462,52 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9368
9462
  });
9369
9463
  }));
9370
9464
  case 14:
9371
- _context12.next = 22;
9465
+ _context16.next = 22;
9372
9466
  break;
9373
9467
  case 16:
9374
- _context12.prev = 16;
9375
- _context12.t0 = _context12["catch"](0);
9468
+ _context16.prev = 16;
9469
+ _context16.t0 = _context16["catch"](0);
9376
9470
  sentryScope.captureException('Error in "sentry-file-deletion-plugin" buildEnd hook');
9377
- _context12.next = 21;
9471
+ _context16.next = 21;
9378
9472
  return safeFlushTelemetry(sentryClient);
9379
9473
  case 21:
9380
9474
  // We throw by default if we get here b/c not being able to delete
9381
9475
  // source maps could leak them to production
9382
- handleRecoverableError(_context12.t0, true);
9476
+ handleRecoverableError(_context16.t0, true);
9383
9477
  case 22:
9384
9478
  case "end":
9385
- return _context12.stop();
9479
+ return _context16.stop();
9386
9480
  }
9387
- }, _callee12, null, [[0, 16]]);
9481
+ }, _callee16, null, [[0, 16]]);
9388
9482
  }))();
9389
9483
  },
9390
9484
  createDependencyOnBuildArtifacts: createDependencyOnBuildArtifacts
9391
9485
  };
9392
9486
  }
9487
+ function canUploadSourceMaps(options, logger, isDevMode) {
9488
+ var _options$sourcemaps6;
9489
+ if ((_options$sourcemaps6 = options.sourcemaps) !== null && _options$sourcemaps6 !== void 0 && _options$sourcemaps6.disable) {
9490
+ logger.debug("Source map upload was disabled. Will not upload sourcemaps using debug ID process.");
9491
+ return false;
9492
+ }
9493
+ if (isDevMode) {
9494
+ logger.debug("Running in development mode. Will not upload sourcemaps.");
9495
+ return false;
9496
+ }
9497
+ if (!options.authToken) {
9498
+ logger.warn("No auth token provided. Will not upload source maps. 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"));
9499
+ return false;
9500
+ }
9501
+ if (!options.org && !options.authToken.startsWith("sntrys_")) {
9502
+ logger.warn("No org provided. Will not upload source maps. Please set the `org` option to your Sentry organization slug." + getTurborepoEnvPassthroughWarning("SENTRY_ORG"));
9503
+ return false;
9504
+ }
9505
+ if (!options.project) {
9506
+ logger.warn("No project provided. Will not upload source maps. Please set the `project` option to your Sentry project slug." + getTurborepoEnvPassthroughWarning("SENTRY_PROJECT"));
9507
+ return false;
9508
+ }
9509
+ return true;
9510
+ }
9393
9511
 
9394
9512
  /**
9395
9513
  * Creates an unplugin instance used to create Sentry plugins for Vite, Rollup, esbuild, and Webpack.
@@ -9485,13 +9603,13 @@ function sentryUnpluginFactory(_ref) {
9485
9603
  });
9486
9604
  if (!((_options$sourcemaps = options.sourcemaps) !== null && _options$sourcemaps !== void 0 && _options$sourcemaps.disable)) {
9487
9605
  plugins.push(debugIdInjectionPlugin(logger));
9488
- }
9489
9606
 
9490
- // This option is only strongly typed for the webpack plugin, where it is used. It has no effect on other plugins
9491
- var webpack_forceExitOnBuildComplete = typeof options._experiments["forceExitOnBuildCompletion"] === "boolean" ? options._experiments["forceExitOnBuildCompletion"] : undefined;
9492
- plugins.push(debugIdUploadPlugin(createDebugIdUploadFunction({
9493
- sentryBuildPluginManager: sentryBuildPluginManager
9494
- }), logger, sentryBuildPluginManager.createDependencyOnBuildArtifacts, webpack_forceExitOnBuildComplete));
9607
+ // This option is only strongly typed for the webpack plugin, where it is used. It has no effect on other plugins
9608
+ var _webpack_forceExitOnBuildComplete = typeof options._experiments["forceExitOnBuildCompletion"] === "boolean" ? options._experiments["forceExitOnBuildCompletion"] : undefined;
9609
+ plugins.push(debugIdUploadPlugin(createDebugIdUploadFunction({
9610
+ sentryBuildPluginManager: sentryBuildPluginManager
9611
+ }), logger, sentryBuildPluginManager.createDependencyOnBuildArtifacts, _webpack_forceExitOnBuildComplete));
9612
+ }
9495
9613
  if (options.reactComponentAnnotation) {
9496
9614
  if (!options.reactComponentAnnotation.enabled) {
9497
9615
  logger.debug("The component name annotate plugin is currently disabled. Skipping component name annotations.");
@@ -9525,23 +9643,11 @@ function sentryUnpluginFactory(_ref) {
9525
9643
  }
9526
9644
 
9527
9645
  /**
9528
- * @deprecated
9646
+ * @deprecated This will be removed in v4
9529
9647
  */
9530
- // TODO(v4): Don't export this from the package
9531
- function getBuildInformation() {
9532
- var packageJson = getPackageJson();
9533
- var _ref2 = packageJson ? getDependencies(packageJson) : {
9534
- deps: [],
9535
- depsVersions: {}
9536
- },
9537
- deps = _ref2.deps,
9538
- depsVersions = _ref2.depsVersions;
9539
- return {
9540
- deps: deps,
9541
- depsVersions: depsVersions,
9542
- nodeVersion: parseMajorVersion(process.version)
9543
- };
9544
- }
9648
+ // TODO(v4): Don't export this from the package but keep the utils version
9649
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
9650
+ var getBuildInformation = getBuildInformation$1;
9545
9651
 
9546
9652
  /**
9547
9653
  * Determines whether the Sentry CLI binary is in its expected location.
@@ -9614,6 +9720,13 @@ function createRollupBundleSizeOptimizationHooks(replacementValues) {
9614
9720
  var COMMENT_USE_STRICT_REGEX =
9615
9721
  // Note: CodeQL complains that this regex potentially has n^2 runtime. This likely won't affect realistic files.
9616
9722
  /^(?:\s*|\/\*(?:.|\r|\n)*?\*\/|\/\/.*[\n\r])*(?:"[^"]*";|'[^']*';)?/;
9723
+
9724
+ /**
9725
+ * Simplified `renderChunk` hook type from Rollup.
9726
+ * We can't reference the type directly because the Vite plugin complains
9727
+ * about type mismatches
9728
+ */
9729
+
9617
9730
  function createRollupDebugIdInjectionHooks() {
9618
9731
  return {
9619
9732
  renderChunk: function renderChunk(code, chunk) {