@sentry/bundler-plugin-core 4.2.0 → 4.4.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
@@ -8102,7 +8102,7 @@ function normalizeUserOptions(userOptions) {
8102
8102
  * @returns `true` if the options are valid, `false` otherwise
8103
8103
  */
8104
8104
  function validateOptions(options, logger) {
8105
- var _options$release, _options$release2, _options$release3;
8105
+ var _options$release, _options$release2;
8106
8106
  var setCommits = (_options$release = options.release) === null || _options$release === void 0 ? void 0 : _options$release.setCommits;
8107
8107
  if (setCommits) {
8108
8108
  if (!setCommits.auto && !(setCommits.repo && setCommits.commit)) {
@@ -8113,7 +8113,7 @@ function validateOptions(options, logger) {
8113
8113
  logger.warn("The `setCommits` options includes `auto` but also `repo` and `commit`.", "Ignoring `repo` and `commit`.", "Please only set either `auto` or both, `repo` and `commit`.");
8114
8114
  }
8115
8115
  }
8116
- if ((_options$release2 = options.release) !== null && _options$release2 !== void 0 && _options$release2.deploy && !((_options$release3 = options.release) !== null && _options$release3 !== void 0 && _options$release3.deploy.env)) {
8116
+ if ((_options$release2 = options.release) !== null && _options$release2 !== void 0 && _options$release2.deploy && _typeof(options.release.deploy) === "object" && !options.release.deploy.env) {
8117
8117
  logger.error("The `deploy` option was specified but is missing the required `env` property.", "Please set the `env` property.");
8118
8118
  return false;
8119
8119
  }
@@ -8307,7 +8307,7 @@ function createSentryInstance(options, shouldSendTelemetry, buildTool) {
8307
8307
  dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
8308
8308
  tracesSampleRate: 1,
8309
8309
  sampleRate: 1,
8310
- release: "4.2.0",
8310
+ release: "4.4.0",
8311
8311
  integrations: [],
8312
8312
  tracePropagationTargets: ["sentry.io/api"],
8313
8313
  stackParser: stackParser,
@@ -8475,12 +8475,16 @@ function createDebugIdUploadFunction(_ref) {
8475
8475
  var sentryBuildPluginManager = _ref.sentryBuildPluginManager;
8476
8476
  return /*#__PURE__*/function () {
8477
8477
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(buildArtifactPaths) {
8478
+ var cleanedPaths;
8478
8479
  return _regeneratorRuntime().wrap(function _callee$(_context) {
8479
8480
  while (1) switch (_context.prev = _context.next) {
8480
8481
  case 0:
8481
- _context.next = 2;
8482
- return sentryBuildPluginManager.uploadSourcemaps(buildArtifactPaths);
8483
- case 2:
8482
+ // Webpack and perhaps other bundlers allow you to append query strings to
8483
+ // filenames for cache busting purposes. We should strip these before upload.
8484
+ cleanedPaths = buildArtifactPaths.map(stripQueryAndHashFromPath);
8485
+ _context.next = 3;
8486
+ return sentryBuildPluginManager.uploadSourcemaps(cleanedPaths);
8487
+ case 3:
8484
8488
  case "end":
8485
8489
  return _context.stop();
8486
8490
  }
@@ -8910,7 +8914,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8910
8914
  });
8911
8915
 
8912
8916
  // Set the User-Agent that Sentry CLI will use when interacting with Sentry
8913
- process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.2.0");
8917
+ process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.4.0");
8914
8918
 
8915
8919
  // Not a bulletproof check but should be good enough to at least sometimes determine
8916
8920
  // if the plugin is called in dev/watch mode or for a prod build. The important part
@@ -9313,6 +9317,8 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9313
9317
  */
9314
9318
  uploadSourcemaps: function uploadSourcemaps(buildArtifactPaths, opts) {
9315
9319
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
9320
+ var _options$sourcemaps;
9321
+ var assets;
9316
9322
  return _regeneratorRuntime().wrap(function _callee19$(_context19) {
9317
9323
  while (1) switch (_context19.prev = _context19.next) {
9318
9324
  case 0:
@@ -9322,7 +9328,16 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9322
9328
  }
9323
9329
  return _context19.abrupt("return");
9324
9330
  case 2:
9325
- _context19.next = 4;
9331
+ // Early exit if assets is explicitly set to an empty array
9332
+ assets = (_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.assets;
9333
+ if (!(Array.isArray(assets) && assets.length === 0)) {
9334
+ _context19.next = 6;
9335
+ break;
9336
+ }
9337
+ logger.debug("Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.");
9338
+ return _context19.abrupt("return");
9339
+ case 6:
9340
+ _context19.next = 8;
9326
9341
  return startSpan(
9327
9342
  // This is `forceTransaction`ed because this span is used in dashboards in the form of indexed transactions.
9328
9343
  {
@@ -9331,7 +9346,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9331
9346
  forceTransaction: true
9332
9347
  }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
9333
9348
  var _opts$prepareArtifact;
9334
- var shouldPrepare, folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps, assets, globAssets, globResult, debugIdChunkFilePaths, tmpUploadFolder, _process$env2;
9349
+ var shouldPrepare, folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps2, _options$sourcemaps3, _options$sourcemaps4, _options$sourcemaps5, pathsToUpload, ignorePaths, globAssets, globResult, debugIdChunkFilePaths, tmpUploadFolder, _process$env2;
9335
9350
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
9336
9351
  while (1) switch (_context18.prev = _context18.next) {
9337
9352
  case 0:
@@ -9341,96 +9356,100 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9341
9356
  // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.
9342
9357
  freeUploadDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
9343
9358
  _context18.prev = 2;
9344
- assets = (_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.assets;
9359
+ if (shouldPrepare) {
9360
+ _context18.next = 11;
9361
+ break;
9362
+ }
9363
+ // Direct CLI upload from existing artifact paths (no globbing, no preparation)
9364
+
9345
9365
  if (assets) {
9346
- globAssets = assets;
9366
+ pathsToUpload = Array.isArray(assets) ? assets : [assets];
9367
+ logger.debug("Direct upload mode: passing user-provided assets directly to CLI: ".concat(pathsToUpload.join(", ")));
9347
9368
  } else {
9348
- logger.debug("No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.");
9349
- globAssets = buildArtifactPaths;
9369
+ // Use original paths e.g. like ['.next/server'] directly –> preferred way when no globbing is done
9370
+ pathsToUpload = buildArtifactPaths;
9350
9371
  }
9351
- _context18.next = 7;
9372
+ ignorePaths = (_options$sourcemaps2 = options.sourcemaps) !== null && _options$sourcemaps2 !== void 0 && _options$sourcemaps2.ignore ? Array.isArray((_options$sourcemaps3 = options.sourcemaps) === null || _options$sourcemaps3 === void 0 ? void 0 : _options$sourcemaps3.ignore) ? (_options$sourcemaps4 = options.sourcemaps) === null || _options$sourcemaps4 === void 0 ? void 0 : _options$sourcemaps4.ignore : [(_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.ignore] : [];
9373
+ _context18.next = 8;
9352
9374
  return startSpan({
9353
- name: "glob",
9375
+ name: "upload",
9354
9376
  scope: sentryScope
9355
9377
  }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
9356
- var _options$sourcemaps2;
9378
+ var _options$release$name;
9379
+ var cliInstance;
9357
9380
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
9358
9381
  while (1) switch (_context10.prev = _context10.next) {
9359
9382
  case 0:
9360
- _context10.next = 2;
9361
- return glob.glob(globAssets, {
9362
- absolute: true,
9363
- // If we do not use a temp folder, we allow directories and files; CLI will traverse as needed when given paths.
9364
- nodir: shouldPrepare,
9365
- ignore: (_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.ignore
9383
+ cliInstance = createCliInstance(options);
9384
+ _context10.next = 3;
9385
+ return cliInstance.releases.uploadSourceMaps((_options$release$name = options.release.name) !== null && _options$release$name !== void 0 ? _options$release$name : "undefined", {
9386
+ include: [{
9387
+ paths: pathsToUpload,
9388
+ rewrite: true,
9389
+ dist: options.release.dist
9390
+ }],
9391
+ ignore: ignorePaths,
9392
+ live: "rejectOnError"
9366
9393
  });
9367
- case 2:
9368
- return _context10.abrupt("return", _context10.sent);
9369
9394
  case 3:
9370
9395
  case "end":
9371
9396
  return _context10.stop();
9372
9397
  }
9373
9398
  }, _callee10);
9374
9399
  })));
9375
- case 7:
9376
- globResult = _context18.sent;
9377
- debugIdChunkFilePaths = shouldPrepare ? globResult.filter(function (debugIdChunkFilePath) {
9378
- return !!stripQueryAndHashFromPath(debugIdChunkFilePath).match(/\.(js|mjs|cjs)$/);
9379
- }) : globResult; // The order of the files output by glob() is not deterministic
9380
- // Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent
9381
- debugIdChunkFilePaths.sort();
9382
- if (!(Array.isArray(assets) && assets.length === 0)) {
9383
- _context18.next = 14;
9384
- break;
9385
- }
9386
- logger.debug("Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.");
9387
- _context18.next = 31;
9388
- break;
9389
- case 14:
9390
- if (!(debugIdChunkFilePaths.length === 0)) {
9391
- _context18.next = 18;
9392
- break;
9393
- }
9394
- logger.warn("Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.");
9395
- _context18.next = 31;
9400
+ case 8:
9401
+ logger.info("Successfully uploaded source maps to Sentry");
9402
+ _context18.next = 28;
9396
9403
  break;
9397
- case 18:
9398
- if (shouldPrepare) {
9399
- _context18.next = 24;
9400
- break;
9404
+ case 11:
9405
+ // Prepare artifacts in temp folder before uploading
9406
+
9407
+ if (assets) {
9408
+ globAssets = assets;
9409
+ } else {
9410
+ logger.debug("No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.");
9411
+ globAssets = buildArtifactPaths;
9401
9412
  }
9402
- _context18.next = 21;
9413
+ _context18.next = 14;
9403
9414
  return startSpan({
9404
- name: "upload",
9415
+ name: "glob",
9405
9416
  scope: sentryScope
9406
9417
  }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
9407
- var _options$release$name;
9408
- var cliInstance;
9418
+ var _options$sourcemaps6;
9409
9419
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
9410
9420
  while (1) switch (_context11.prev = _context11.next) {
9411
9421
  case 0:
9412
- cliInstance = createCliInstance(options);
9413
- _context11.next = 3;
9414
- return cliInstance.releases.uploadSourceMaps((_options$release$name = options.release.name) !== null && _options$release$name !== void 0 ? _options$release$name : "undefined", {
9415
- include: [{
9416
- paths: debugIdChunkFilePaths,
9417
- rewrite: false,
9418
- dist: options.release.dist
9419
- }],
9420
- live: "rejectOnError"
9422
+ _context11.next = 2;
9423
+ return glob.glob(globAssets, {
9424
+ absolute: true,
9425
+ nodir: true,
9426
+ // We need individual files for preparation
9427
+ ignore: (_options$sourcemaps6 = options.sourcemaps) === null || _options$sourcemaps6 === void 0 ? void 0 : _options$sourcemaps6.ignore
9421
9428
  });
9429
+ case 2:
9430
+ return _context11.abrupt("return", _context11.sent);
9422
9431
  case 3:
9423
9432
  case "end":
9424
9433
  return _context11.stop();
9425
9434
  }
9426
9435
  }, _callee11);
9427
9436
  })));
9428
- case 21:
9429
- logger.info("Successfully uploaded source maps to Sentry");
9430
- _context18.next = 31;
9437
+ case 14:
9438
+ globResult = _context18.sent;
9439
+ debugIdChunkFilePaths = globResult.filter(function (debugIdChunkFilePath) {
9440
+ return !!stripQueryAndHashFromPath(debugIdChunkFilePath).match(/\.(js|mjs|cjs)$/);
9441
+ }); // The order of the files output by glob() is not deterministic
9442
+ // Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent
9443
+ debugIdChunkFilePaths.sort();
9444
+ if (!(debugIdChunkFilePaths.length === 0)) {
9445
+ _context18.next = 21;
9446
+ break;
9447
+ }
9448
+ logger.warn("Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.");
9449
+ _context18.next = 28;
9431
9450
  break;
9432
- case 24:
9433
- _context18.next = 26;
9451
+ case 21:
9452
+ _context18.next = 23;
9434
9453
  return startSpan({
9435
9454
  name: "mkdtemp",
9436
9455
  scope: sentryScope
@@ -9456,12 +9475,12 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9456
9475
  }
9457
9476
  }, _callee12);
9458
9477
  })));
9459
- case 26:
9478
+ case 23:
9460
9479
  tmpUploadFolder = _context18.sent;
9461
9480
  folderToCleanUp = tmpUploadFolder;
9462
9481
 
9463
9482
  // Prepare into temp folder, then upload
9464
- _context18.next = 30;
9483
+ _context18.next = 27;
9465
9484
  return startSpan({
9466
9485
  name: "prepare-bundles",
9467
9486
  scope: sentryScope
@@ -9475,12 +9494,12 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9475
9494
  // instead we do it with a maximum of 16 concurrent workers
9476
9495
  preparationTasks = debugIdChunkFilePaths.map(function (chunkFilePath, chunkIndex) {
9477
9496
  return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
9478
- var _options$sourcemaps$r, _options$sourcemaps3, _options$sourcemaps4;
9497
+ var _options$sourcemaps$r, _options$sourcemaps7, _options$sourcemaps8;
9479
9498
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
9480
9499
  while (1) switch (_context13.prev = _context13.next) {
9481
9500
  case 0:
9482
9501
  _context13.next = 2;
9483
- 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);
9502
+ return prepareBundleForDebugIdUpload(chunkFilePath, tmpUploadFolder, chunkIndex, logger, (_options$sourcemaps$r = (_options$sourcemaps7 = options.sourcemaps) === null || _options$sourcemaps7 === void 0 ? void 0 : _options$sourcemaps7.rewriteSources) !== null && _options$sourcemaps$r !== void 0 ? _options$sourcemaps$r : defaultRewriteSourcesHook, (_options$sourcemaps8 = options.sourcemaps) === null || _options$sourcemaps8 === void 0 ? void 0 : _options$sourcemaps8.resolveSourceMap);
9484
9503
  case 2:
9485
9504
  case "end":
9486
9505
  return _context13.stop();
@@ -9577,18 +9596,18 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9577
9596
  return _ref6.apply(this, arguments);
9578
9597
  };
9579
9598
  }());
9580
- case 30:
9599
+ case 27:
9581
9600
  logger.info("Successfully uploaded source maps to Sentry");
9582
- case 31:
9583
- _context18.next = 37;
9601
+ case 28:
9602
+ _context18.next = 34;
9584
9603
  break;
9585
- case 33:
9586
- _context18.prev = 33;
9604
+ case 30:
9605
+ _context18.prev = 30;
9587
9606
  _context18.t0 = _context18["catch"](2);
9588
9607
  sentryScope.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
9589
9608
  handleRecoverableError(_context18.t0, false);
9590
- case 37:
9591
- _context18.prev = 37;
9609
+ case 34:
9610
+ _context18.prev = 34;
9592
9611
  if (folderToCleanUp && !((_process$env2 = process.env) !== null && _process$env2 !== void 0 && _process$env2["SENTRY_TEST_OVERRIDE_TEMP_DIR"])) {
9593
9612
  void startSpan({
9594
9613
  name: "cleanup",
@@ -9614,17 +9633,17 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9614
9633
  })));
9615
9634
  }
9616
9635
  freeUploadDependencyOnBuildArtifacts();
9617
- _context18.next = 42;
9636
+ _context18.next = 39;
9618
9637
  return safeFlushTelemetry(sentryClient);
9619
- case 42:
9620
- return _context18.finish(37);
9621
- case 43:
9638
+ case 39:
9639
+ return _context18.finish(34);
9640
+ case 40:
9622
9641
  case "end":
9623
9642
  return _context18.stop();
9624
9643
  }
9625
- }, _callee18, null, [[2, 33, 37, 43]]);
9644
+ }, _callee18, null, [[2, 30, 34, 40]]);
9626
9645
  })));
9627
- case 4:
9646
+ case 8:
9628
9647
  case "end":
9629
9648
  return _context19.stop();
9630
9649
  }
@@ -9636,13 +9655,13 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9636
9655
  */
9637
9656
  deleteArtifacts: function deleteArtifacts() {
9638
9657
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
9639
- var _options$sourcemaps5, filesToDelete, filePathsToDelete;
9658
+ var _options$sourcemaps9, filesToDelete, filePathsToDelete;
9640
9659
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
9641
9660
  while (1) switch (_context20.prev = _context20.next) {
9642
9661
  case 0:
9643
9662
  _context20.prev = 0;
9644
9663
  _context20.next = 3;
9645
- return (_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.filesToDeleteAfterUpload;
9664
+ return (_options$sourcemaps9 = options.sourcemaps) === null || _options$sourcemaps9 === void 0 ? void 0 : _options$sourcemaps9.filesToDeleteAfterUpload;
9646
9665
  case 3:
9647
9666
  filesToDelete = _context20.sent;
9648
9667
  if (!(filesToDelete !== undefined)) {
@@ -9696,8 +9715,8 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9696
9715
  };
9697
9716
  }
9698
9717
  function canUploadSourceMaps(options, logger, isDevMode) {
9699
- var _options$sourcemaps6;
9700
- if ((_options$sourcemaps6 = options.sourcemaps) !== null && _options$sourcemaps6 !== void 0 && _options$sourcemaps6.disable) {
9718
+ var _options$sourcemaps10;
9719
+ if ((_options$sourcemaps10 = options.sourcemaps) !== null && _options$sourcemaps10 !== void 0 && _options$sourcemaps10.disable) {
9701
9720
  logger.debug("Source map upload was disabled. Will not upload sourcemaps using debug ID process.");
9702
9721
  return false;
9703
9722
  }