@sentry/bundler-plugin-core 2.10.3 → 2.11.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
@@ -3,6 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var SentryCli = require('@sentry/cli');
6
+ var core = require('@babel/core');
7
+ var componentAnnotatePlugin = require('@sentry/component-annotate-plugin');
6
8
  var fs = require('fs');
7
9
  var path = require('path');
8
10
  var MagicString = require('magic-string');
@@ -13,7 +15,7 @@ var crypto = require('crypto');
13
15
  var childProcess = require('child_process');
14
16
  var glob = require('glob');
15
17
  var util = require('util');
16
- var utils = require('@sentry/utils');
18
+ var pkg = require('@sentry/utils');
17
19
  var node = require('@sentry/node');
18
20
  var dotenv = require('dotenv');
19
21
 
@@ -48,6 +50,7 @@ var os__default = /*#__PURE__*/_interopDefaultLegacy(os);
48
50
  var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
49
51
  var childProcess__default = /*#__PURE__*/_interopDefaultLegacy(childProcess);
50
52
  var util__namespace = /*#__PURE__*/_interopNamespace(util);
53
+ var pkg__default = /*#__PURE__*/_interopDefaultLegacy(pkg);
51
54
  var dotenv__namespace = /*#__PURE__*/_interopNamespace(dotenv);
52
55
 
53
56
  function ownKeys(object, enumerableOnly) {
@@ -694,6 +697,7 @@ function normalizeUserOptions(userOptions) {
694
697
  cleanArtifacts: (_userOptions$release$6 = (_userOptions$release6 = userOptions.release) === null || _userOptions$release6 === void 0 ? void 0 : _userOptions$release6.cleanArtifacts) !== null && _userOptions$release$6 !== void 0 ? _userOptions$release$6 : false
695
698
  }),
696
699
  bundleSizeOptimizations: userOptions.bundleSizeOptimizations,
700
+ reactComponentAnnotation: userOptions.reactComponentAnnotation,
697
701
  _experiments: (_userOptions$_experim = userOptions._experiments) !== null && _userOptions$_experim !== void 0 ? _userOptions$_experim : {}
698
702
  };
699
703
  return options;
@@ -736,7 +740,7 @@ function createSentryInstance(options, shouldSendTelemetry, bundler) {
736
740
  dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
737
741
  tracesSampleRate: 1,
738
742
  sampleRate: 1,
739
- release: "2.10.3",
743
+ release: "2.11.0",
740
744
  integrations: [],
741
745
  tracePropagationTargets: ["sentry.io/api"],
742
746
  stackParser: node.defaultStackParser,
@@ -1073,7 +1077,7 @@ function createDebugIdUploadFunction(_ref) {
1073
1077
  headers: _objectSpread2({
1074
1078
  "sentry-trace": uploadSpan.toTraceparent(),
1075
1079
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1076
- baggage: utils.dynamicSamplingContextToSentryBaggageHeader(artifactBundleUploadTransaction.getDynamicSamplingContext())
1080
+ baggage: pkg.dynamicSamplingContextToSentryBaggageHeader(artifactBundleUploadTransaction.getDynamicSamplingContext())
1077
1081
  }, sentryCliOptions.headers)
1078
1082
  }));
1079
1083
  _context3.next = 45;
@@ -1572,6 +1576,7 @@ function createLogger(options) {
1572
1576
  };
1573
1577
  }
1574
1578
 
1579
+ var logger = pkg__default["default"].logger;
1575
1580
  /**
1576
1581
  * The sentry bundler plugin concerns itself with two things:
1577
1582
  * - Release injection
@@ -1601,6 +1606,7 @@ function createLogger(options) {
1601
1606
  */
1602
1607
  function sentryUnpluginFactory(_ref) {
1603
1608
  var releaseInjectionPlugin = _ref.releaseInjectionPlugin,
1609
+ componentNameAnnotatePlugin = _ref.componentNameAnnotatePlugin,
1604
1610
  moduleMetadataInjectionPlugin = _ref.moduleMetadataInjectionPlugin,
1605
1611
  debugIdInjectionPlugin = _ref.debugIdInjectionPlugin,
1606
1612
  debugIdUploadPlugin = _ref.debugIdUploadPlugin,
@@ -1646,7 +1652,7 @@ function sentryUnpluginFactory(_ref) {
1646
1652
  });
1647
1653
 
1648
1654
  // Set the User-Agent that Sentry CLI will use when interacting with Sentry
1649
- process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.10.3");
1655
+ process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.11.0");
1650
1656
  function handleRecoverableError(unknownError) {
1651
1657
  sentrySession.status = "abnormal";
1652
1658
  try {
@@ -1801,6 +1807,15 @@ function sentryUnpluginFactory(_ref) {
1801
1807
  }
1802
1808
  })));
1803
1809
  }
1810
+ if (options.reactComponentAnnotation) {
1811
+ if (!options.reactComponentAnnotation.enabled) {
1812
+ logger.info("The component name annotate plugin is currently disabled. Skipping component name annotations.");
1813
+ } else if (options.reactComponentAnnotation.enabled && !componentNameAnnotatePlugin) {
1814
+ logger.warn("The component name annotate plugin is currently not supported by '@sentry/esbuild-plugin'");
1815
+ } else {
1816
+ componentNameAnnotatePlugin && plugins.push(componentNameAnnotatePlugin());
1817
+ }
1818
+ }
1804
1819
  return plugins;
1805
1820
  });
1806
1821
  }
@@ -2013,10 +2028,79 @@ function createRollupDebugIdUploadHooks(upload) {
2013
2028
  }
2014
2029
  };
2015
2030
  }
2031
+ function createComponentNameAnnotateHooks() {
2032
+ return {
2033
+ transform: function transform(code, id) {
2034
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
2035
+ var idWithoutQueryAndHash, parserPlugins, _result$code, result;
2036
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2037
+ while (1) switch (_context2.prev = _context2.next) {
2038
+ case 0:
2039
+ // id may contain query and hash which will trip up our file extension logic below
2040
+ idWithoutQueryAndHash = stripQueryAndHashFromPath(id);
2041
+ if (!idWithoutQueryAndHash.match(/\\node_modules\\|\/node_modules\//)) {
2042
+ _context2.next = 3;
2043
+ break;
2044
+ }
2045
+ return _context2.abrupt("return", null);
2046
+ case 3:
2047
+ if ([".jsx", ".tsx"].some(function (ending) {
2048
+ return idWithoutQueryAndHash.endsWith(ending);
2049
+ })) {
2050
+ _context2.next = 5;
2051
+ break;
2052
+ }
2053
+ return _context2.abrupt("return", null);
2054
+ case 5:
2055
+ parserPlugins = [];
2056
+ if (idWithoutQueryAndHash.endsWith(".jsx")) {
2057
+ parserPlugins.push("jsx");
2058
+ } else if (idWithoutQueryAndHash.endsWith(".tsx")) {
2059
+ parserPlugins.push("jsx", "typescript");
2060
+ }
2061
+ _context2.prev = 7;
2062
+ _context2.next = 10;
2063
+ return core.transformAsync(code, {
2064
+ plugins: [[componentAnnotatePlugin.componentNameAnnotatePlugin]],
2065
+ filename: id,
2066
+ parserOpts: {
2067
+ sourceType: "module",
2068
+ allowAwaitOutsideFunction: true,
2069
+ plugins: parserPlugins
2070
+ },
2071
+ generatorOpts: {
2072
+ decoratorsBeforeExport: true
2073
+ },
2074
+ sourceMaps: true
2075
+ });
2076
+ case 10:
2077
+ result = _context2.sent;
2078
+ return _context2.abrupt("return", {
2079
+ code: (_result$code = result === null || result === void 0 ? void 0 : result.code) !== null && _result$code !== void 0 ? _result$code : code,
2080
+ map: result === null || result === void 0 ? void 0 : result.map
2081
+ });
2082
+ case 14:
2083
+ _context2.prev = 14;
2084
+ _context2.t0 = _context2["catch"](7);
2085
+ logger.error("Failed to apply react annotate plugin", _context2.t0);
2086
+ case 17:
2087
+ return _context2.abrupt("return", {
2088
+ code: code
2089
+ });
2090
+ case 18:
2091
+ case "end":
2092
+ return _context2.stop();
2093
+ }
2094
+ }, _callee2, null, [[7, 14]]);
2095
+ }))();
2096
+ }
2097
+ };
2098
+ }
2016
2099
  function getDebugIdSnippet(debugId) {
2017
2100
  return ";!function(){try{var e=\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=\"".concat(debugId, "\",e._sentryDebugIdIdentifier=\"sentry-dbid-").concat(debugId, "\")}catch(e){}}();");
2018
2101
  }
2019
2102
 
2103
+ exports.createComponentNameAnnotateHooks = createComponentNameAnnotateHooks;
2020
2104
  exports.createRollupBundleSizeOptimizationHooks = createRollupBundleSizeOptimizationHooks;
2021
2105
  exports.createRollupDebugIdInjectionHooks = createRollupDebugIdInjectionHooks;
2022
2106
  exports.createRollupDebugIdUploadHooks = createRollupDebugIdUploadHooks;