@sentry/bundler-plugin-core 4.2.0 → 4.3.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.3.0",
8274
8274
  integrations: [],
8275
8275
  tracePropagationTargets: ["sentry.io/api"],
8276
8276
  stackParser: stackParser,
@@ -8873,7 +8873,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8873
8873
  });
8874
8874
 
8875
8875
  // 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");
8876
+ process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.3.0");
8877
8877
 
8878
8878
  // Not a bulletproof check but should be good enough to at least sometimes determine
8879
8879
  // if the plugin is called in dev/watch mode or for a prod build. The important part
@@ -9276,6 +9276,8 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9276
9276
  */
9277
9277
  uploadSourcemaps: function uploadSourcemaps(buildArtifactPaths, opts) {
9278
9278
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
9279
+ var _options$sourcemaps;
9280
+ var assets;
9279
9281
  return _regeneratorRuntime().wrap(function _callee19$(_context19) {
9280
9282
  while (1) switch (_context19.prev = _context19.next) {
9281
9283
  case 0:
@@ -9285,7 +9287,16 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9285
9287
  }
9286
9288
  return _context19.abrupt("return");
9287
9289
  case 2:
9288
- _context19.next = 4;
9290
+ // Early exit if assets is explicitly set to an empty array
9291
+ assets = (_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.assets;
9292
+ if (!(Array.isArray(assets) && assets.length === 0)) {
9293
+ _context19.next = 6;
9294
+ break;
9295
+ }
9296
+ logger.debug("Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.");
9297
+ return _context19.abrupt("return");
9298
+ case 6:
9299
+ _context19.next = 8;
9289
9300
  return startSpan(
9290
9301
  // This is `forceTransaction`ed because this span is used in dashboards in the form of indexed transactions.
9291
9302
  {
@@ -9294,7 +9305,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9294
9305
  forceTransaction: true
9295
9306
  }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
9296
9307
  var _opts$prepareArtifact;
9297
- var shouldPrepare, folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps, assets, globAssets, globResult, debugIdChunkFilePaths, tmpUploadFolder, _process$env2;
9308
+ var shouldPrepare, folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps2, _options$sourcemaps3, _options$sourcemaps4, _options$sourcemaps5, pathsToUpload, ignorePaths, globAssets, globResult, debugIdChunkFilePaths, tmpUploadFolder, _process$env2;
9298
9309
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
9299
9310
  while (1) switch (_context18.prev = _context18.next) {
9300
9311
  case 0:
@@ -9304,96 +9315,100 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9304
9315
  // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.
9305
9316
  freeUploadDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
9306
9317
  _context18.prev = 2;
9307
- assets = (_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.assets;
9318
+ if (shouldPrepare) {
9319
+ _context18.next = 11;
9320
+ break;
9321
+ }
9322
+ // Direct CLI upload from existing artifact paths (no globbing, no preparation)
9323
+
9308
9324
  if (assets) {
9309
- globAssets = assets;
9325
+ pathsToUpload = Array.isArray(assets) ? assets : [assets];
9326
+ logger.debug("Direct upload mode: passing user-provided assets directly to CLI: ".concat(pathsToUpload.join(", ")));
9310
9327
  } else {
9311
- logger.debug("No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.");
9312
- globAssets = buildArtifactPaths;
9328
+ // Use original paths e.g. like ['.next/server'] directly –> preferred way when no globbing is done
9329
+ pathsToUpload = buildArtifactPaths;
9313
9330
  }
9314
- _context18.next = 7;
9331
+ 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] : [];
9332
+ _context18.next = 8;
9315
9333
  return startSpan({
9316
- name: "glob",
9334
+ name: "upload",
9317
9335
  scope: sentryScope
9318
9336
  }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
9319
- var _options$sourcemaps2;
9337
+ var _options$release$name;
9338
+ var cliInstance;
9320
9339
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
9321
9340
  while (1) switch (_context10.prev = _context10.next) {
9322
9341
  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
9342
+ cliInstance = createCliInstance(options);
9343
+ _context10.next = 3;
9344
+ return cliInstance.releases.uploadSourceMaps((_options$release$name = options.release.name) !== null && _options$release$name !== void 0 ? _options$release$name : "undefined", {
9345
+ include: [{
9346
+ paths: pathsToUpload,
9347
+ rewrite: true,
9348
+ dist: options.release.dist
9349
+ }],
9350
+ ignore: ignorePaths,
9351
+ live: "rejectOnError"
9329
9352
  });
9330
- case 2:
9331
- return _context10.abrupt("return", _context10.sent);
9332
9353
  case 3:
9333
9354
  case "end":
9334
9355
  return _context10.stop();
9335
9356
  }
9336
9357
  }, _callee10);
9337
9358
  })));
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;
9359
+ case 8:
9360
+ logger.info("Successfully uploaded source maps to Sentry");
9361
+ _context18.next = 28;
9359
9362
  break;
9360
- case 18:
9361
- if (shouldPrepare) {
9362
- _context18.next = 24;
9363
- break;
9363
+ case 11:
9364
+ // Prepare artifacts in temp folder before uploading
9365
+
9366
+ if (assets) {
9367
+ globAssets = assets;
9368
+ } else {
9369
+ logger.debug("No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.");
9370
+ globAssets = buildArtifactPaths;
9364
9371
  }
9365
- _context18.next = 21;
9372
+ _context18.next = 14;
9366
9373
  return startSpan({
9367
- name: "upload",
9374
+ name: "glob",
9368
9375
  scope: sentryScope
9369
9376
  }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
9370
- var _options$release$name;
9371
- var cliInstance;
9377
+ var _options$sourcemaps6;
9372
9378
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
9373
9379
  while (1) switch (_context11.prev = _context11.next) {
9374
9380
  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"
9381
+ _context11.next = 2;
9382
+ return glob(globAssets, {
9383
+ absolute: true,
9384
+ nodir: true,
9385
+ // We need individual files for preparation
9386
+ ignore: (_options$sourcemaps6 = options.sourcemaps) === null || _options$sourcemaps6 === void 0 ? void 0 : _options$sourcemaps6.ignore
9384
9387
  });
9388
+ case 2:
9389
+ return _context11.abrupt("return", _context11.sent);
9385
9390
  case 3:
9386
9391
  case "end":
9387
9392
  return _context11.stop();
9388
9393
  }
9389
9394
  }, _callee11);
9390
9395
  })));
9391
- case 21:
9392
- logger.info("Successfully uploaded source maps to Sentry");
9393
- _context18.next = 31;
9396
+ case 14:
9397
+ globResult = _context18.sent;
9398
+ debugIdChunkFilePaths = globResult.filter(function (debugIdChunkFilePath) {
9399
+ return !!stripQueryAndHashFromPath(debugIdChunkFilePath).match(/\.(js|mjs|cjs)$/);
9400
+ }); // The order of the files output by glob() is not deterministic
9401
+ // Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent
9402
+ debugIdChunkFilePaths.sort();
9403
+ if (!(debugIdChunkFilePaths.length === 0)) {
9404
+ _context18.next = 21;
9405
+ break;
9406
+ }
9407
+ logger.warn("Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.");
9408
+ _context18.next = 28;
9394
9409
  break;
9395
- case 24:
9396
- _context18.next = 26;
9410
+ case 21:
9411
+ _context18.next = 23;
9397
9412
  return startSpan({
9398
9413
  name: "mkdtemp",
9399
9414
  scope: sentryScope
@@ -9419,12 +9434,12 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9419
9434
  }
9420
9435
  }, _callee12);
9421
9436
  })));
9422
- case 26:
9437
+ case 23:
9423
9438
  tmpUploadFolder = _context18.sent;
9424
9439
  folderToCleanUp = tmpUploadFolder;
9425
9440
 
9426
9441
  // Prepare into temp folder, then upload
9427
- _context18.next = 30;
9442
+ _context18.next = 27;
9428
9443
  return startSpan({
9429
9444
  name: "prepare-bundles",
9430
9445
  scope: sentryScope
@@ -9438,12 +9453,12 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9438
9453
  // instead we do it with a maximum of 16 concurrent workers
9439
9454
  preparationTasks = debugIdChunkFilePaths.map(function (chunkFilePath, chunkIndex) {
9440
9455
  return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
9441
- var _options$sourcemaps$r, _options$sourcemaps3, _options$sourcemaps4;
9456
+ var _options$sourcemaps$r, _options$sourcemaps7, _options$sourcemaps8;
9442
9457
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
9443
9458
  while (1) switch (_context13.prev = _context13.next) {
9444
9459
  case 0:
9445
9460
  _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);
9461
+ 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
9462
  case 2:
9448
9463
  case "end":
9449
9464
  return _context13.stop();
@@ -9540,18 +9555,18 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9540
9555
  return _ref6.apply(this, arguments);
9541
9556
  };
9542
9557
  }());
9543
- case 30:
9558
+ case 27:
9544
9559
  logger.info("Successfully uploaded source maps to Sentry");
9545
- case 31:
9546
- _context18.next = 37;
9560
+ case 28:
9561
+ _context18.next = 34;
9547
9562
  break;
9548
- case 33:
9549
- _context18.prev = 33;
9563
+ case 30:
9564
+ _context18.prev = 30;
9550
9565
  _context18.t0 = _context18["catch"](2);
9551
9566
  sentryScope.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
9552
9567
  handleRecoverableError(_context18.t0, false);
9553
- case 37:
9554
- _context18.prev = 37;
9568
+ case 34:
9569
+ _context18.prev = 34;
9555
9570
  if (folderToCleanUp && !((_process$env2 = process.env) !== null && _process$env2 !== void 0 && _process$env2["SENTRY_TEST_OVERRIDE_TEMP_DIR"])) {
9556
9571
  void startSpan({
9557
9572
  name: "cleanup",
@@ -9577,17 +9592,17 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9577
9592
  })));
9578
9593
  }
9579
9594
  freeUploadDependencyOnBuildArtifacts();
9580
- _context18.next = 42;
9595
+ _context18.next = 39;
9581
9596
  return safeFlushTelemetry(sentryClient);
9582
- case 42:
9583
- return _context18.finish(37);
9584
- case 43:
9597
+ case 39:
9598
+ return _context18.finish(34);
9599
+ case 40:
9585
9600
  case "end":
9586
9601
  return _context18.stop();
9587
9602
  }
9588
- }, _callee18, null, [[2, 33, 37, 43]]);
9603
+ }, _callee18, null, [[2, 30, 34, 40]]);
9589
9604
  })));
9590
- case 4:
9605
+ case 8:
9591
9606
  case "end":
9592
9607
  return _context19.stop();
9593
9608
  }
@@ -9599,13 +9614,13 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9599
9614
  */
9600
9615
  deleteArtifacts: function deleteArtifacts() {
9601
9616
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
9602
- var _options$sourcemaps5, filesToDelete, filePathsToDelete;
9617
+ var _options$sourcemaps9, filesToDelete, filePathsToDelete;
9603
9618
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
9604
9619
  while (1) switch (_context20.prev = _context20.next) {
9605
9620
  case 0:
9606
9621
  _context20.prev = 0;
9607
9622
  _context20.next = 3;
9608
- return (_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.filesToDeleteAfterUpload;
9623
+ return (_options$sourcemaps9 = options.sourcemaps) === null || _options$sourcemaps9 === void 0 ? void 0 : _options$sourcemaps9.filesToDeleteAfterUpload;
9609
9624
  case 3:
9610
9625
  filesToDelete = _context20.sent;
9611
9626
  if (!(filesToDelete !== undefined)) {
@@ -9659,8 +9674,8 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9659
9674
  };
9660
9675
  }
9661
9676
  function canUploadSourceMaps(options, logger, isDevMode) {
9662
- var _options$sourcemaps6;
9663
- if ((_options$sourcemaps6 = options.sourcemaps) !== null && _options$sourcemaps6 !== void 0 && _options$sourcemaps6.disable) {
9677
+ var _options$sourcemaps10;
9678
+ if ((_options$sourcemaps10 = options.sourcemaps) !== null && _options$sourcemaps10 !== void 0 && _options$sourcemaps10.disable) {
9664
9679
  logger.debug("Source map upload was disabled. Will not upload sourcemaps using debug ID process.");
9665
9680
  return false;
9666
9681
  }