@sentry/bundler-plugin-core 3.5.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
@@ -8195,7 +8195,7 @@ function createSentryInstance(options, shouldSendTelemetry, buildTool) {
8195
8195
  dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
8196
8196
  tracesSampleRate: 1,
8197
8197
  sampleRate: 1,
8198
- release: "3.5.0",
8198
+ release: "3.6.0",
8199
8199
  integrations: [],
8200
8200
  tracePropagationTargets: ["sentry.io/api"],
8201
8201
  stackParser: stackParser,
@@ -8771,7 +8771,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8771
8771
  });
8772
8772
 
8773
8773
  // Set the User-Agent that Sentry CLI will use when interacting with Sentry
8774
- process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "3.5.0");
8774
+ process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "3.6.0");
8775
8775
 
8776
8776
  // Not a bulletproof check but should be good enough to at least sometimes determine
8777
8777
  // if the plugin is called in dev/watch mode or for a prod build. The important part
@@ -9120,22 +9120,16 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9120
9120
  */
9121
9121
  uploadSourcemaps: function uploadSourcemaps(buildArtifactPaths) {
9122
9122
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
9123
- var _options$sourcemaps;
9124
9123
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
9125
9124
  while (1) switch (_context15.prev = _context15.next) {
9126
9125
  case 0:
9127
- if ((_options$sourcemaps = options.sourcemaps) !== null && _options$sourcemaps !== void 0 && _options$sourcemaps.disable) {
9128
- logger.debug("Source map upload was disabled. Will not upload sourcemaps using debug ID process.");
9129
- } else if (isDevMode) {
9130
- logger.debug("Running in development mode. Will not upload sourcemaps.");
9131
- } else if (!options.authToken) {
9132
- 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"));
9133
- } else if (!options.org && !options.authToken.startsWith("sntrys_")) {
9134
- logger.warn("No org provided. Will not upload source maps. Please set the `org` option to your Sentry organization slug." + getTurborepoEnvPassthroughWarning("SENTRY_ORG"));
9135
- } else if (!options.project) {
9136
- 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;
9137
9129
  }
9138
- _context15.next = 3;
9130
+ return _context15.abrupt("return");
9131
+ case 2:
9132
+ _context15.next = 4;
9139
9133
  return startSpan(
9140
9134
  // This is `forceTransaction`ed because this span is used in dashboards in the form of indexed transactions.
9141
9135
  {
@@ -9143,7 +9137,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9143
9137
  scope: sentryScope,
9144
9138
  forceTransaction: true
9145
9139
  }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
9146
- var folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps2, tmpUploadFolder, assets, globAssets, globResult, debugIdChunkFilePaths, _process$env2;
9140
+ var folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps, tmpUploadFolder, assets, globAssets, globResult, debugIdChunkFilePaths, numUploadedFiles, _process$env2;
9147
9141
  return _regeneratorRuntime().wrap(function _callee14$(_context14) {
9148
9142
  while (1) switch (_context14.prev = _context14.next) {
9149
9143
  case 0:
@@ -9180,7 +9174,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9180
9174
  case 4:
9181
9175
  tmpUploadFolder = _context14.sent;
9182
9176
  folderToCleanUp = tmpUploadFolder;
9183
- 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;
9184
9178
  if (assets) {
9185
9179
  globAssets = assets;
9186
9180
  } else {
@@ -9192,7 +9186,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9192
9186
  name: "glob",
9193
9187
  scope: sentryScope
9194
9188
  }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
9195
- var _options$sourcemaps3;
9189
+ var _options$sourcemaps2;
9196
9190
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
9197
9191
  while (1) switch (_context8.prev = _context8.next) {
9198
9192
  case 0:
@@ -9200,7 +9194,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9200
9194
  return glob.glob(globAssets, {
9201
9195
  absolute: true,
9202
9196
  nodir: true,
9203
- 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
9204
9198
  });
9205
9199
  case 2:
9206
9200
  return _context8.abrupt("return", _context8.sent);
@@ -9222,7 +9216,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9222
9216
  break;
9223
9217
  }
9224
9218
  logger.debug("Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.");
9225
- _context14.next = 24;
9219
+ _context14.next = 25;
9226
9220
  break;
9227
9221
  case 17:
9228
9222
  if (!(debugIdChunkFilePaths.length === 0)) {
@@ -9230,7 +9224,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9230
9224
  break;
9231
9225
  }
9232
9226
  logger.warn("Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.");
9233
- _context14.next = 24;
9227
+ _context14.next = 25;
9234
9228
  break;
9235
9229
  case 21:
9236
9230
  _context14.next = 23;
@@ -9247,12 +9241,12 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9247
9241
  // instead we do it with a maximum of 16 concurrent workers
9248
9242
  preparationTasks = debugIdChunkFilePaths.map(function (chunkFilePath, chunkIndex) {
9249
9243
  return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
9250
- var _options$sourcemaps$r, _options$sourcemaps4, _options$sourcemaps5;
9244
+ var _options$sourcemaps$r, _options$sourcemaps3, _options$sourcemaps4;
9251
9245
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
9252
9246
  while (1) switch (_context9.prev = _context9.next) {
9253
9247
  case 0:
9254
9248
  _context9.next = 2;
9255
- 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, (_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.resolveSourceMap);
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);
9256
9250
  case 2:
9257
9251
  case "end":
9258
9252
  return _context9.stop();
@@ -9358,6 +9352,8 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9358
9352
  };
9359
9353
  }());
9360
9354
  case 17:
9355
+ return _context12.abrupt("return", files.length);
9356
+ case 18:
9361
9357
  case "end":
9362
9358
  return _context12.stop();
9363
9359
  }
@@ -9368,17 +9364,20 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9368
9364
  };
9369
9365
  }());
9370
9366
  case 23:
9371
- logger.info("Successfully uploaded source maps to Sentry");
9372
- case 24:
9373
- _context14.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;
9374
9373
  break;
9375
- case 26:
9376
- _context14.prev = 26;
9374
+ case 27:
9375
+ _context14.prev = 27;
9377
9376
  _context14.t0 = _context14["catch"](1);
9378
9377
  sentryScope.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
9379
9378
  handleRecoverableError(_context14.t0, false);
9380
- case 30:
9381
- _context14.prev = 30;
9379
+ case 31:
9380
+ _context14.prev = 31;
9382
9381
  if (folderToCleanUp && !((_process$env2 = process.env) !== null && _process$env2 !== void 0 && _process$env2["SENTRY_TEST_OVERRIDE_TEMP_DIR"])) {
9383
9382
  void startSpan({
9384
9383
  name: "cleanup",
@@ -9404,17 +9403,17 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9404
9403
  })));
9405
9404
  }
9406
9405
  freeUploadDependencyOnBuildArtifacts();
9407
- _context14.next = 35;
9406
+ _context14.next = 36;
9408
9407
  return safeFlushTelemetry(sentryClient);
9409
- case 35:
9410
- return _context14.finish(30);
9411
9408
  case 36:
9409
+ return _context14.finish(31);
9410
+ case 37:
9412
9411
  case "end":
9413
9412
  return _context14.stop();
9414
9413
  }
9415
- }, _callee14, null, [[1, 26, 30, 36]]);
9414
+ }, _callee14, null, [[1, 27, 31, 37]]);
9416
9415
  })));
9417
- case 3:
9416
+ case 4:
9418
9417
  case "end":
9419
9418
  return _context15.stop();
9420
9419
  }
@@ -9426,13 +9425,13 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9426
9425
  */
9427
9426
  deleteArtifacts: function deleteArtifacts() {
9428
9427
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
9429
- var _options$sourcemaps6, filesToDelete, filePathsToDelete;
9428
+ var _options$sourcemaps5, filesToDelete, filePathsToDelete;
9430
9429
  return _regeneratorRuntime().wrap(function _callee16$(_context16) {
9431
9430
  while (1) switch (_context16.prev = _context16.next) {
9432
9431
  case 0:
9433
9432
  _context16.prev = 0;
9434
9433
  _context16.next = 3;
9435
- return (_options$sourcemaps6 = options.sourcemaps) === null || _options$sourcemaps6 === void 0 ? void 0 : _options$sourcemaps6.filesToDeleteAfterUpload;
9434
+ return (_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.filesToDeleteAfterUpload;
9436
9435
  case 3:
9437
9436
  filesToDelete = _context16.sent;
9438
9437
  if (!(filesToDelete !== undefined)) {
@@ -9485,6 +9484,30 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9485
9484
  createDependencyOnBuildArtifacts: createDependencyOnBuildArtifacts
9486
9485
  };
9487
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
+ }
9488
9511
 
9489
9512
  /**
9490
9513
  * Creates an unplugin instance used to create Sentry plugins for Vite, Rollup, esbuild, and Webpack.
@@ -9580,13 +9603,13 @@ function sentryUnpluginFactory(_ref) {
9580
9603
  });
9581
9604
  if (!((_options$sourcemaps = options.sourcemaps) !== null && _options$sourcemaps !== void 0 && _options$sourcemaps.disable)) {
9582
9605
  plugins.push(debugIdInjectionPlugin(logger));
9583
- }
9584
9606
 
9585
- // This option is only strongly typed for the webpack plugin, where it is used. It has no effect on other plugins
9586
- var webpack_forceExitOnBuildComplete = typeof options._experiments["forceExitOnBuildCompletion"] === "boolean" ? options._experiments["forceExitOnBuildCompletion"] : undefined;
9587
- plugins.push(debugIdUploadPlugin(createDebugIdUploadFunction({
9588
- sentryBuildPluginManager: sentryBuildPluginManager
9589
- }), 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
+ }
9590
9613
  if (options.reactComponentAnnotation) {
9591
9614
  if (!options.reactComponentAnnotation.enabled) {
9592
9615
  logger.debug("The component name annotate plugin is currently disabled. Skipping component name annotations.");
@@ -9620,23 +9643,11 @@ function sentryUnpluginFactory(_ref) {
9620
9643
  }
9621
9644
 
9622
9645
  /**
9623
- * @deprecated
9646
+ * @deprecated This will be removed in v4
9624
9647
  */
9625
- // TODO(v4): Don't export this from the package
9626
- function getBuildInformation() {
9627
- var packageJson = getPackageJson();
9628
- var _ref2 = packageJson ? getDependencies(packageJson) : {
9629
- deps: [],
9630
- depsVersions: {}
9631
- },
9632
- deps = _ref2.deps,
9633
- depsVersions = _ref2.depsVersions;
9634
- return {
9635
- deps: deps,
9636
- depsVersions: depsVersions,
9637
- nodeVersion: parseMajorVersion(process.version)
9638
- };
9639
- }
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;
9640
9651
 
9641
9652
  /**
9642
9653
  * Determines whether the Sentry CLI binary is in its expected location.
@@ -9709,6 +9720,13 @@ function createRollupBundleSizeOptimizationHooks(replacementValues) {
9709
9720
  var COMMENT_USE_STRICT_REGEX =
9710
9721
  // Note: CodeQL complains that this regex potentially has n^2 runtime. This likely won't affect realistic files.
9711
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
+
9712
9730
  function createRollupDebugIdInjectionHooks() {
9713
9731
  return {
9714
9732
  renderChunk: function renderChunk(code, chunk) {