@sentry/bundler-plugin-core 2.21.0 → 2.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -13659,7 +13659,7 @@ function createSentryInstance(options, shouldSendTelemetry, bundler) {
13659
13659
  dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
13660
13660
  tracesSampleRate: 1,
13661
13661
  sampleRate: 1,
13662
- release: "2.21.0",
13662
+ release: "2.21.1",
13663
13663
  integrations: [],
13664
13664
  tracePropagationTargets: ["sentry.io/api"],
13665
13665
  stackParser: defaultStackParser,
@@ -13863,23 +13863,27 @@ function createDebugIdUploadFunction(_ref) {
13863
13863
  sentryClient = _ref.sentryClient,
13864
13864
  sentryCliOptions = _ref.sentryCliOptions,
13865
13865
  rewriteSourcesHook = _ref.rewriteSourcesHook,
13866
- freeDependencyOnSourcemapFiles = _ref.freeDependencyOnSourcemapFiles;
13866
+ createDependencyOnSourcemapFiles = _ref.createDependencyOnSourcemapFiles;
13867
+ var freeGlobalDependencyOnSourcemapFiles = createDependencyOnSourcemapFiles();
13867
13868
  return /*#__PURE__*/function () {
13868
13869
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(buildArtifactPaths) {
13869
- var artifactBundleUploadTransaction, folderToCleanUp, mkdtempSpan, tmpUploadFolder, globAssets, globSpan, globResult, debugIdChunkFilePaths, prepareSpan, preparationTasks, workers, worker, workerIndex, files, stats, uploadSize, uploadSpan, cliInstance, cleanupSpan;
13870
+ var artifactBundleUploadTransaction, folderToCleanUp, freeUploadDependencyOnSourcemapFiles, mkdtempSpan, tmpUploadFolder, globAssets, globSpan, globResult, debugIdChunkFilePaths, prepareSpan, preparationTasks, workers, worker, workerIndex, files, stats, uploadSize, uploadSpan, cliInstance, cleanupSpan;
13870
13871
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
13871
13872
  while (1) switch (_context3.prev = _context3.next) {
13872
13873
  case 0:
13873
13874
  artifactBundleUploadTransaction = sentryHub.startTransaction({
13874
13875
  name: "debug-id-sourcemap-upload"
13875
13876
  });
13876
- _context3.prev = 1;
13877
+ // 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`)
13878
+ // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.
13879
+ freeUploadDependencyOnSourcemapFiles = createDependencyOnSourcemapFiles();
13880
+ _context3.prev = 2;
13877
13881
  mkdtempSpan = artifactBundleUploadTransaction.startChild({
13878
13882
  description: "mkdtemp"
13879
13883
  });
13880
- _context3.next = 5;
13884
+ _context3.next = 6;
13881
13885
  return fs__default["default"].promises.mkdtemp(path__default["default"].join(os__default["default"].tmpdir(), "sentry-bundler-plugin-upload-"));
13882
- case 5:
13886
+ case 6:
13883
13887
  tmpUploadFolder = _context3.sent;
13884
13888
  mkdtempSpan.finish();
13885
13889
  folderToCleanUp = tmpUploadFolder;
@@ -13892,13 +13896,13 @@ function createDebugIdUploadFunction(_ref) {
13892
13896
  globSpan = artifactBundleUploadTransaction.startChild({
13893
13897
  description: "glob"
13894
13898
  });
13895
- _context3.next = 12;
13899
+ _context3.next = 13;
13896
13900
  return glob.glob(globAssets, {
13897
13901
  absolute: true,
13898
13902
  nodir: true,
13899
13903
  ignore: ignore
13900
13904
  });
13901
- case 12:
13905
+ case 13:
13902
13906
  globResult = _context3.sent;
13903
13907
  globSpan.finish();
13904
13908
  debugIdChunkFilePaths = globResult.filter(function (debugIdChunkFilePath) {
@@ -13907,21 +13911,21 @@ function createDebugIdUploadFunction(_ref) {
13907
13911
  // Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent
13908
13912
  debugIdChunkFilePaths.sort();
13909
13913
  if (!(Array.isArray(assets) && assets.length === 0)) {
13910
- _context3.next = 20;
13914
+ _context3.next = 21;
13911
13915
  break;
13912
13916
  }
13913
13917
  logger.debug("Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.");
13914
- _context3.next = 47;
13918
+ _context3.next = 48;
13915
13919
  break;
13916
- case 20:
13920
+ case 21:
13917
13921
  if (!(debugIdChunkFilePaths.length === 0)) {
13918
- _context3.next = 24;
13922
+ _context3.next = 25;
13919
13923
  break;
13920
13924
  }
13921
13925
  logger.warn("Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.");
13922
- _context3.next = 47;
13926
+ _context3.next = 48;
13923
13927
  break;
13924
- case 24:
13928
+ case 25:
13925
13929
  prepareSpan = artifactBundleUploadTransaction.startChild({
13926
13930
  description: "prepare-bundles"
13927
13931
  }); // Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so
@@ -13974,20 +13978,20 @@ function createDebugIdUploadFunction(_ref) {
13974
13978
  for (workerIndex = 0; workerIndex < 16; workerIndex++) {
13975
13979
  workers.push(worker());
13976
13980
  }
13977
- _context3.next = 31;
13981
+ _context3.next = 32;
13978
13982
  return Promise.all(workers);
13979
- case 31:
13983
+ case 32:
13980
13984
  prepareSpan.finish();
13981
- _context3.next = 34;
13985
+ _context3.next = 35;
13982
13986
  return fs__default["default"].promises.readdir(tmpUploadFolder);
13983
- case 34:
13987
+ case 35:
13984
13988
  files = _context3.sent;
13985
13989
  stats = files.map(function (file) {
13986
13990
  return fs__default["default"].promises.stat(path__default["default"].join(tmpUploadFolder, file));
13987
13991
  });
13988
- _context3.next = 38;
13992
+ _context3.next = 39;
13989
13993
  return Promise.all(stats);
13990
- case 38:
13994
+ case 39:
13991
13995
  uploadSize = _context3.sent.reduce(function (accumulator, _ref5) {
13992
13996
  var size = _ref5.size;
13993
13997
  return accumulator + size;
@@ -14004,7 +14008,7 @@ function createDebugIdUploadFunction(_ref) {
14004
14008
  baggage: dynamicSamplingContextToSentryBaggageHeader(artifactBundleUploadTransaction.getDynamicSamplingContext())
14005
14009
  }, sentryCliOptions.headers)
14006
14010
  }));
14007
- _context3.next = 45;
14011
+ _context3.next = 46;
14008
14012
  return cliInstance.releases.uploadSourceMaps(releaseName !== null && releaseName !== void 0 ? releaseName : "undefined",
14009
14013
  // unfortunetly this needs a value for now but it will not matter since debug IDs overpower releases anyhow
14010
14014
  {
@@ -14015,22 +14019,22 @@ function createDebugIdUploadFunction(_ref) {
14015
14019
  }],
14016
14020
  useArtifactBundle: true
14017
14021
  });
14018
- case 45:
14022
+ case 46:
14019
14023
  uploadSpan.finish();
14020
14024
  logger.info("Successfully uploaded source maps to Sentry");
14021
- case 47:
14022
- _context3.next = 53;
14025
+ case 48:
14026
+ _context3.next = 54;
14023
14027
  break;
14024
- case 49:
14025
- _context3.prev = 49;
14026
- _context3.t0 = _context3["catch"](1);
14028
+ case 50:
14029
+ _context3.prev = 50;
14030
+ _context3.t0 = _context3["catch"](2);
14027
14031
  sentryHub.withScope(function (scope) {
14028
14032
  scope.setSpan(artifactBundleUploadTransaction);
14029
14033
  sentryHub.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
14030
14034
  });
14031
14035
  handleRecoverableError(_context3.t0);
14032
- case 53:
14033
- _context3.prev = 53;
14036
+ case 54:
14037
+ _context3.prev = 54;
14034
14038
  if (folderToCleanUp) {
14035
14039
  cleanupSpan = artifactBundleUploadTransaction.startChild({
14036
14040
  description: "cleanup"
@@ -14042,16 +14046,17 @@ function createDebugIdUploadFunction(_ref) {
14042
14046
  cleanupSpan.finish();
14043
14047
  }
14044
14048
  artifactBundleUploadTransaction.finish();
14045
- freeDependencyOnSourcemapFiles();
14046
- _context3.next = 59;
14049
+ freeGlobalDependencyOnSourcemapFiles();
14050
+ freeUploadDependencyOnSourcemapFiles();
14051
+ _context3.next = 61;
14047
14052
  return safeFlushTelemetry(sentryClient);
14048
- case 59:
14049
- return _context3.finish(53);
14050
- case 60:
14053
+ case 61:
14054
+ return _context3.finish(54);
14055
+ case 62:
14051
14056
  case "end":
14052
14057
  return _context3.stop();
14053
14058
  }
14054
- }, _callee3, null, [[1, 49, 53, 60]]);
14059
+ }, _callee3, null, [[2, 50, 54, 62]]);
14055
14060
  }));
14056
14061
  return function (_x) {
14057
14062
  return _ref2.apply(this, arguments);
@@ -14298,26 +14303,30 @@ function releaseManagementPlugin(_ref) {
14298
14303
  sentryHub = _ref.sentryHub,
14299
14304
  sentryClient = _ref.sentryClient,
14300
14305
  sentryCliOptions = _ref.sentryCliOptions,
14301
- freeDependencyOnSourcemapFiles = _ref.freeDependencyOnSourcemapFiles;
14306
+ createDependencyOnSourcemapFiles = _ref.createDependencyOnSourcemapFiles;
14307
+ var freeGlobalDependencyOnSourcemapFiles = createDependencyOnSourcemapFiles();
14302
14308
  return {
14303
14309
  name: "sentry-debug-id-upload-plugin",
14304
14310
  writeBundle: function writeBundle() {
14305
14311
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
14306
- var cliInstance, normalizedInclude;
14312
+ var freeWriteBundleInvocationDependencyOnSourcemapFiles, cliInstance, normalizedInclude;
14307
14313
  return _regeneratorRuntime().wrap(function _callee$(_context) {
14308
14314
  while (1) switch (_context.prev = _context.next) {
14309
14315
  case 0:
14310
- _context.prev = 0;
14316
+ // 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`)
14317
+ // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.
14318
+ freeWriteBundleInvocationDependencyOnSourcemapFiles = createDependencyOnSourcemapFiles();
14319
+ _context.prev = 1;
14311
14320
  cliInstance = new SentryCli__default["default"](null, sentryCliOptions);
14312
14321
  if (!shouldCreateRelease) {
14313
- _context.next = 5;
14322
+ _context.next = 6;
14314
14323
  break;
14315
14324
  }
14316
- _context.next = 5;
14325
+ _context.next = 6;
14317
14326
  return cliInstance.releases["new"](releaseName);
14318
- case 5:
14327
+ case 6:
14319
14328
  if (!include) {
14320
- _context.next = 9;
14329
+ _context.next = 10;
14321
14330
  break;
14322
14331
  }
14323
14332
  normalizedInclude = arrayify$1(include).map(function (includeItem) {
@@ -14334,52 +14343,53 @@ function releaseManagementPlugin(_ref) {
14334
14343
  ignore: includeEntry.ignore ? arrayify$1(includeEntry.ignore) : undefined
14335
14344
  });
14336
14345
  });
14337
- _context.next = 9;
14346
+ _context.next = 10;
14338
14347
  return cliInstance.releases.uploadSourceMaps(releaseName, {
14339
14348
  include: normalizedInclude,
14340
14349
  dist: dist
14341
14350
  });
14342
- case 9:
14351
+ case 10:
14343
14352
  if (!setCommitsOption) {
14344
- _context.next = 12;
14353
+ _context.next = 13;
14345
14354
  break;
14346
14355
  }
14347
- _context.next = 12;
14356
+ _context.next = 13;
14348
14357
  return cliInstance.releases.setCommits(releaseName, setCommitsOption);
14349
- case 12:
14358
+ case 13:
14350
14359
  if (!shouldFinalizeRelease) {
14351
- _context.next = 15;
14360
+ _context.next = 16;
14352
14361
  break;
14353
14362
  }
14354
- _context.next = 15;
14363
+ _context.next = 16;
14355
14364
  return cliInstance.releases.finalize(releaseName);
14356
- case 15:
14365
+ case 16:
14357
14366
  if (!deployOptions) {
14358
- _context.next = 18;
14367
+ _context.next = 19;
14359
14368
  break;
14360
14369
  }
14361
- _context.next = 18;
14370
+ _context.next = 19;
14362
14371
  return cliInstance.releases.newDeploy(releaseName, deployOptions);
14363
- case 18:
14364
- _context.next = 26;
14372
+ case 19:
14373
+ _context.next = 27;
14365
14374
  break;
14366
- case 20:
14367
- _context.prev = 20;
14368
- _context.t0 = _context["catch"](0);
14375
+ case 21:
14376
+ _context.prev = 21;
14377
+ _context.t0 = _context["catch"](1);
14369
14378
  sentryHub.captureException('Error in "releaseManagementPlugin" writeBundle hook');
14370
- _context.next = 25;
14379
+ _context.next = 26;
14371
14380
  return safeFlushTelemetry(sentryClient);
14372
- case 25:
14373
- handleRecoverableError(_context.t0);
14374
14381
  case 26:
14375
- _context.prev = 26;
14376
- freeDependencyOnSourcemapFiles();
14377
- return _context.finish(26);
14378
- case 29:
14382
+ handleRecoverableError(_context.t0);
14383
+ case 27:
14384
+ _context.prev = 27;
14385
+ freeGlobalDependencyOnSourcemapFiles();
14386
+ freeWriteBundleInvocationDependencyOnSourcemapFiles();
14387
+ return _context.finish(27);
14388
+ case 31:
14379
14389
  case "end":
14380
14390
  return _context.stop();
14381
14391
  }
14382
- }, _callee, null, [[0, 20, 26, 29]]);
14392
+ }, _callee, null, [[1, 21, 27, 31]]);
14383
14393
  }))();
14384
14394
  }
14385
14395
  };
@@ -14470,73 +14480,62 @@ function fileDeletionPlugin(_ref) {
14470
14480
  sentryHub = _ref.sentryHub,
14471
14481
  sentryClient = _ref.sentryClient,
14472
14482
  filesToDeleteAfterUpload = _ref.filesToDeleteAfterUpload,
14473
- dependenciesAreFreedPromise = _ref.dependenciesAreFreedPromise,
14483
+ waitUntilSourcemapFileDependenciesAreFreed = _ref.waitUntilSourcemapFileDependenciesAreFreed,
14474
14484
  logger = _ref.logger;
14475
- var writeBundle = /*#__PURE__*/function () {
14476
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
14477
- var filePathsToDelete;
14478
- return _regeneratorRuntime().wrap(function _callee$(_context) {
14479
- while (1) switch (_context.prev = _context.next) {
14480
- case 0:
14481
- _context.prev = 0;
14482
- if (!(filesToDeleteAfterUpload !== undefined)) {
14483
- _context.next = 11;
14484
- break;
14485
- }
14486
- _context.next = 4;
14487
- return glob.glob(filesToDeleteAfterUpload, {
14488
- absolute: true,
14489
- nodir: true
14490
- });
14491
- case 4:
14492
- filePathsToDelete = _context.sent;
14493
- logger.debug("Waiting for dependencies on generated files to be freed before deleting...");
14494
- _context.next = 8;
14495
- return dependenciesAreFreedPromise;
14496
- case 8:
14497
- filePathsToDelete.forEach(function (filePathToDelete) {
14498
- logger.debug("Deleting asset after upload: ".concat(filePathToDelete));
14499
- });
14500
- _context.next = 11;
14501
- return Promise.all(filePathsToDelete.map(function (filePathToDelete) {
14502
- return fs__default["default"].promises.rm(filePathToDelete, {
14503
- force: true
14504
- })["catch"](function (e) {
14505
- // This is allowed to fail - we just don't do anything
14506
- logger.debug("An error occurred while attempting to delete asset: ".concat(filePathToDelete), e);
14507
- });
14508
- }));
14509
- case 11:
14510
- _context.next = 19;
14511
- break;
14512
- case 13:
14513
- _context.prev = 13;
14514
- _context.t0 = _context["catch"](0);
14515
- sentryHub.captureException('Error in "sentry-file-deletion-plugin" buildEnd hook');
14516
- _context.next = 18;
14517
- return safeFlushTelemetry(sentryClient);
14518
- case 18:
14519
- handleRecoverableError(_context.t0);
14520
- case 19:
14521
- case "end":
14522
- return _context.stop();
14523
- }
14524
- }, _callee, null, [[0, 13]]);
14525
- }));
14526
- return function writeBundle() {
14527
- return _ref2.apply(this, arguments);
14528
- };
14529
- }();
14530
14485
  return {
14531
14486
  name: "sentry-file-deletion-plugin",
14532
- vite: {
14533
- writeBundle: {
14534
- sequential: true,
14535
- order: "post",
14536
- handler: writeBundle
14537
- }
14538
- },
14539
- writeBundle: writeBundle
14487
+ writeBundle: function writeBundle() {
14488
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
14489
+ var filePathsToDelete;
14490
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
14491
+ while (1) switch (_context.prev = _context.next) {
14492
+ case 0:
14493
+ _context.prev = 0;
14494
+ if (!(filesToDeleteAfterUpload !== undefined)) {
14495
+ _context.next = 11;
14496
+ break;
14497
+ }
14498
+ _context.next = 4;
14499
+ return glob.glob(filesToDeleteAfterUpload, {
14500
+ absolute: true,
14501
+ nodir: true
14502
+ });
14503
+ case 4:
14504
+ filePathsToDelete = _context.sent;
14505
+ logger.debug("Waiting for dependencies on generated files to be freed before deleting...");
14506
+ _context.next = 8;
14507
+ return waitUntilSourcemapFileDependenciesAreFreed();
14508
+ case 8:
14509
+ filePathsToDelete.forEach(function (filePathToDelete) {
14510
+ logger.debug("Deleting asset after upload: ".concat(filePathToDelete));
14511
+ });
14512
+ _context.next = 11;
14513
+ return Promise.all(filePathsToDelete.map(function (filePathToDelete) {
14514
+ return fs__default["default"].promises.rm(filePathToDelete, {
14515
+ force: true
14516
+ })["catch"](function (e) {
14517
+ // This is allowed to fail - we just don't do anything
14518
+ logger.debug("An error occurred while attempting to delete asset: ".concat(filePathToDelete), e);
14519
+ });
14520
+ }));
14521
+ case 11:
14522
+ _context.next = 19;
14523
+ break;
14524
+ case 13:
14525
+ _context.prev = 13;
14526
+ _context.t0 = _context["catch"](0);
14527
+ sentryHub.captureException('Error in "sentry-file-deletion-plugin" buildEnd hook');
14528
+ _context.next = 18;
14529
+ return safeFlushTelemetry(sentryClient);
14530
+ case 18:
14531
+ handleRecoverableError(_context.t0);
14532
+ case 19:
14533
+ case "end":
14534
+ return _context.stop();
14535
+ }
14536
+ }, _callee, null, [[0, 13]]);
14537
+ }))();
14538
+ }
14540
14539
  };
14541
14540
  }
14542
14541
 
@@ -14624,7 +14623,7 @@ function sentryUnpluginFactory(_ref) {
14624
14623
  });
14625
14624
 
14626
14625
  // Set the User-Agent that Sentry CLI will use when interacting with Sentry
14627
- process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.21.0");
14626
+ process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.21.1");
14628
14627
  function handleRecoverableError(unknownError) {
14629
14628
  sentrySession.status = "abnormal";
14630
14629
  try {
@@ -14685,6 +14684,9 @@ function sentryUnpluginFactory(_ref) {
14685
14684
 
14686
14685
  /**
14687
14686
  * Returns a Promise that resolves when all the currently active dependencies are freed again.
14687
+ *
14688
+ * It is very important that this function is called as late as possible before wanting to await the Promise to give
14689
+ * the dependency producers as much time as possible to register themselves.
14688
14690
  */
14689
14691
  function waitUntilSourcemapFileDependenciesAreFreed() {
14690
14692
  return new Promise(function (resolve) {
@@ -14792,7 +14794,7 @@ function sentryUnpluginFactory(_ref) {
14792
14794
  vcsRemote: options.release.vcsRemote,
14793
14795
  headers: options.headers
14794
14796
  },
14795
- freeDependencyOnSourcemapFiles: createDependencyOnSourcemapFiles()
14797
+ createDependencyOnSourcemapFiles: createDependencyOnSourcemapFiles
14796
14798
  }));
14797
14799
  }
14798
14800
  plugins.push(debugIdInjectionPlugin(logger));
@@ -14807,7 +14809,7 @@ function sentryUnpluginFactory(_ref) {
14807
14809
  plugins.push(debugIdUploadPlugin(createDebugIdUploadFunction({
14808
14810
  assets: (_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.assets,
14809
14811
  ignore: (_options$sourcemaps3 = options.sourcemaps) === null || _options$sourcemaps3 === void 0 ? void 0 : _options$sourcemaps3.ignore,
14810
- freeDependencyOnSourcemapFiles: createDependencyOnSourcemapFiles(),
14812
+ createDependencyOnSourcemapFiles: createDependencyOnSourcemapFiles,
14811
14813
  dist: options.release.dist,
14812
14814
  releaseName: options.release.name,
14813
14815
  logger: logger,
@@ -14836,9 +14838,7 @@ function sentryUnpluginFactory(_ref) {
14836
14838
  }
14837
14839
  }
14838
14840
  plugins.push(fileDeletionPlugin({
14839
- // It is very important that this is only called after all other dependencies have been created with `createDependencyOnSourcemapFiles`.
14840
- // Ideally, we always register this plugin last.
14841
- dependenciesAreFreedPromise: waitUntilSourcemapFileDependenciesAreFreed(),
14841
+ waitUntilSourcemapFileDependenciesAreFreed: waitUntilSourcemapFileDependenciesAreFreed,
14842
14842
  filesToDeleteAfterUpload: (_options$sourcemaps$f = (_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.filesToDeleteAfterUpload) !== null && _options$sourcemaps$f !== void 0 ? _options$sourcemaps$f : (_options$sourcemaps6 = options.sourcemaps) === null || _options$sourcemaps6 === void 0 ? void 0 : _options$sourcemaps6.deleteFilesAfterUpload,
14843
14843
  logger: logger,
14844
14844
  handleRecoverableError: handleRecoverableError,