@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.
@@ -8065,7 +8065,7 @@ function normalizeUserOptions(userOptions) {
8065
8065
  * @returns `true` if the options are valid, `false` otherwise
8066
8066
  */
8067
8067
  function validateOptions(options, logger) {
8068
- var _options$release, _options$release2, _options$release3;
8068
+ var _options$release, _options$release2;
8069
8069
  var setCommits = (_options$release = options.release) === null || _options$release === void 0 ? void 0 : _options$release.setCommits;
8070
8070
  if (setCommits) {
8071
8071
  if (!setCommits.auto && !(setCommits.repo && setCommits.commit)) {
@@ -8076,7 +8076,7 @@ function validateOptions(options, logger) {
8076
8076
  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`.");
8077
8077
  }
8078
8078
  }
8079
- 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)) {
8079
+ if ((_options$release2 = options.release) !== null && _options$release2 !== void 0 && _options$release2.deploy && _typeof(options.release.deploy) === "object" && !options.release.deploy.env) {
8080
8080
  logger.error("The `deploy` option was specified but is missing the required `env` property.", "Please set the `env` property.");
8081
8081
  return false;
8082
8082
  }
@@ -8270,7 +8270,7 @@ function createSentryInstance(options, shouldSendTelemetry, buildTool) {
8270
8270
  dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
8271
8271
  tracesSampleRate: 1,
8272
8272
  sampleRate: 1,
8273
- release: "4.2.0",
8273
+ release: "4.4.0",
8274
8274
  integrations: [],
8275
8275
  tracePropagationTargets: ["sentry.io/api"],
8276
8276
  stackParser: stackParser,
@@ -8438,12 +8438,16 @@ function createDebugIdUploadFunction(_ref) {
8438
8438
  var sentryBuildPluginManager = _ref.sentryBuildPluginManager;
8439
8439
  return /*#__PURE__*/function () {
8440
8440
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(buildArtifactPaths) {
8441
+ var cleanedPaths;
8441
8442
  return _regeneratorRuntime().wrap(function _callee$(_context) {
8442
8443
  while (1) switch (_context.prev = _context.next) {
8443
8444
  case 0:
8444
- _context.next = 2;
8445
- return sentryBuildPluginManager.uploadSourcemaps(buildArtifactPaths);
8446
- case 2:
8445
+ // Webpack and perhaps other bundlers allow you to append query strings to
8446
+ // filenames for cache busting purposes. We should strip these before upload.
8447
+ cleanedPaths = buildArtifactPaths.map(stripQueryAndHashFromPath);
8448
+ _context.next = 3;
8449
+ return sentryBuildPluginManager.uploadSourcemaps(cleanedPaths);
8450
+ case 3:
8447
8451
  case "end":
8448
8452
  return _context.stop();
8449
8453
  }
@@ -8873,7 +8877,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8873
8877
  });
8874
8878
 
8875
8879
  // Set the User-Agent that Sentry CLI will use when interacting with Sentry
8876
- process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.2.0");
8880
+ process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.4.0");
8877
8881
 
8878
8882
  // Not a bulletproof check but should be good enough to at least sometimes determine
8879
8883
  // if the plugin is called in dev/watch mode or for a prod build. The important part
@@ -9276,6 +9280,8 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9276
9280
  */
9277
9281
  uploadSourcemaps: function uploadSourcemaps(buildArtifactPaths, opts) {
9278
9282
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
9283
+ var _options$sourcemaps;
9284
+ var assets;
9279
9285
  return _regeneratorRuntime().wrap(function _callee19$(_context19) {
9280
9286
  while (1) switch (_context19.prev = _context19.next) {
9281
9287
  case 0:
@@ -9285,7 +9291,16 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9285
9291
  }
9286
9292
  return _context19.abrupt("return");
9287
9293
  case 2:
9288
- _context19.next = 4;
9294
+ // Early exit if assets is explicitly set to an empty array
9295
+ assets = (_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.assets;
9296
+ if (!(Array.isArray(assets) && assets.length === 0)) {
9297
+ _context19.next = 6;
9298
+ break;
9299
+ }
9300
+ logger.debug("Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.");
9301
+ return _context19.abrupt("return");
9302
+ case 6:
9303
+ _context19.next = 8;
9289
9304
  return startSpan(
9290
9305
  // This is `forceTransaction`ed because this span is used in dashboards in the form of indexed transactions.
9291
9306
  {
@@ -9294,7 +9309,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9294
9309
  forceTransaction: true
9295
9310
  }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
9296
9311
  var _opts$prepareArtifact;
9297
- var shouldPrepare, folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps, assets, globAssets, globResult, debugIdChunkFilePaths, tmpUploadFolder, _process$env2;
9312
+ var shouldPrepare, folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps2, _options$sourcemaps3, _options$sourcemaps4, _options$sourcemaps5, pathsToUpload, ignorePaths, globAssets, globResult, debugIdChunkFilePaths, tmpUploadFolder, _process$env2;
9298
9313
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
9299
9314
  while (1) switch (_context18.prev = _context18.next) {
9300
9315
  case 0:
@@ -9304,96 +9319,100 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9304
9319
  // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.
9305
9320
  freeUploadDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
9306
9321
  _context18.prev = 2;
9307
- assets = (_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.assets;
9322
+ if (shouldPrepare) {
9323
+ _context18.next = 11;
9324
+ break;
9325
+ }
9326
+ // Direct CLI upload from existing artifact paths (no globbing, no preparation)
9327
+
9308
9328
  if (assets) {
9309
- globAssets = assets;
9329
+ pathsToUpload = Array.isArray(assets) ? assets : [assets];
9330
+ logger.debug("Direct upload mode: passing user-provided assets directly to CLI: ".concat(pathsToUpload.join(", ")));
9310
9331
  } else {
9311
- logger.debug("No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.");
9312
- globAssets = buildArtifactPaths;
9332
+ // Use original paths e.g. like ['.next/server'] directly –> preferred way when no globbing is done
9333
+ pathsToUpload = buildArtifactPaths;
9313
9334
  }
9314
- _context18.next = 7;
9335
+ 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] : [];
9336
+ _context18.next = 8;
9315
9337
  return startSpan({
9316
- name: "glob",
9338
+ name: "upload",
9317
9339
  scope: sentryScope
9318
9340
  }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
9319
- var _options$sourcemaps2;
9341
+ var _options$release$name;
9342
+ var cliInstance;
9320
9343
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
9321
9344
  while (1) switch (_context10.prev = _context10.next) {
9322
9345
  case 0:
9323
- _context10.next = 2;
9324
- return glob(globAssets, {
9325
- absolute: true,
9326
- // If we do not use a temp folder, we allow directories and files; CLI will traverse as needed when given paths.
9327
- nodir: shouldPrepare,
9328
- ignore: (_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.ignore
9346
+ cliInstance = createCliInstance(options);
9347
+ _context10.next = 3;
9348
+ return cliInstance.releases.uploadSourceMaps((_options$release$name = options.release.name) !== null && _options$release$name !== void 0 ? _options$release$name : "undefined", {
9349
+ include: [{
9350
+ paths: pathsToUpload,
9351
+ rewrite: true,
9352
+ dist: options.release.dist
9353
+ }],
9354
+ ignore: ignorePaths,
9355
+ live: "rejectOnError"
9329
9356
  });
9330
- case 2:
9331
- return _context10.abrupt("return", _context10.sent);
9332
9357
  case 3:
9333
9358
  case "end":
9334
9359
  return _context10.stop();
9335
9360
  }
9336
9361
  }, _callee10);
9337
9362
  })));
9338
- case 7:
9339
- globResult = _context18.sent;
9340
- debugIdChunkFilePaths = shouldPrepare ? globResult.filter(function (debugIdChunkFilePath) {
9341
- return !!stripQueryAndHashFromPath(debugIdChunkFilePath).match(/\.(js|mjs|cjs)$/);
9342
- }) : globResult; // The order of the files output by glob() is not deterministic
9343
- // Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent
9344
- debugIdChunkFilePaths.sort();
9345
- if (!(Array.isArray(assets) && assets.length === 0)) {
9346
- _context18.next = 14;
9347
- break;
9348
- }
9349
- logger.debug("Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.");
9350
- _context18.next = 31;
9351
- break;
9352
- case 14:
9353
- if (!(debugIdChunkFilePaths.length === 0)) {
9354
- _context18.next = 18;
9355
- break;
9356
- }
9357
- logger.warn("Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.");
9358
- _context18.next = 31;
9363
+ case 8:
9364
+ logger.info("Successfully uploaded source maps to Sentry");
9365
+ _context18.next = 28;
9359
9366
  break;
9360
- case 18:
9361
- if (shouldPrepare) {
9362
- _context18.next = 24;
9363
- break;
9367
+ case 11:
9368
+ // Prepare artifacts in temp folder before uploading
9369
+
9370
+ if (assets) {
9371
+ globAssets = assets;
9372
+ } else {
9373
+ logger.debug("No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.");
9374
+ globAssets = buildArtifactPaths;
9364
9375
  }
9365
- _context18.next = 21;
9376
+ _context18.next = 14;
9366
9377
  return startSpan({
9367
- name: "upload",
9378
+ name: "glob",
9368
9379
  scope: sentryScope
9369
9380
  }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
9370
- var _options$release$name;
9371
- var cliInstance;
9381
+ var _options$sourcemaps6;
9372
9382
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
9373
9383
  while (1) switch (_context11.prev = _context11.next) {
9374
9384
  case 0:
9375
- cliInstance = createCliInstance(options);
9376
- _context11.next = 3;
9377
- return cliInstance.releases.uploadSourceMaps((_options$release$name = options.release.name) !== null && _options$release$name !== void 0 ? _options$release$name : "undefined", {
9378
- include: [{
9379
- paths: debugIdChunkFilePaths,
9380
- rewrite: false,
9381
- dist: options.release.dist
9382
- }],
9383
- live: "rejectOnError"
9385
+ _context11.next = 2;
9386
+ return glob(globAssets, {
9387
+ absolute: true,
9388
+ nodir: true,
9389
+ // We need individual files for preparation
9390
+ ignore: (_options$sourcemaps6 = options.sourcemaps) === null || _options$sourcemaps6 === void 0 ? void 0 : _options$sourcemaps6.ignore
9384
9391
  });
9392
+ case 2:
9393
+ return _context11.abrupt("return", _context11.sent);
9385
9394
  case 3:
9386
9395
  case "end":
9387
9396
  return _context11.stop();
9388
9397
  }
9389
9398
  }, _callee11);
9390
9399
  })));
9391
- case 21:
9392
- logger.info("Successfully uploaded source maps to Sentry");
9393
- _context18.next = 31;
9400
+ case 14:
9401
+ globResult = _context18.sent;
9402
+ debugIdChunkFilePaths = globResult.filter(function (debugIdChunkFilePath) {
9403
+ return !!stripQueryAndHashFromPath(debugIdChunkFilePath).match(/\.(js|mjs|cjs)$/);
9404
+ }); // The order of the files output by glob() is not deterministic
9405
+ // Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent
9406
+ debugIdChunkFilePaths.sort();
9407
+ if (!(debugIdChunkFilePaths.length === 0)) {
9408
+ _context18.next = 21;
9409
+ break;
9410
+ }
9411
+ logger.warn("Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.");
9412
+ _context18.next = 28;
9394
9413
  break;
9395
- case 24:
9396
- _context18.next = 26;
9414
+ case 21:
9415
+ _context18.next = 23;
9397
9416
  return startSpan({
9398
9417
  name: "mkdtemp",
9399
9418
  scope: sentryScope
@@ -9419,12 +9438,12 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9419
9438
  }
9420
9439
  }, _callee12);
9421
9440
  })));
9422
- case 26:
9441
+ case 23:
9423
9442
  tmpUploadFolder = _context18.sent;
9424
9443
  folderToCleanUp = tmpUploadFolder;
9425
9444
 
9426
9445
  // Prepare into temp folder, then upload
9427
- _context18.next = 30;
9446
+ _context18.next = 27;
9428
9447
  return startSpan({
9429
9448
  name: "prepare-bundles",
9430
9449
  scope: sentryScope
@@ -9438,12 +9457,12 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9438
9457
  // instead we do it with a maximum of 16 concurrent workers
9439
9458
  preparationTasks = debugIdChunkFilePaths.map(function (chunkFilePath, chunkIndex) {
9440
9459
  return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
9441
- var _options$sourcemaps$r, _options$sourcemaps3, _options$sourcemaps4;
9460
+ var _options$sourcemaps$r, _options$sourcemaps7, _options$sourcemaps8;
9442
9461
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
9443
9462
  while (1) switch (_context13.prev = _context13.next) {
9444
9463
  case 0:
9445
9464
  _context13.next = 2;
9446
- 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);
9465
+ 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);
9447
9466
  case 2:
9448
9467
  case "end":
9449
9468
  return _context13.stop();
@@ -9540,18 +9559,18 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9540
9559
  return _ref6.apply(this, arguments);
9541
9560
  };
9542
9561
  }());
9543
- case 30:
9562
+ case 27:
9544
9563
  logger.info("Successfully uploaded source maps to Sentry");
9545
- case 31:
9546
- _context18.next = 37;
9564
+ case 28:
9565
+ _context18.next = 34;
9547
9566
  break;
9548
- case 33:
9549
- _context18.prev = 33;
9567
+ case 30:
9568
+ _context18.prev = 30;
9550
9569
  _context18.t0 = _context18["catch"](2);
9551
9570
  sentryScope.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
9552
9571
  handleRecoverableError(_context18.t0, false);
9553
- case 37:
9554
- _context18.prev = 37;
9572
+ case 34:
9573
+ _context18.prev = 34;
9555
9574
  if (folderToCleanUp && !((_process$env2 = process.env) !== null && _process$env2 !== void 0 && _process$env2["SENTRY_TEST_OVERRIDE_TEMP_DIR"])) {
9556
9575
  void startSpan({
9557
9576
  name: "cleanup",
@@ -9577,17 +9596,17 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9577
9596
  })));
9578
9597
  }
9579
9598
  freeUploadDependencyOnBuildArtifacts();
9580
- _context18.next = 42;
9599
+ _context18.next = 39;
9581
9600
  return safeFlushTelemetry(sentryClient);
9582
- case 42:
9583
- return _context18.finish(37);
9584
- case 43:
9601
+ case 39:
9602
+ return _context18.finish(34);
9603
+ case 40:
9585
9604
  case "end":
9586
9605
  return _context18.stop();
9587
9606
  }
9588
- }, _callee18, null, [[2, 33, 37, 43]]);
9607
+ }, _callee18, null, [[2, 30, 34, 40]]);
9589
9608
  })));
9590
- case 4:
9609
+ case 8:
9591
9610
  case "end":
9592
9611
  return _context19.stop();
9593
9612
  }
@@ -9599,13 +9618,13 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9599
9618
  */
9600
9619
  deleteArtifacts: function deleteArtifacts() {
9601
9620
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
9602
- var _options$sourcemaps5, filesToDelete, filePathsToDelete;
9621
+ var _options$sourcemaps9, filesToDelete, filePathsToDelete;
9603
9622
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
9604
9623
  while (1) switch (_context20.prev = _context20.next) {
9605
9624
  case 0:
9606
9625
  _context20.prev = 0;
9607
9626
  _context20.next = 3;
9608
- return (_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.filesToDeleteAfterUpload;
9627
+ return (_options$sourcemaps9 = options.sourcemaps) === null || _options$sourcemaps9 === void 0 ? void 0 : _options$sourcemaps9.filesToDeleteAfterUpload;
9609
9628
  case 3:
9610
9629
  filesToDelete = _context20.sent;
9611
9630
  if (!(filesToDelete !== undefined)) {
@@ -9659,8 +9678,8 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9659
9678
  };
9660
9679
  }
9661
9680
  function canUploadSourceMaps(options, logger, isDevMode) {
9662
- var _options$sourcemaps6;
9663
- if ((_options$sourcemaps6 = options.sourcemaps) !== null && _options$sourcemaps6 !== void 0 && _options$sourcemaps6.disable) {
9681
+ var _options$sourcemaps10;
9682
+ if ((_options$sourcemaps10 = options.sourcemaps) !== null && _options$sourcemaps10 !== void 0 && _options$sourcemaps10.disable) {
9664
9683
  logger.debug("Source map upload was disabled. Will not upload sourcemaps using debug ID process.");
9665
9684
  return false;
9666
9685
  }