@sentry/bundler-plugin-core 4.0.0 → 4.0.2

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.
@@ -7816,12 +7816,13 @@ function generateGlobalInjectorCode(_ref2) {
7816
7816
  injectBuildInformation = _ref2.injectBuildInformation;
7817
7817
  // The code below is mostly ternary operators because it saves bundle size.
7818
7818
  // The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
7819
- var code = "{\n let _global =\n typeof window !== 'undefined' ?\n window :\n typeof global !== 'undefined' ?\n global :\n typeof globalThis !== 'undefined' ?\n globalThis :\n typeof self !== 'undefined' ?\n self :\n {};\n\n _global.SENTRY_RELEASE={id:".concat(JSON.stringify(release), "};");
7819
+ var code = "!function(){var e=\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:{};";
7820
+ code += "e.SENTRY_RELEASE={id:".concat(JSON.stringify(release), "};");
7820
7821
  if (injectBuildInformation) {
7821
7822
  var buildInfo = getBuildInformation();
7822
- code += "\n _global.SENTRY_BUILD_INFO=".concat(JSON.stringify(buildInfo), ";");
7823
+ code += "e.SENTRY_BUILD_INFO=".concat(JSON.stringify(buildInfo), ";");
7823
7824
  }
7824
- code += "}";
7825
+ code += "}();";
7825
7826
  return code;
7826
7827
  }
7827
7828
 
@@ -7830,7 +7831,7 @@ function generateModuleMetadataInjectorCode(metadata) {
7830
7831
  // The code below is mostly ternary operators because it saves bundle size.
7831
7832
  // The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
7832
7833
  // We are merging the metadata objects in case modules are bundled twice with the plugin
7833
- return "{\n let _sentryModuleMetadataGlobal =\n typeof window !== \"undefined\"\n ? window\n : typeof global !== \"undefined\"\n ? global\n : typeof globalThis !== \"undefined\"\n ? globalThis\n : typeof self !== \"undefined\"\n ? self\n : {};\n\n _sentryModuleMetadataGlobal._sentryModuleMetadata =\n _sentryModuleMetadataGlobal._sentryModuleMetadata || {};\n\n _sentryModuleMetadataGlobal._sentryModuleMetadata[new _sentryModuleMetadataGlobal.Error().stack] =\n Object.assign(\n {},\n _sentryModuleMetadataGlobal._sentryModuleMetadata[new _sentryModuleMetadataGlobal.Error().stack],\n ".concat(JSON.stringify(metadata), "\n );\n}");
7834
+ return "!function(){var e=\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])}return e}({},e._sentryModuleMetadata[(new e.Error).stack],".concat(JSON.stringify(metadata), ")}();");
7834
7835
  }
7835
7836
  function getBuildInformation() {
7836
7837
  var packageJson = getPackageJson();
@@ -8158,7 +8159,7 @@ function createSentryInstance(options, shouldSendTelemetry, buildTool) {
8158
8159
  dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
8159
8160
  tracesSampleRate: 1,
8160
8161
  sampleRate: 1,
8161
- release: "4.0.0",
8162
+ release: "4.0.2",
8162
8163
  integrations: [],
8163
8164
  tracePropagationTargets: ["sentry.io/api"],
8164
8165
  stackParser: stackParser,
@@ -8734,7 +8735,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8734
8735
  });
8735
8736
 
8736
8737
  // Set the User-Agent that Sentry CLI will use when interacting with Sentry
8737
- process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.0.0");
8738
+ process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.0.2");
8738
8739
 
8739
8740
  // Not a bulletproof check but should be good enough to at least sometimes determine
8740
8741
  // if the plugin is called in dev/watch mode or for a prod build. The important part
@@ -9619,56 +9620,55 @@ function sentryUnpluginFactory(_ref) {
9619
9620
  function sentryCliBinaryExists() {
9620
9621
  return fs.existsSync(SentryCli.getPath());
9621
9622
  }
9623
+
9624
+ // We need to be careful not to inject the snippet before any `"use strict";`s.
9625
+ // As an additional complication `"use strict";`s may come after any number of comments.
9626
+ var COMMENT_USE_STRICT_REGEX =
9627
+ // Note: CodeQL complains that this regex potentially has n^2 runtime. This likely won't affect realistic files.
9628
+ /^(?:\s*|\/\*(?:.|\r|\n)*?\*\/|\/\/.*[\n\r])*(?:"[^"]*";|'[^']*';)?/;
9629
+
9630
+ /**
9631
+ * Simplified `renderChunk` hook type from Rollup.
9632
+ * We can't reference the type directly because the Vite plugin complains
9633
+ * about type mismatches
9634
+ */
9635
+
9622
9636
  function createRollupReleaseInjectionHooks(injectionCode) {
9623
- var virtualReleaseInjectionFileId = "\0sentry-release-injection-file";
9624
9637
  return {
9625
- resolveId: function resolveId(id) {
9626
- if (id === virtualReleaseInjectionFileId) {
9638
+ renderChunk: function renderChunk(code, chunk) {
9639
+ if (
9640
+ // chunks could be any file (html, md, ...)
9641
+ [".js", ".mjs", ".cjs"].some(function (ending) {
9642
+ return stripQueryAndHashFromPath(chunk.fileName).endsWith(ending);
9643
+ })) {
9644
+ var _code$match;
9645
+ var ms = new MagicString(code, {
9646
+ filename: chunk.fileName
9647
+ });
9648
+ var match = (_code$match = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match === void 0 ? void 0 : _code$match[0];
9649
+ if (match) {
9650
+ // Add injected code after any comments or "use strict" at the beginning of the bundle.
9651
+ ms.appendLeft(match.length, injectionCode);
9652
+ } else {
9653
+ // ms.replace() doesn't work when there is an empty string match (which happens if
9654
+ // there is neither, a comment, nor a "use strict" at the top of the chunk) so we
9655
+ // need this special case here.
9656
+ ms.prepend(injectionCode);
9657
+ }
9627
9658
  return {
9628
- id: virtualReleaseInjectionFileId,
9629
- external: false,
9630
- moduleSideEffects: true
9659
+ code: ms.toString(),
9660
+ map: ms.generateMap({
9661
+ file: chunk.fileName,
9662
+ hires: "boundary"
9663
+ })
9631
9664
  };
9632
9665
  } else {
9633
- return null;
9634
- }
9635
- },
9636
- load: function load(id) {
9637
- if (id === virtualReleaseInjectionFileId) {
9638
- return injectionCode;
9639
- } else {
9640
- return null;
9641
- }
9642
- },
9643
- transform: function transform(code, id) {
9644
- if (id === virtualReleaseInjectionFileId) {
9645
- return null;
9646
- }
9647
-
9648
- // id may contain query and hash which will trip up our file extension logic below
9649
- var idWithoutQueryAndHash = stripQueryAndHashFromPath(id);
9650
- if (idWithoutQueryAndHash.match(/\\node_modules\\|\/node_modules\//)) {
9651
- return null;
9652
- }
9653
- if (![".js", ".ts", ".jsx", ".tsx", ".mjs"].some(function (ending) {
9654
- return idWithoutQueryAndHash.endsWith(ending);
9655
- })) {
9656
- return null;
9666
+ return null; // returning null means not modifying the chunk at all
9657
9667
  }
9658
- var ms = new MagicString(code);
9659
-
9660
- // Appending instead of prepending has less probability of mucking with user's source maps.
9661
- // Luckily import statements get hoisted to the top anyways.
9662
- ms.append("\n\n;import \"".concat(virtualReleaseInjectionFileId, "\";"));
9663
- return {
9664
- code: ms.toString(),
9665
- map: ms.generateMap({
9666
- hires: "boundary"
9667
- })
9668
- };
9669
9668
  }
9670
9669
  };
9671
9670
  }
9671
+
9672
9672
  function createRollupBundleSizeOptimizationHooks(replacementValues) {
9673
9673
  return {
9674
9674
  transform: function transform(code) {
@@ -9676,19 +9676,6 @@ function createRollupBundleSizeOptimizationHooks(replacementValues) {
9676
9676
  }
9677
9677
  };
9678
9678
  }
9679
-
9680
- // We need to be careful not to inject the snippet before any `"use strict";`s.
9681
- // As an additional complication `"use strict";`s may come after any number of comments.
9682
- var COMMENT_USE_STRICT_REGEX =
9683
- // Note: CodeQL complains that this regex potentially has n^2 runtime. This likely won't affect realistic files.
9684
- /^(?:\s*|\/\*(?:.|\r|\n)*?\*\/|\/\/.*[\n\r])*(?:"[^"]*";|'[^']*';)?/;
9685
-
9686
- /**
9687
- * Simplified `renderChunk` hook type from Rollup.
9688
- * We can't reference the type directly because the Vite plugin complains
9689
- * about type mismatches
9690
- */
9691
-
9692
9679
  function createRollupDebugIdInjectionHooks() {
9693
9680
  return {
9694
9681
  renderChunk: function renderChunk(code, chunk) {
@@ -9697,13 +9684,13 @@ function createRollupDebugIdInjectionHooks() {
9697
9684
  [".js", ".mjs", ".cjs"].some(function (ending) {
9698
9685
  return stripQueryAndHashFromPath(chunk.fileName).endsWith(ending);
9699
9686
  })) {
9700
- var _code$match;
9687
+ var _code$match2;
9701
9688
  var debugId = stringToUUID(code); // generate a deterministic debug ID
9702
9689
  var codeToInject = getDebugIdSnippet(debugId);
9703
9690
  var ms = new MagicString(code, {
9704
9691
  filename: chunk.fileName
9705
9692
  });
9706
- var match = (_code$match = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match === void 0 ? void 0 : _code$match[0];
9693
+ var match = (_code$match2 = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match2 === void 0 ? void 0 : _code$match2[0];
9707
9694
  if (match) {
9708
9695
  // Add injected code after any comments or "use strict" at the beginning of the bundle.
9709
9696
  ms.appendLeft(match.length, codeToInject);
@@ -9735,11 +9722,11 @@ function createRollupModuleMetadataInjectionHooks(injectionCode) {
9735
9722
  [".js", ".mjs", ".cjs"].some(function (ending) {
9736
9723
  return stripQueryAndHashFromPath(chunk.fileName).endsWith(ending);
9737
9724
  })) {
9738
- var _code$match2;
9725
+ var _code$match3;
9739
9726
  var ms = new MagicString(code, {
9740
9727
  filename: chunk.fileName
9741
9728
  });
9742
- var match = (_code$match2 = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match2 === void 0 ? void 0 : _code$match2[0];
9729
+ var match = (_code$match3 = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match3 === void 0 ? void 0 : _code$match3[0];
9743
9730
  if (match) {
9744
9731
  // Add injected code after any comments or "use strict" at the beginning of the bundle.
9745
9732
  ms.appendLeft(match.length, injectionCode);
@@ -9895,7 +9882,7 @@ function createComponentNameAnnotateHooks(ignoredComponents) {
9895
9882
  };
9896
9883
  }
9897
9884
  function getDebugIdSnippet(debugId) {
9898
- return ";{try{let e=\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=\"".concat(debugId, "\",e._sentryDebugIdIdentifier=\"sentry-dbid-").concat(debugId, "\")}catch(e){}};");
9885
+ return ";{try{(function(){var e=\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=\"".concat(debugId, "\",e._sentryDebugIdIdentifier=\"sentry-dbid-").concat(debugId, "\");})();}catch(e){}};");
9899
9886
  }
9900
9887
 
9901
9888
  export { createComponentNameAnnotateHooks, createRollupBundleSizeOptimizationHooks, createRollupDebugIdInjectionHooks, createRollupDebugIdUploadHooks, createRollupModuleMetadataInjectionHooks, createRollupReleaseInjectionHooks, createSentryBuildPluginManager, getDebugIdSnippet, replaceBooleanFlagsInCode, sentryCliBinaryExists, sentryUnpluginFactory, stringToUUID };