@sentry/bundler-plugins 11.10.0 → 11.12.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.
Files changed (84) hide show
  1. package/build/cjs/core/build-plugin-manager.js +184 -33
  2. package/build/cjs/core/build-plugin-manager.js.map +1 -1
  3. package/build/cjs/core/debug-id-upload.js +63 -54
  4. package/build/cjs/core/debug-id-upload.js.map +1 -1
  5. package/build/cjs/core/index.js +2 -0
  6. package/build/cjs/core/index.js.map +1 -1
  7. package/build/cjs/core/options-mapping.js +6 -0
  8. package/build/cjs/core/options-mapping.js.map +1 -1
  9. package/build/cjs/core/sentry/telemetry.js +4 -0
  10. package/build/cjs/core/sentry/telemetry.js.map +1 -1
  11. package/build/cjs/core/sourcemap-settings.js +63 -0
  12. package/build/cjs/core/sourcemap-settings.js.map +1 -0
  13. package/build/cjs/core/upload-filter.js +57 -0
  14. package/build/cjs/core/upload-filter.js.map +1 -0
  15. package/build/cjs/core/version.js +1 -1
  16. package/build/cjs/core/version.js.map +1 -1
  17. package/build/cjs/esbuild/index.js +3 -2
  18. package/build/cjs/esbuild/index.js.map +1 -1
  19. package/build/cjs/rollup/index.js +49 -9
  20. package/build/cjs/rollup/index.js.map +1 -1
  21. package/build/cjs/rollup/source-map-handling.js +202 -0
  22. package/build/cjs/rollup/source-map-handling.js.map +1 -0
  23. package/build/cjs/vite/index.js +4 -18
  24. package/build/cjs/vite/index.js.map +1 -1
  25. package/build/cjs/vite/source-map-hooks.js +93 -0
  26. package/build/cjs/vite/source-map-hooks.js.map +1 -0
  27. package/build/cjs/webpack/index.js +113 -1
  28. package/build/cjs/webpack/index.js.map +1 -1
  29. package/build/esm/core/build-plugin-manager.js +185 -34
  30. package/build/esm/core/build-plugin-manager.js.map +1 -1
  31. package/build/esm/core/debug-id-upload.js +62 -56
  32. package/build/esm/core/debug-id-upload.js.map +1 -1
  33. package/build/esm/core/index.js +1 -0
  34. package/build/esm/core/index.js.map +1 -1
  35. package/build/esm/core/options-mapping.js +6 -0
  36. package/build/esm/core/options-mapping.js.map +1 -1
  37. package/build/esm/core/sentry/telemetry.js +4 -0
  38. package/build/esm/core/sentry/telemetry.js.map +1 -1
  39. package/build/esm/core/sourcemap-settings.js +61 -0
  40. package/build/esm/core/sourcemap-settings.js.map +1 -0
  41. package/build/esm/core/upload-filter.js +41 -0
  42. package/build/esm/core/upload-filter.js.map +1 -0
  43. package/build/esm/core/version.js +1 -1
  44. package/build/esm/core/version.js.map +1 -1
  45. package/build/esm/esbuild/index.js +3 -2
  46. package/build/esm/esbuild/index.js.map +1 -1
  47. package/build/esm/package.json +1 -1
  48. package/build/esm/rollup/index.js +49 -10
  49. package/build/esm/rollup/index.js.map +1 -1
  50. package/build/esm/rollup/source-map-handling.js +183 -0
  51. package/build/esm/rollup/source-map-handling.js.map +1 -0
  52. package/build/esm/vite/index.js +5 -19
  53. package/build/esm/vite/index.js.map +1 -1
  54. package/build/esm/vite/source-map-hooks.js +77 -0
  55. package/build/esm/vite/source-map-hooks.js.map +1 -0
  56. package/build/esm/webpack/index.js +114 -2
  57. package/build/esm/webpack/index.js.map +1 -1
  58. package/build/types/core/build-plugin-manager.d.ts +69 -1
  59. package/build/types/core/build-plugin-manager.d.ts.map +1 -1
  60. package/build/types/core/debug-id-upload.d.ts +38 -2
  61. package/build/types/core/debug-id-upload.d.ts.map +1 -1
  62. package/build/types/core/index.d.ts +4 -0
  63. package/build/types/core/index.d.ts.map +1 -1
  64. package/build/types/core/options-mapping.d.ts +1 -0
  65. package/build/types/core/options-mapping.d.ts.map +1 -1
  66. package/build/types/core/sentry/telemetry.d.ts.map +1 -1
  67. package/build/types/core/sourcemap-settings.d.ts +28 -0
  68. package/build/types/core/sourcemap-settings.d.ts.map +1 -0
  69. package/build/types/core/types.d.ts +18 -0
  70. package/build/types/core/types.d.ts.map +1 -1
  71. package/build/types/core/upload-filter.d.ts +9 -0
  72. package/build/types/core/upload-filter.d.ts.map +1 -0
  73. package/build/types/core/version.d.ts +1 -1
  74. package/build/types/esbuild/index.d.ts.map +1 -1
  75. package/build/types/rollup/index.d.ts +106 -6
  76. package/build/types/rollup/index.d.ts.map +1 -1
  77. package/build/types/rollup/source-map-handling.d.ts +59 -0
  78. package/build/types/rollup/source-map-handling.d.ts.map +1 -0
  79. package/build/types/vite/index.d.ts +1 -5
  80. package/build/types/vite/index.d.ts.map +1 -1
  81. package/build/types/vite/source-map-hooks.d.ts +45 -0
  82. package/build/types/vite/source-map-hooks.d.ts.map +1 -0
  83. package/build/types/webpack/index.d.ts.map +1 -1
  84. package/package.json +43 -41
@@ -26,52 +26,90 @@ const url__namespace = /*#__PURE__*/_interopNamespace(url);
26
26
  const util__namespace = /*#__PURE__*/_interopNamespace(util);
27
27
 
28
28
  function createDebugIdUploadFunction({ sentryBuildPluginManager }) {
29
- return async (buildArtifactPaths) => {
29
+ return async (buildArtifactPaths, opts) => {
30
30
  const cleanedPaths = buildArtifactPaths.map(utils.stripQueryAndHashFromPath);
31
- await sentryBuildPluginManager.uploadSourcemaps(cleanedPaths);
31
+ return sentryBuildPluginManager.uploadSourcemaps(cleanedPaths, opts);
32
32
  };
33
33
  }
34
34
  async function prepareBundleForDebugIdUpload(bundleFilePath, uploadFolder, chunkIndex, logger, rewriteSourcesHook, resolveSourceMapHook) {
35
35
  let bundleContent;
36
36
  try {
37
- bundleContent = await util.promisify(fs__default.readFile)(bundleFilePath, "utf8");
37
+ bundleContent = await fs__default.promises.readFile(bundleFilePath, "utf8");
38
38
  } catch (e) {
39
39
  logger.error(`Could not read bundle to determine debug ID and source map: ${bundleFilePath}`, e);
40
40
  return;
41
41
  }
42
- const debugId = determineDebugIdFromBundleSource(bundleContent);
43
- if (debugId === void 0) {
42
+ if (determineDebugIdFromBundleSource(bundleContent) === void 0) {
44
43
  logger.debug(
45
44
  `Could not determine debug ID from bundle. This can happen if you did not clean your output folder before installing the Sentry plugin. File will not be source mapped: ${bundleFilePath}`
46
45
  );
47
46
  return;
48
47
  }
49
- const uniqueUploadName = `${debugId}-${chunkIndex}`;
50
- bundleContent = addDebugIdToBundleSource(bundleContent, debugId);
51
48
  const sourceMapPath = await determineSourceMapPathFromBundle(
52
49
  bundleFilePath,
53
50
  bundleContent,
54
51
  logger,
55
52
  resolveSourceMapHook
56
53
  );
57
- if (!sourceMapPath && !bundleHasInlineSourceMap(bundleContent)) {
58
- logger.debug(`Not uploading bundle without a source map: ${bundleFilePath}`);
54
+ let sourceMapSource;
55
+ if (sourceMapPath) {
56
+ try {
57
+ sourceMapSource = await fs__default.promises.readFile(sourceMapPath, "utf8");
58
+ } catch (e) {
59
+ logger.error(`Failed to read source map for debug ID upload: ${sourceMapPath}`, e);
60
+ return;
61
+ }
62
+ }
63
+ const result = prepareArtifactForUpload({
64
+ code: bundleContent,
65
+ mapSource: sourceMapSource,
66
+ mapDir: path__default.dirname(sourceMapPath ?? bundleFilePath),
67
+ rewriteSourcesHook
68
+ });
69
+ if (!result.ok) {
70
+ if (result.reason === "invalid-source-map") {
71
+ logger.error(`Failed to parse source map for debug ID upload: ${sourceMapPath}`);
72
+ } else {
73
+ logger.debug(`Not uploading bundle without a source map: ${bundleFilePath}`);
74
+ }
59
75
  return;
60
76
  }
61
- const writeSourceFilePromise = fs__default.promises.writeFile(
62
- path__default.join(uploadFolder, `${uniqueUploadName}.js`),
63
- bundleContent,
64
- "utf-8"
65
- );
66
- const writeSourceMapFilePromise = sourceMapPath ? prepareSourceMapForDebugIdUpload(
67
- sourceMapPath,
68
- path__default.join(uploadFolder, `${uniqueUploadName}.js.map`),
69
- debugId,
70
- rewriteSourcesHook,
71
- logger
72
- ) : Promise.resolve();
73
- await writeSourceFilePromise;
74
- await writeSourceMapFilePromise;
77
+ await writePreparedArtifact(uploadFolder, `${result.artifact.debugId}-${chunkIndex}`, result.artifact);
78
+ }
79
+ function prepareArtifactForUpload(input) {
80
+ const debugId = determineDebugIdFromBundleSource(input.code);
81
+ if (debugId === void 0) {
82
+ return { ok: false, reason: "no-debug-id" };
83
+ }
84
+ const bundleSource = addDebugIdToBundleSource(input.code, debugId);
85
+ if (input.mapSource === void 0) {
86
+ if (!bundleHasInlineSourceMap(input.code)) {
87
+ return { ok: false, reason: "no-source-map" };
88
+ }
89
+ return { ok: true, artifact: { debugId, bundleSource, sourceMapSource: void 0 } };
90
+ }
91
+ const map = parseSourceMap(input.mapSource);
92
+ if (!map) {
93
+ return { ok: false, reason: "invalid-source-map" };
94
+ }
95
+ setDebugIdOnSourceMap(map, debugId);
96
+ if (Array.isArray(map["sources"])) {
97
+ map["sources"] = map["sources"].map(
98
+ (source) => input.rewriteSourcesHook(source, map, { mapDir: input.mapDir })
99
+ );
100
+ }
101
+ return { ok: true, artifact: { debugId, bundleSource, sourceMapSource: JSON.stringify(map) } };
102
+ }
103
+ async function writePreparedArtifact(uploadFolder, uniqueUploadName, artifact) {
104
+ const writes = [
105
+ fs__default.promises.writeFile(path__default.join(uploadFolder, `${uniqueUploadName}.js`), artifact.bundleSource, "utf-8")
106
+ ];
107
+ if (artifact.sourceMapSource !== void 0) {
108
+ writes.push(
109
+ fs__default.promises.writeFile(path__default.join(uploadFolder, `${uniqueUploadName}.js.map`), artifact.sourceMapSource, "utf-8")
110
+ );
111
+ }
112
+ await Promise.all(writes);
75
113
  }
76
114
  function determineDebugIdFromBundleSource(code) {
77
115
  const match = code.match(
@@ -214,37 +252,6 @@ async function determineSourceMapPathFromBundle(bundlePath, bundleSource, logger
214
252
  );
215
253
  return void 0;
216
254
  }
217
- async function prepareSourceMapForDebugIdUpload(sourceMapPath, targetPath, debugId, rewriteSourcesHook, logger) {
218
- let sourceMapFileContent;
219
- try {
220
- sourceMapFileContent = await util__namespace.promisify(fs__default.readFile)(sourceMapPath, {
221
- encoding: "utf8"
222
- });
223
- } catch (e) {
224
- logger.error(`Failed to read source map for debug ID upload: ${sourceMapPath}`, e);
225
- return;
226
- }
227
- let map;
228
- try {
229
- map = JSON.parse(sourceMapFileContent);
230
- setDebugIdOnSourceMap(map, debugId);
231
- } catch {
232
- logger.error(`Failed to parse source map for debug ID upload: ${sourceMapPath}`);
233
- return;
234
- }
235
- if (map["sources"] && Array.isArray(map["sources"])) {
236
- const mapDir = path__default.dirname(sourceMapPath);
237
- map["sources"] = map["sources"].map((source) => rewriteSourcesHook(source, map, { mapDir }));
238
- }
239
- try {
240
- await util__namespace.promisify(fs__default.writeFile)(targetPath, JSON.stringify(map), {
241
- encoding: "utf8"
242
- });
243
- } catch (e) {
244
- logger.error(`Failed to prepare source map for debug ID upload: ${sourceMapPath}`, e);
245
- return;
246
- }
247
- }
248
255
  const PROTOCOL_REGEX = /^[a-zA-Z][a-zA-Z0-9+\-.]*:\/\//;
249
256
  function defaultRewriteSourcesHook(source) {
250
257
  if (source.match(PROTOCOL_REGEX)) {
@@ -258,6 +265,8 @@ exports.addDebugIdToEmittedArtifacts = addDebugIdToEmittedArtifacts;
258
265
  exports.createDebugIdUploadFunction = createDebugIdUploadFunction;
259
266
  exports.defaultRewriteSourcesHook = defaultRewriteSourcesHook;
260
267
  exports.determineSourceMapPathFromBundle = determineSourceMapPathFromBundle;
268
+ exports.prepareArtifactForUpload = prepareArtifactForUpload;
261
269
  exports.prepareBundleForDebugIdUpload = prepareBundleForDebugIdUpload;
262
270
  exports.stampDebugId = stampDebugId;
271
+ exports.writePreparedArtifact = writePreparedArtifact;
263
272
  //# sourceMappingURL=debug-id-upload.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"debug-id-upload.js","sources":["../../../src/core/debug-id-upload.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport * as url from 'url';\nimport * as util from 'util';\nimport { promisify } from 'util';\nimport type { SentryBuildPluginManager } from './build-plugin-manager';\nimport type { Logger } from './logger';\nimport type { ResolveSourceMapHook, RewriteSourcesHook } from './types';\nimport { stripQueryAndHashFromPath } from './utils';\n\ninterface DebugIdUploadPluginOptions {\n sentryBuildPluginManager: SentryBuildPluginManager;\n}\n\nexport function createDebugIdUploadFunction({ sentryBuildPluginManager }: DebugIdUploadPluginOptions) {\n return async (buildArtifactPaths: string[]) => {\n // Webpack and perhaps other bundlers allow you to append query strings to\n // filenames for cache busting purposes. We should strip these before upload.\n const cleanedPaths = buildArtifactPaths.map(stripQueryAndHashFromPath);\n await sentryBuildPluginManager.uploadSourcemaps(cleanedPaths);\n };\n}\n\nexport async function prepareBundleForDebugIdUpload(\n bundleFilePath: string,\n uploadFolder: string,\n chunkIndex: number,\n logger: Logger,\n rewriteSourcesHook: RewriteSourcesHook,\n resolveSourceMapHook: ResolveSourceMapHook | undefined,\n): Promise<void> {\n let bundleContent;\n try {\n bundleContent = await promisify(fs.readFile)(bundleFilePath, 'utf8');\n } catch (e) {\n logger.error(`Could not read bundle to determine debug ID and source map: ${bundleFilePath}`, e);\n return;\n }\n\n const debugId = determineDebugIdFromBundleSource(bundleContent);\n if (debugId === undefined) {\n logger.debug(\n `Could not determine debug ID from bundle. This can happen if you did not clean your output folder before installing the Sentry plugin. File will not be source mapped: ${bundleFilePath}`,\n );\n return;\n }\n\n const uniqueUploadName = `${debugId}-${chunkIndex}`;\n\n bundleContent = addDebugIdToBundleSource(bundleContent, debugId);\n\n const sourceMapPath = await determineSourceMapPathFromBundle(\n bundleFilePath,\n bundleContent,\n logger,\n resolveSourceMapHook,\n );\n\n // A chunk with a debug ID but no resolvable source map\n // (e.g. framework-generated stub chunks that never emit one) can't be\n // symbolicated, so uploading its minified source alone accomplishes\n // nothing and only makes the uploader warn about a missing source map ref.\n // Skip it, unless the source map is inlined into the bundle, in which case\n // the source file carries the map itself and must still be uploaded.\n if (!sourceMapPath && !bundleHasInlineSourceMap(bundleContent)) {\n logger.debug(`Not uploading bundle without a source map: ${bundleFilePath}`);\n return;\n }\n\n const writeSourceFilePromise = fs.promises.writeFile(\n path.join(uploadFolder, `${uniqueUploadName}.js`),\n bundleContent,\n 'utf-8',\n );\n\n const writeSourceMapFilePromise = sourceMapPath\n ? prepareSourceMapForDebugIdUpload(\n sourceMapPath,\n path.join(uploadFolder, `${uniqueUploadName}.js.map`),\n debugId,\n rewriteSourcesHook,\n logger,\n )\n : Promise.resolve();\n\n await writeSourceFilePromise;\n await writeSourceMapFilePromise;\n}\n\n/**\n * Looks for a particular string pattern (`sdbid-[debug ID]`) in the bundle\n * source and extracts the bundle's debug ID from it.\n *\n * The string pattern is injected via the debug ID injection snipped.\n */\nfunction determineDebugIdFromBundleSource(code: string): string | undefined {\n const match = code.match(\n /sentry-dbid-([0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12})/,\n );\n\n if (match) {\n return match[1];\n } else {\n return undefined;\n }\n}\n\nconst SPEC_LAST_DEBUG_ID_REGEX = /\\/\\/# debugId=([a-fA-F0-9-]+)(?![\\s\\S]*\\/\\/# debugId=)/m;\n\nfunction hasSpecCompliantDebugId(bundleSource: string): boolean {\n return SPEC_LAST_DEBUG_ID_REGEX.test(bundleSource);\n}\n\nfunction addDebugIdToBundleSource(bundleSource: string, debugId: string): string {\n if (hasSpecCompliantDebugId(bundleSource)) {\n return bundleSource.replace(SPEC_LAST_DEBUG_ID_REGEX, `//# debugId=${debugId}`);\n } else {\n return `${bundleSource}\\n//# debugId=${debugId}`;\n }\n}\n\nfunction setDebugIdOnSourceMap(map: Record<string, unknown>, debugId: string): void {\n // For now we write both fields until we know what will become the standard - if ever.\n map['debug_id'] = debugId;\n map['debugId'] = debugId;\n}\n\nexport type StampedArtifacts = {\n bundleSource: string;\n /** `undefined` when the bundle has no separate source map (i.e. the map is inlined). */\n sourceMapSource: string | undefined;\n};\n\nfunction parseSourceMap(sourceMapSource: string): Record<string, unknown> | undefined {\n let map: unknown;\n try {\n map = JSON.parse(sourceMapSource);\n } catch {\n return undefined;\n }\n\n return map && typeof map === 'object' ? (map as Record<string, unknown>) : undefined;\n}\n\n/**\n * Stamps the debug ID injected into `bundleSource` into the bundle (as `//# debugId=` comment) and its\n * source map (as `debug_id`/`debugId` fields).\n *\n * This exists for `sourcemaps.disable: \"disable-upload\"`: the regular upload path only stamps\n * temporary copies of the artifacts (see `prepareBundleForDebugIdUpload`), so without this the\n * emitted artifacts would carry no debug ID and a later manual upload could not match them.\n * Callers must apply the result inside the bundler's asset pipeline (or, for bundlers without one,\n * before the build resolves) so that integrity hashes computed by later build steps include it.\n *\n * Pass `sourceMapSource: undefined` when the bundle has no separate source map. A bundle with an\n * inlined map still gets the comment, which is all the CLI and Symbolicator read the debug ID from.\n *\n * @returns the stamped artifacts, or `undefined` for bundles without a debug ID, without any source\n * map, or with an unparseable map.\n */\nexport function stampDebugId(bundleSource: string, sourceMapSource: string | undefined): StampedArtifacts | undefined {\n const debugId = determineDebugIdFromBundleSource(bundleSource);\n if (debugId === undefined) {\n return undefined;\n }\n\n if (sourceMapSource === undefined) {\n if (!bundleHasInlineSourceMap(bundleSource)) {\n return undefined;\n }\n\n return { bundleSource: addDebugIdToBundleSource(bundleSource, debugId), sourceMapSource: undefined };\n }\n\n const map = parseSourceMap(sourceMapSource);\n if (!map) {\n return undefined;\n }\n\n setDebugIdOnSourceMap(map, debugId);\n\n return {\n bundleSource: addDebugIdToBundleSource(bundleSource, debugId),\n sourceMapSource: JSON.stringify(map),\n };\n}\n\n/**\n * Stamps the debug ID of an emitted bundle into the bundle and its source map on disk.\n *\n * Used by bundlers that offer no hook to modify assets before they are written (esbuild).\n */\nexport async function addDebugIdToEmittedArtifacts(\n bundleFilePath: string,\n logger: Logger,\n resolveSourceMapHook: ResolveSourceMapHook | undefined,\n): Promise<void> {\n let bundleSource: string;\n try {\n bundleSource = await fs.promises.readFile(bundleFilePath, 'utf8');\n } catch (e) {\n logger.error(`Could not read bundle to stamp debug ID: ${bundleFilePath}`, e);\n return;\n }\n\n const sourceMapPath = await determineSourceMapPathFromBundle(\n bundleFilePath,\n bundleSource,\n logger,\n resolveSourceMapHook,\n );\n\n let sourceMapSource: string | undefined;\n if (sourceMapPath) {\n try {\n sourceMapSource = await fs.promises.readFile(sourceMapPath, 'utf8');\n } catch (e) {\n logger.error(`Could not read source map to stamp debug ID: ${sourceMapPath}`, e);\n return;\n }\n }\n\n const stamped = stampDebugId(bundleSource, sourceMapSource);\n if (!stamped) {\n logger.debug(\n `Could not stamp debug ID (no debug ID in bundle, no source map, or invalid source map): ${bundleFilePath}`,\n );\n return;\n }\n\n const writes = [fs.promises.writeFile(bundleFilePath, stamped.bundleSource, 'utf8')];\n if (sourceMapPath && stamped.sourceMapSource !== undefined) {\n writes.push(fs.promises.writeFile(sourceMapPath, stamped.sourceMapSource, 'utf8'));\n }\n\n try {\n await Promise.all(writes);\n } catch (e) {\n logger.error(`Could not write debug ID into build artifacts: ${bundleFilePath}`, e);\n }\n}\n\n/**\n * Whether the bundle carries its source map inlined as `sourceMappingURL=data:`\n * URI, rather than referencing a separate `.map` file. Such bundles must still\n * be uploaded even when no `.map` file is found, because the source file itself\n * contains the map.\n */\nfunction bundleHasInlineSourceMap(bundleSource: string): boolean {\n return /^\\s*\\/\\/# sourceMappingURL=data:/m.test(bundleSource);\n}\n\n/**\n * Applies a set of heuristics to find the source map for a particular bundle.\n *\n * @returns the path to the bundle's source map or `undefined` if none could be found.\n */\nexport async function determineSourceMapPathFromBundle(\n bundlePath: string,\n bundleSource: string,\n logger: Logger,\n resolveSourceMapHook: ResolveSourceMapHook | undefined,\n): Promise<string | undefined> {\n const sourceMappingUrlMatch = bundleSource.match(/^\\s*\\/\\/# sourceMappingURL=(.*)$/m);\n const sourceMappingUrl = sourceMappingUrlMatch ? (sourceMappingUrlMatch[1] as string) : undefined;\n\n const searchLocations: string[] = [];\n\n if (resolveSourceMapHook) {\n logger.debug(\n `Calling sourcemaps.resolveSourceMap(${JSON.stringify(bundlePath)}, ${JSON.stringify(sourceMappingUrl)})`,\n );\n const customPath = await resolveSourceMapHook(bundlePath, sourceMappingUrl);\n logger.debug(`resolveSourceMap hook returned: ${JSON.stringify(customPath)}`);\n\n if (customPath) {\n searchLocations.push(customPath);\n }\n }\n\n // 1. try to find source map at `sourceMappingURL` location\n if (sourceMappingUrl) {\n let parsedUrl: URL | undefined;\n try {\n parsedUrl = new URL(sourceMappingUrl);\n } catch {\n // noop\n }\n\n if (parsedUrl?.protocol === 'file:') {\n searchLocations.push(url.fileURLToPath(sourceMappingUrl));\n } else if (parsedUrl) {\n // noop, non-file urls don't translate to a local sourcemap file\n } else if (path.isAbsolute(sourceMappingUrl)) {\n searchLocations.push(path.normalize(sourceMappingUrl));\n } else {\n searchLocations.push(path.normalize(path.join(path.dirname(bundlePath), sourceMappingUrl)));\n }\n }\n\n // 2. try to find source map at path adjacent to chunk source, but with `.map` appended\n searchLocations.push(`${bundlePath}.map`);\n\n for (const searchLocation of searchLocations) {\n try {\n await util.promisify(fs.access)(searchLocation);\n logger.debug(`Source map found for bundle \\`${bundlePath}\\`: \\`${searchLocation}\\``);\n return searchLocation;\n } catch {\n // noop\n }\n }\n\n // This is just a debug message because it can be quite spammy for some frameworks\n logger.debug(\n `Could not determine source map path for bundle \\`${bundlePath}\\`` +\n ` with sourceMappingURL=${sourceMappingUrl === undefined ? 'undefined' : `\\`${sourceMappingUrl}\\``}` +\n ` - Did you turn on source map generation in your bundler?` +\n ` (Attempted paths: ${searchLocations.map(e => `\\`${e}\\``).join(', ')})`,\n );\n return undefined;\n}\n\n/**\n * Reads a source map, injects debug ID fields, and writes the source map to the target path.\n */\nasync function prepareSourceMapForDebugIdUpload(\n sourceMapPath: string,\n targetPath: string,\n debugId: string,\n rewriteSourcesHook: RewriteSourcesHook,\n logger: Logger,\n): Promise<void> {\n let sourceMapFileContent: string;\n try {\n sourceMapFileContent = await util.promisify(fs.readFile)(sourceMapPath, {\n encoding: 'utf8',\n });\n } catch (e) {\n logger.error(`Failed to read source map for debug ID upload: ${sourceMapPath}`, e);\n return;\n }\n\n let map: Record<string, unknown>;\n try {\n map = JSON.parse(sourceMapFileContent) as { sources: unknown; [key: string]: unknown };\n setDebugIdOnSourceMap(map, debugId);\n } catch {\n logger.error(`Failed to parse source map for debug ID upload: ${sourceMapPath}`);\n return;\n }\n\n if (map['sources'] && Array.isArray(map['sources'])) {\n const mapDir = path.dirname(sourceMapPath);\n map['sources'] = map['sources'].map((source: string) => rewriteSourcesHook(source, map, { mapDir }));\n }\n\n try {\n await util.promisify(fs.writeFile)(targetPath, JSON.stringify(map), {\n encoding: 'utf8',\n });\n } catch (e) {\n logger.error(`Failed to prepare source map for debug ID upload: ${sourceMapPath}`, e);\n return;\n }\n}\n\nconst PROTOCOL_REGEX = /^[a-zA-Z][a-zA-Z0-9+\\-.]*:\\/\\//;\nexport function defaultRewriteSourcesHook(source: string): string {\n if (source.match(PROTOCOL_REGEX)) {\n return source.replace(PROTOCOL_REGEX, '');\n } else {\n return path.relative(process.cwd(), path.normalize(source));\n }\n}\n"],"names":["stripQueryAndHashFromPath","promisify","fs","path","url","util"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAcO,SAAS,2BAAA,CAA4B,EAAE,wBAAA,EAAyB,EAA+B;AACpG,EAAA,OAAO,OAAO,kBAAA,KAAiC;AAG7C,IAAA,MAAM,YAAA,GAAe,kBAAA,CAAmB,GAAA,CAAIA,+BAAyB,CAAA;AACrE,IAAA,MAAM,wBAAA,CAAyB,iBAAiB,YAAY,CAAA;AAAA,EAC9D,CAAA;AACF;AAEA,eAAsB,8BACpB,cAAA,EACA,YAAA,EACA,UAAA,EACA,MAAA,EACA,oBACA,oBAAA,EACe;AACf,EAAA,IAAI,aAAA;AACJ,EAAA,IAAI;AACF,IAAA,aAAA,GAAgB,MAAMC,cAAA,CAAUC,WAAA,CAAG,QAAQ,CAAA,CAAE,gBAAgB,MAAM,CAAA;AAAA,EACrE,SAAS,CAAA,EAAG;AACV,IAAA,MAAA,CAAO,KAAA,CAAM,CAAA,4DAAA,EAA+D,cAAc,CAAA,CAAA,EAAI,CAAC,CAAA;AAC/F,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,OAAA,GAAU,iCAAiC,aAAa,CAAA;AAC9D,EAAA,IA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AAK,OAAA,CAAQ,aAAa,CAAA;AACzC,IAAA,GAAA,CAAI,SAAS,CAAA,GAAI,GAAA,CAAI,SAAS,EAAE,GAAA,CAAI,CAAC,MAAA,KAAmB,kBAAA,CAAmB,MAAA,EAAQ,GAAA,EAAK,EAAE,MAAA,EAAQ,CAAC,CAAA;AAAA,EACrG;AAEA,EAAA,IAAI;AACF,IAAA,MAAME,eAAA,CAAK,UAAUH,WAAA,CAAG,SAAS,EAAE,UAAA,EAAY,IAAA,CAAK,SAAA,CAAU,GAAG,CAAA,EAAG;AAAA,MAClE,QAAA,EAAU;AAAA,KACX,CAAA;AAAA,EACH,SAAS,CAAA,EAAG;AACV,IAAA,MAAA,CAAO,KAAA,CAAM,CAAA,kDAAA,EAAqD,aAAa,CAAA,CAAA,EAAI,CAAC,CAAA;AACpF,IAAA;AAAA,EACF;AACF;AAEA,MAAM,cAAA,GAAiB,gCAAA;AAChB,SAAS,0BAA0B,MAAA,EAAwB;AAChE,EAAA,IAAI,MAAA,CAAO,KAAA,CAAM,cAAc,CAAA,EAAG;AAChC,IAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,cAAA,EAAgB,EAAE,CAAA;AAAA,EAC1C,CAAA,MAAO;AACL,IAAA,OAAOC,aAAA,CAAK,SAAS,OAAA,CAAQ,GAAA,IAAOA,aAAA,CAAK,SAAA,CAAU,MAAM,CAAC,CAAA;AAAA,EAC5D;AACF;;;;;;;;;"}
1
+ {"version":3,"file":"debug-id-upload.js","sources":["../../../src/core/debug-id-upload.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport * as url from 'url';\nimport * as util from 'util';\nimport type { SentryBuildPluginManager, UploadStaging } from './build-plugin-manager';\nimport type { Logger } from './logger';\nimport type { ResolveSourceMapHook, RewriteSourcesHook } from './types';\nimport { stripQueryAndHashFromPath } from './utils';\n\ninterface DebugIdUploadPluginOptions {\n sentryBuildPluginManager: SentryBuildPluginManager;\n}\n\nexport function createDebugIdUploadFunction({ sentryBuildPluginManager }: DebugIdUploadPluginOptions) {\n return async (buildArtifactPaths: string[], opts?: { staging?: UploadStaging }) => {\n // Webpack and perhaps other bundlers allow you to append query strings to\n // filenames for cache busting purposes. We should strip these before upload.\n const cleanedPaths = buildArtifactPaths.map(stripQueryAndHashFromPath);\n return sentryBuildPluginManager.uploadSourcemaps(cleanedPaths, opts);\n };\n}\n\nexport async function prepareBundleForDebugIdUpload(\n bundleFilePath: string,\n uploadFolder: string,\n chunkIndex: number,\n logger: Logger,\n rewriteSourcesHook: RewriteSourcesHook,\n resolveSourceMapHook: ResolveSourceMapHook | undefined,\n): Promise<void> {\n let bundleContent: string;\n try {\n bundleContent = await fs.promises.readFile(bundleFilePath, 'utf8');\n } catch (e) {\n logger.error(`Could not read bundle to determine debug ID and source map: ${bundleFilePath}`, e);\n return;\n }\n\n if (determineDebugIdFromBundleSource(bundleContent) === undefined) {\n logger.debug(\n `Could not determine debug ID from bundle. This can happen if you did not clean your output folder before installing the Sentry plugin. File will not be source mapped: ${bundleFilePath}`,\n );\n return;\n }\n\n const sourceMapPath = await determineSourceMapPathFromBundle(\n bundleFilePath,\n bundleContent,\n logger,\n resolveSourceMapHook,\n );\n\n let sourceMapSource: string | undefined;\n if (sourceMapPath) {\n try {\n sourceMapSource = await fs.promises.readFile(sourceMapPath, 'utf8');\n } catch (e) {\n logger.error(`Failed to read source map for debug ID upload: ${sourceMapPath}`, e);\n return;\n }\n }\n\n const result = prepareArtifactForUpload({\n code: bundleContent,\n mapSource: sourceMapSource,\n mapDir: path.dirname(sourceMapPath ?? bundleFilePath),\n rewriteSourcesHook,\n });\n\n if (!result.ok) {\n if (result.reason === 'invalid-source-map') {\n logger.error(`Failed to parse source map for debug ID upload: ${sourceMapPath}`);\n } else {\n // A chunk with a debug ID but no resolvable source map\n // (e.g. framework-generated stub chunks that never emit one) can't be\n // symbolicated, so uploading its minified source alone accomplishes\n // nothing and only makes the uploader warn about a missing source map ref.\n logger.debug(`Not uploading bundle without a source map: ${bundleFilePath}`);\n }\n return;\n }\n\n await writePreparedArtifact(uploadFolder, `${result.artifact.debugId}-${chunkIndex}`, result.artifact);\n}\n\nexport type PreparedUploadArtifact = {\n debugId: string;\n bundleSource: string;\n /** `undefined` when the bundle has no separate source map (i.e. the map is inlined). */\n sourceMapSource: string | undefined;\n};\n\nexport type PrepareArtifactResult =\n | { ok: true; artifact: PreparedUploadArtifact }\n | { ok: false; reason: 'no-debug-id' | 'no-source-map' | 'invalid-source-map' };\n\n/**\n * Prepares a bundle and its source map for the debug ID upload: stamps the debug ID into both\n * and runs the `rewriteSources` hook over the map's `sources`.\n *\n * Pass `mapSource: undefined` when the bundle has no separate source map. A bundle with an\n * inlined map is still prepared; a bundle without any map is skipped because it cannot be\n * symbolicated.\n */\nexport function prepareArtifactForUpload(input: {\n code: string;\n mapSource: string | undefined;\n /** Directory the source map lives in, passed to the `rewriteSources` hook. */\n mapDir: string;\n rewriteSourcesHook: RewriteSourcesHook;\n}): PrepareArtifactResult {\n const debugId = determineDebugIdFromBundleSource(input.code);\n if (debugId === undefined) {\n return { ok: false, reason: 'no-debug-id' };\n }\n\n const bundleSource = addDebugIdToBundleSource(input.code, debugId);\n\n if (input.mapSource === undefined) {\n if (!bundleHasInlineSourceMap(input.code)) {\n return { ok: false, reason: 'no-source-map' };\n }\n return { ok: true, artifact: { debugId, bundleSource, sourceMapSource: undefined } };\n }\n\n const map = parseSourceMap(input.mapSource);\n if (!map) {\n return { ok: false, reason: 'invalid-source-map' };\n }\n\n setDebugIdOnSourceMap(map, debugId);\n\n if (Array.isArray(map['sources'])) {\n map['sources'] = map['sources'].map((source: string) =>\n input.rewriteSourcesHook(source, map, { mapDir: input.mapDir }),\n );\n }\n\n return { ok: true, artifact: { debugId, bundleSource, sourceMapSource: JSON.stringify(map) } };\n}\n\n/**\n * Writes a prepared artifact as `<uniqueUploadName>.js` (and `.js.map`) into the upload folder.\n */\nexport async function writePreparedArtifact(\n uploadFolder: string,\n uniqueUploadName: string,\n artifact: PreparedUploadArtifact,\n): Promise<void> {\n const writes = [\n fs.promises.writeFile(path.join(uploadFolder, `${uniqueUploadName}.js`), artifact.bundleSource, 'utf-8'),\n ];\n\n if (artifact.sourceMapSource !== undefined) {\n writes.push(\n fs.promises.writeFile(path.join(uploadFolder, `${uniqueUploadName}.js.map`), artifact.sourceMapSource, 'utf-8'),\n );\n }\n\n await Promise.all(writes);\n}\n\n/**\n * Looks for a particular string pattern (`sdbid-[debug ID]`) in the bundle\n * source and extracts the bundle's debug ID from it.\n *\n * The string pattern is injected via the debug ID injection snipped.\n */\nfunction determineDebugIdFromBundleSource(code: string): string | undefined {\n const match = code.match(\n /sentry-dbid-([0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12})/,\n );\n\n if (match) {\n return match[1];\n } else {\n return undefined;\n }\n}\n\nconst SPEC_LAST_DEBUG_ID_REGEX = /\\/\\/# debugId=([a-fA-F0-9-]+)(?![\\s\\S]*\\/\\/# debugId=)/m;\n\nfunction hasSpecCompliantDebugId(bundleSource: string): boolean {\n return SPEC_LAST_DEBUG_ID_REGEX.test(bundleSource);\n}\n\nfunction addDebugIdToBundleSource(bundleSource: string, debugId: string): string {\n if (hasSpecCompliantDebugId(bundleSource)) {\n return bundleSource.replace(SPEC_LAST_DEBUG_ID_REGEX, `//# debugId=${debugId}`);\n } else {\n return `${bundleSource}\\n//# debugId=${debugId}`;\n }\n}\n\nfunction setDebugIdOnSourceMap(map: Record<string, unknown>, debugId: string): void {\n // For now we write both fields until we know what will become the standard - if ever.\n map['debug_id'] = debugId;\n map['debugId'] = debugId;\n}\n\nexport type StampedArtifacts = {\n bundleSource: string;\n /** `undefined` when the bundle has no separate source map (i.e. the map is inlined). */\n sourceMapSource: string | undefined;\n};\n\nfunction parseSourceMap(sourceMapSource: string): Record<string, unknown> | undefined {\n let map: unknown;\n try {\n map = JSON.parse(sourceMapSource);\n } catch {\n return undefined;\n }\n\n return map && typeof map === 'object' ? (map as Record<string, unknown>) : undefined;\n}\n\n/**\n * Stamps the debug ID injected into `bundleSource` into the bundle (as `//# debugId=` comment) and its\n * source map (as `debug_id`/`debugId` fields).\n *\n * This exists for `sourcemaps.disable: \"disable-upload\"`: the regular upload path only stamps\n * temporary copies of the artifacts (see `prepareBundleForDebugIdUpload`), so without this the\n * emitted artifacts would carry no debug ID and a later manual upload could not match them.\n * Callers must apply the result inside the bundler's asset pipeline (or, for bundlers without one,\n * before the build resolves) so that integrity hashes computed by later build steps include it.\n *\n * Pass `sourceMapSource: undefined` when the bundle has no separate source map. A bundle with an\n * inlined map still gets the comment, which is all the CLI and Symbolicator read the debug ID from.\n *\n * @returns the stamped artifacts, or `undefined` for bundles without a debug ID, without any source\n * map, or with an unparseable map.\n */\nexport function stampDebugId(bundleSource: string, sourceMapSource: string | undefined): StampedArtifacts | undefined {\n const debugId = determineDebugIdFromBundleSource(bundleSource);\n if (debugId === undefined) {\n return undefined;\n }\n\n if (sourceMapSource === undefined) {\n if (!bundleHasInlineSourceMap(bundleSource)) {\n return undefined;\n }\n\n return { bundleSource: addDebugIdToBundleSource(bundleSource, debugId), sourceMapSource: undefined };\n }\n\n const map = parseSourceMap(sourceMapSource);\n if (!map) {\n return undefined;\n }\n\n setDebugIdOnSourceMap(map, debugId);\n\n return {\n bundleSource: addDebugIdToBundleSource(bundleSource, debugId),\n sourceMapSource: JSON.stringify(map),\n };\n}\n\n/**\n * Stamps the debug ID of an emitted bundle into the bundle and its source map on disk.\n *\n * Used by bundlers that offer no hook to modify assets before they are written (esbuild).\n */\nexport async function addDebugIdToEmittedArtifacts(\n bundleFilePath: string,\n logger: Logger,\n resolveSourceMapHook: ResolveSourceMapHook | undefined,\n): Promise<void> {\n let bundleSource: string;\n try {\n bundleSource = await fs.promises.readFile(bundleFilePath, 'utf8');\n } catch (e) {\n logger.error(`Could not read bundle to stamp debug ID: ${bundleFilePath}`, e);\n return;\n }\n\n const sourceMapPath = await determineSourceMapPathFromBundle(\n bundleFilePath,\n bundleSource,\n logger,\n resolveSourceMapHook,\n );\n\n let sourceMapSource: string | undefined;\n if (sourceMapPath) {\n try {\n sourceMapSource = await fs.promises.readFile(sourceMapPath, 'utf8');\n } catch (e) {\n logger.error(`Could not read source map to stamp debug ID: ${sourceMapPath}`, e);\n return;\n }\n }\n\n const stamped = stampDebugId(bundleSource, sourceMapSource);\n if (!stamped) {\n logger.debug(\n `Could not stamp debug ID (no debug ID in bundle, no source map, or invalid source map): ${bundleFilePath}`,\n );\n return;\n }\n\n const writes = [fs.promises.writeFile(bundleFilePath, stamped.bundleSource, 'utf8')];\n if (sourceMapPath && stamped.sourceMapSource !== undefined) {\n writes.push(fs.promises.writeFile(sourceMapPath, stamped.sourceMapSource, 'utf8'));\n }\n\n try {\n await Promise.all(writes);\n } catch (e) {\n logger.error(`Could not write debug ID into build artifacts: ${bundleFilePath}`, e);\n }\n}\n\n/**\n * Whether the bundle carries its source map inlined as `sourceMappingURL=data:`\n * URI, rather than referencing a separate `.map` file. Such bundles must still\n * be uploaded even when no `.map` file is found, because the source file itself\n * contains the map.\n */\nfunction bundleHasInlineSourceMap(bundleSource: string): boolean {\n return /^\\s*\\/\\/# sourceMappingURL=data:/m.test(bundleSource);\n}\n\n/**\n * Applies a set of heuristics to find the source map for a particular bundle.\n *\n * @returns the path to the bundle's source map or `undefined` if none could be found.\n */\nexport async function determineSourceMapPathFromBundle(\n bundlePath: string,\n bundleSource: string,\n logger: Logger,\n resolveSourceMapHook: ResolveSourceMapHook | undefined,\n): Promise<string | undefined> {\n const sourceMappingUrlMatch = bundleSource.match(/^\\s*\\/\\/# sourceMappingURL=(.*)$/m);\n const sourceMappingUrl = sourceMappingUrlMatch ? (sourceMappingUrlMatch[1] as string) : undefined;\n\n const searchLocations: string[] = [];\n\n if (resolveSourceMapHook) {\n logger.debug(\n `Calling sourcemaps.resolveSourceMap(${JSON.stringify(bundlePath)}, ${JSON.stringify(sourceMappingUrl)})`,\n );\n const customPath = await resolveSourceMapHook(bundlePath, sourceMappingUrl);\n logger.debug(`resolveSourceMap hook returned: ${JSON.stringify(customPath)}`);\n\n if (customPath) {\n searchLocations.push(customPath);\n }\n }\n\n // 1. try to find source map at `sourceMappingURL` location\n if (sourceMappingUrl) {\n let parsedUrl: URL | undefined;\n try {\n parsedUrl = new URL(sourceMappingUrl);\n } catch {\n // noop\n }\n\n if (parsedUrl?.protocol === 'file:') {\n searchLocations.push(url.fileURLToPath(sourceMappingUrl));\n } else if (parsedUrl) {\n // noop, non-file urls don't translate to a local sourcemap file\n } else if (path.isAbsolute(sourceMappingUrl)) {\n searchLocations.push(path.normalize(sourceMappingUrl));\n } else {\n searchLocations.push(path.normalize(path.join(path.dirname(bundlePath), sourceMappingUrl)));\n }\n }\n\n // 2. try to find source map at path adjacent to chunk source, but with `.map` appended\n searchLocations.push(`${bundlePath}.map`);\n\n for (const searchLocation of searchLocations) {\n try {\n await util.promisify(fs.access)(searchLocation);\n logger.debug(`Source map found for bundle \\`${bundlePath}\\`: \\`${searchLocation}\\``);\n return searchLocation;\n } catch {\n // noop\n }\n }\n\n // This is just a debug message because it can be quite spammy for some frameworks\n logger.debug(\n `Could not determine source map path for bundle \\`${bundlePath}\\`` +\n ` with sourceMappingURL=${sourceMappingUrl === undefined ? 'undefined' : `\\`${sourceMappingUrl}\\``}` +\n ` - Did you turn on source map generation in your bundler?` +\n ` (Attempted paths: ${searchLocations.map(e => `\\`${e}\\``).join(', ')})`,\n );\n return undefined;\n}\n\nconst PROTOCOL_REGEX = /^[a-zA-Z][a-zA-Z0-9+\\-.]*:\\/\\//;\nexport function defaultRewriteSourcesHook(source: string): string {\n if (source.match(PROTOCOL_REGEX)) {\n return source.replace(PROTOCOL_REGEX, '');\n } else {\n return path.relative(process.cwd(), path.normalize(source));\n }\n}\n"],"names":["stripQueryAndHashFromPath","fs","path","url","util"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAaO,SAAS,2BAAA,CAA4B,EAA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CAAgB,IAAA,CAAK,CAAA,EAAG,UAAU,CAAA,IAAA,CAAM,CAAA;AAExC,EAAA,KAAA,MAAW,kBAAkB,eAAA,EAAiB;AAC5C,IAAA,IAAI;AACF,MAAA,MAAME,eAAA,CAAK,SAAA,CAAUH,WAAA,CAAG,MAAM,EAAE,cAAc,CAAA;AAC9C,MAAA,MAAA,CAAO,KAAA,CAAM,CAAA,8BAAA,EAAiC,UAAU,CAAA,MAAA,EAAS,cAAc,CAAA,EAAA,CAAI,CAAA;AACnF,MAAA,OAAO,cAAA;AAAA,IACT,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF;AAGA,EAAA,MAAA,CAAO,KAAA;AAAA,IACL,oDAAoD,UAAU,CAAA,yBAAA,EAClC,qBAAqB,MAAA,GAAY,WAAA,GAAc,KAAK,gBAAgB,CAAA,EAAA,CAAI,+EAE5E,eAAA,CAAgB,GAAA,CAAI,OAAK,CAAA,EAAA,EAAK,CAAC,IAAI,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA;AAAA,GACzE;AACA,EAAA,OAAO,MAAA;AACT;AAEA,MAAM,cAAA,GAAiB,gCAAA;AAChB,SAAS,0BAA0B,MAAA,EAAwB;AAChE,EAAA,IAAI,MAAA,CAAO,KAAA,CAAM,cAAc,CAAA,EAAG;AAChC,IAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,cAAA,EAAgB,EAAE,CAAA;AAAA,EAC1C,CAAA,MAAO;AACL,IAAA,OAAOC,aAAA,CAAK,SAAS,OAAA,CAAQ,GAAA,IAAOA,aAAA,CAAK,SAAA,CAAU,MAAM,CAAC,CAAA;AAAA,EAC5D;AACF;;;;;;;;;;;"}
@@ -6,6 +6,7 @@ const getCodeInjectionPosition = require('./get-code-injection-position.js');
6
6
  const componentAnnotateHooks = require('./component-annotate-hooks.js');
7
7
  const buildPluginManager = require('./build-plugin-manager.js');
8
8
  const debugIdUpload = require('./debug-id-upload.js');
9
+ const sourcemapSettings = require('./sourcemap-settings.js');
9
10
 
10
11
  function isJsFile(fileName) {
11
12
  const cleanFileName = utils.stripQueryAndHashFromPath(fileName);
@@ -67,6 +68,7 @@ exports.createSentryBuildPluginManager = buildPluginManager.createSentryBuildPlu
67
68
  exports.addDebugIdToEmittedArtifacts = debugIdUpload.addDebugIdToEmittedArtifacts;
68
69
  exports.createDebugIdUploadFunction = debugIdUpload.createDebugIdUploadFunction;
69
70
  exports.stampDebugId = debugIdUpload.stampDebugId;
71
+ exports.decideSourceMapHandling = sourcemapSettings.decideSourceMapHandling;
70
72
  exports.getDebugIdSnippet = getDebugIdSnippet;
71
73
  exports.isInitialChunk = isInitialChunk;
72
74
  exports.isJsFile = isJsFile;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/core/index.ts"],"sourcesContent":["import { CodeInjection, containsOnlyImports, stripQueryAndHashFromPath } from './utils';\n\n/**\n * Checks if a file is a JavaScript file based on its extension.\n * Handles query strings and hashes in the filename.\n */\nexport function isJsFile(fileName: string): boolean {\n const cleanFileName = stripQueryAndHashFromPath(fileName);\n return ['.js', '.mjs', '.cjs'].some(ext => cleanFileName.endsWith(ext));\n}\n\n/**\n * Checks if a chunk should be skipped for code injection\n *\n * This is necessary to handle Vite's MPA (multi-page application) mode where\n * HTML entry points create \"facade\" chunks that should not contain injected code.\n * See: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/829\n *\n * However, in SPA mode, the main bundle also has an HTML facade but contains\n * substantial application code. We should NOT skip injection for these bundles.\n *\n * @param code - The chunk's code content\n * @param facadeModuleId - The facade module ID (if any) - HTML files create facade chunks\n * @returns true if the chunk should be skipped\n */\nexport function shouldSkipCodeInjection(code: string, facadeModuleId: string | null | undefined): boolean {\n // Skip empty chunks - these are placeholder chunks that should be optimized away\n if (code.trim().length === 0) {\n return true;\n }\n\n // For HTML facade chunks, only skip if they contain only import statements\n if (facadeModuleId && stripQueryAndHashFromPath(facadeModuleId).endsWith('.html')) {\n return containsOnlyImports(code);\n }\n\n return false;\n}\n\nexport interface ChunkGraphNode {\n fileName: string;\n isEntry?: boolean;\n imports?: string[];\n}\n\nconst initialChunksCache = new WeakMap<Record<string, ChunkGraphNode>, Set<string>>();\n\nfunction getInitialChunks(chunks: Record<string, ChunkGraphNode>): Set<string> {\n const cached = initialChunksCache.get(chunks);\n if (cached) {\n return cached;\n }\n\n const initial = new Set<string>();\n const queue = Object.values(chunks).filter(chunk => chunk.isEntry);\n\n for (let chunk = queue.shift(); chunk; chunk = queue.shift()) {\n if (initial.has(chunk.fileName)) {\n continue;\n }\n initial.add(chunk.fileName);\n for (const imported of chunk.imports ?? []) {\n const importedChunk = chunks[imported];\n if (importedChunk) {\n queue.push(importedChunk);\n }\n }\n }\n\n initialChunksCache.set(chunks, initial);\n return initial;\n}\n\n/**\n * Whether a chunk loads at startup: it is an entry chunk, or an entry chunk\n * reaches it through static imports. Chunks that only dynamic imports reach\n * load later, after startup code already ran.\n *\n * Without the chunk graph every chunk counts as initial.\n */\nexport function isInitialChunk(\n chunk: Pick<ChunkGraphNode, 'fileName' | 'isEntry'>,\n chunks: Record<string, ChunkGraphNode> | undefined,\n): boolean {\n if (chunk.isEntry || !chunks) {\n return true;\n }\n\n return getInitialChunks(chunks).has(chunk.fileName);\n}\n\nexport { globFiles } from './glob';\nexport { getCodeInjectionPosition } from './get-code-injection-position';\n\nexport { createComponentNameAnnotateHooks } from './component-annotate-hooks';\n\nexport function getDebugIdSnippet(debugId: string): CodeInjection {\n return new CodeInjection(\n `var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=\"${debugId}\",e._sentryDebugIdIdentifier=\"sentry-dbid-${debugId}\");`,\n );\n}\n\nexport type { Logger } from './logger';\nexport type { Options, SentrySDKBuildFlags } from './types';\nexport {\n CodeInjection,\n replaceBooleanFlagsInCode,\n stringToUUID,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n} from './utils';\nexport { createSentryBuildPluginManager } from './build-plugin-manager';\nexport { createDebugIdUploadFunction, addDebugIdToEmittedArtifacts, stampDebugId } from './debug-id-upload';\n"],"names":["stripQueryAndHashFromPath","containsOnlyImports","CodeInjection"],"mappings":";;;;;;;;;AAMO,SAAS,SAAS,QAAA,EAA2B;AAClD,EAAA,MAAM,aAAA,GAAgBA,gCAA0B,QAAQ,CAAA;AACxD,EAAA,OAAO,CAAC,KAAA,EAAO,MAAA,EAAQ,MAAM,CAAA,CAAE,KAAK,CAAA,GAAA,KAAO,aAAA,CAAc,QAAA,CAAS,GAAG,CAAC,CAAA;AACxE;AAgBO,SAAS,uBAAA,CAAwB,MAAc,cAAA,EAAoD;AAExG,EAAA,IAAI,IAAA,CAAK,IAAA,EAAK,CAAE,MAAA,KAAW,CAAA,EAAG;AAC5B,IAAA,OAAO,IAAA;AAAA,EACT;AAGA,EAAA,IAAI,kBAAkBA,+BAAA,CAA0B,cAAc,CAAA,CAAE,QAAA,CAAS,OAAO,CAAA,EAAG;AACjF,IAAA,OAAOC,0BAAoB,IAAI,CAAA;AAAA,EACjC;AAEA,EAAA,OAAO,KAAA;AACT;AAQA,MAAM,kBAAA,uBAAyB,OAAA,EAAqD;AAEpF,SAAS,iBAAiB,MAAA,EAAqD;AAC7E,EAAA,MAAM,MAAA,GAAS,kBAAA,CAAmB,GAAA,CAAI,MAAM,CAAA;AAC5C,EAAA,IAAI,MAAA,EAAQ;AACV,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,MAAM,OAAA,uBAAc,GAAA,EAAY;AAChC,EAAA,MAAM,KAAA,GAAQ,OAAO,MAAA,CAAO,MAAM,EAAE,MAAA,CAAO,CAAA,KAAA,KAAS,MAAM,OAAO,CAAA;AAEjE,EAAA,KAAA,IAAS,KAAA,GAAQ,MAAM,KAAA,EAAM,EAAG,OAAO,KAAA,GAAQ,KAAA,CAAM,OAAM,EAAG;AAC5D,IAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,KAAA,CAAM,QAAQ,CAAA,EAAG;AAC/B,MAAA;AAAA,IACF;AACA,IAAA,OAAA,CAAQ,GAAA,CAAI,MAAM,QAAQ,CAAA;AAC1B,IAAA,KAAA,MAAW,QAAA,IAAY,KAAA,CAAM,OAAA,IAAW,EAAC,EAAG;AAC1C,MAAA,MAAM,aAAA,GAAgB,OAAO,QAAQ,CAAA;AACrC,MAAA,IAAI,aAAA,EAAe;AACjB,QAAA,KAAA,CAAM,KAAK,aAAa,CAAA;AAAA,MAC1B;AAAA,IACF;AAAA,EACF;AAEA,EAAA,kBAAA,CAAmB,GAAA,CAAI,QAAQ,OAAO,CAAA;AACtC,EAAA,OAAO,OAAA;AACT;AASO,SAAS,cAAA,CACd,OACA,MAAA,EACS;AACT,EAAA,IAAI,KAAA,CAAM,OAAA,IAAW,CAAC,MAAA,EAAQ;AAC5B,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,gBAAA,CAAiB,MAAM,CAAA,CAAE,GAAA,CAAI,MAAM,QAAQ,CAAA;AACpD;AAOO,SAAS,kBAAkB,OAAA,EAAgC;AAChE,EAAA,OAAO,IAAIC,mBAAA;AAAA,IACT,CAAA,4FAAA,EAA+F,OAAO,CAAA,0CAAA,EAA6C,OAAO,CAAA,GAAA;AAAA,GAC5J;AACF;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/core/index.ts"],"sourcesContent":["import { CodeInjection, containsOnlyImports, stripQueryAndHashFromPath } from './utils';\n\n/**\n * Checks if a file is a JavaScript file based on its extension.\n * Handles query strings and hashes in the filename.\n */\nexport function isJsFile(fileName: string): boolean {\n const cleanFileName = stripQueryAndHashFromPath(fileName);\n return ['.js', '.mjs', '.cjs'].some(ext => cleanFileName.endsWith(ext));\n}\n\n/**\n * Checks if a chunk should be skipped for code injection\n *\n * This is necessary to handle Vite's MPA (multi-page application) mode where\n * HTML entry points create \"facade\" chunks that should not contain injected code.\n * See: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/829\n *\n * However, in SPA mode, the main bundle also has an HTML facade but contains\n * substantial application code. We should NOT skip injection for these bundles.\n *\n * @param code - The chunk's code content\n * @param facadeModuleId - The facade module ID (if any) - HTML files create facade chunks\n * @returns true if the chunk should be skipped\n */\nexport function shouldSkipCodeInjection(code: string, facadeModuleId: string | null | undefined): boolean {\n // Skip empty chunks - these are placeholder chunks that should be optimized away\n if (code.trim().length === 0) {\n return true;\n }\n\n // For HTML facade chunks, only skip if they contain only import statements\n if (facadeModuleId && stripQueryAndHashFromPath(facadeModuleId).endsWith('.html')) {\n return containsOnlyImports(code);\n }\n\n return false;\n}\n\nexport interface ChunkGraphNode {\n fileName: string;\n isEntry?: boolean;\n imports?: string[];\n}\n\nconst initialChunksCache = new WeakMap<Record<string, ChunkGraphNode>, Set<string>>();\n\nfunction getInitialChunks(chunks: Record<string, ChunkGraphNode>): Set<string> {\n const cached = initialChunksCache.get(chunks);\n if (cached) {\n return cached;\n }\n\n const initial = new Set<string>();\n const queue = Object.values(chunks).filter(chunk => chunk.isEntry);\n\n for (let chunk = queue.shift(); chunk; chunk = queue.shift()) {\n if (initial.has(chunk.fileName)) {\n continue;\n }\n initial.add(chunk.fileName);\n for (const imported of chunk.imports ?? []) {\n const importedChunk = chunks[imported];\n if (importedChunk) {\n queue.push(importedChunk);\n }\n }\n }\n\n initialChunksCache.set(chunks, initial);\n return initial;\n}\n\n/**\n * Whether a chunk loads at startup: it is an entry chunk, or an entry chunk\n * reaches it through static imports. Chunks that only dynamic imports reach\n * load later, after startup code already ran.\n *\n * Without the chunk graph every chunk counts as initial.\n */\nexport function isInitialChunk(\n chunk: Pick<ChunkGraphNode, 'fileName' | 'isEntry'>,\n chunks: Record<string, ChunkGraphNode> | undefined,\n): boolean {\n if (chunk.isEntry || !chunks) {\n return true;\n }\n\n return getInitialChunks(chunks).has(chunk.fileName);\n}\n\nexport { globFiles } from './glob';\nexport { getCodeInjectionPosition } from './get-code-injection-position';\n\nexport { createComponentNameAnnotateHooks } from './component-annotate-hooks';\n\nexport function getDebugIdSnippet(debugId: string): CodeInjection {\n return new CodeInjection(\n `var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=\"${debugId}\",e._sentryDebugIdIdentifier=\"sentry-dbid-${debugId}\");`,\n );\n}\n\nexport type { Logger } from './logger';\nexport type { Options, SentrySDKBuildFlags } from './types';\nexport {\n CodeInjection,\n replaceBooleanFlagsInCode,\n stringToUUID,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n} from './utils';\nexport { createSentryBuildPluginManager } from './build-plugin-manager';\nexport type { SentryBuildPluginManager, UploadStaging } from './build-plugin-manager';\nexport { createDebugIdUploadFunction, addDebugIdToEmittedArtifacts, stampDebugId } from './debug-id-upload';\nexport { decideSourceMapHandling } from './sourcemap-settings';\nexport type { SourceMapDecision, SourceMapKind } from './sourcemap-settings';\nexport type { UploadFilter } from './upload-filter';\n"],"names":["stripQueryAndHashFromPath","containsOnlyImports","CodeInjection"],"mappings":";;;;;;;;;;AAMO,SAAS,SAAS,QAAA,EAA2B;AAClD,EAAA,MAAM,aAAA,GAAgBA,gCAA0B,QAAQ,CAAA;AACxD,EAAA,OAAO,CAAC,KAAA,EAAO,MAAA,EAAQ,MAAM,CAAA,CAAE,KAAK,CAAA,GAAA,KAAO,aAAA,CAAc,QAAA,CAAS,GAAG,CAAC,CAAA;AACxE;AAgBO,SAAS,uBAAA,CAAwB,MAAc,cAAA,EAAoD;AAExG,EAAA,IAAI,IAAA,CAAK,IAAA,EAAK,CAAE,MAAA,KAAW,CAAA,EAAG;AAC5B,IAAA,OAAO,IAAA;AAAA,EACT;AAGA,EAAA,IAAI,kBAAkBA,+BAAA,CAA0B,cAAc,CAAA,CAAE,QAAA,CAAS,OAAO,CAAA,EAAG;AACjF,IAAA,OAAOC,0BAAoB,IAAI,CAAA;AAAA,EACjC;AAEA,EAAA,OAAO,KAAA;AACT;AAQA,MAAM,kBAAA,uBAAyB,OAAA,EAAqD;AAEpF,SAAS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A6C,OAAO,CAAA,GAAA;AAAA,GAC5J;AACF;;;;;;;;;;;;;;;;;;;;"}
@@ -96,6 +96,12 @@ function validateOptions(options, logger) {
96
96
  );
97
97
  return false;
98
98
  }
99
+ if (options.sourcemaps?.deleteSourcemapsAfterUpload && options.sourcemaps.disable) {
100
+ logger.warn(
101
+ "The `sourcemaps.deleteSourcemapsAfterUpload` option is set but source map upload is disabled via `sourcemaps.disable`.",
102
+ "Source maps will not be deleted."
103
+ );
104
+ }
99
105
  if (options.project && Array.isArray(options.project)) {
100
106
  if (options.project.length === 0) {
101
107
  logger.error(
@@ -1 +1 @@
1
- {"version":3,"file":"options-mapping.js","sources":["../../../src/core/options-mapping.ts"],"sourcesContent":["import { getVercelEnv } from '@sentry/core';\nimport type { Logger } from './logger';\nimport type {\n Options as UserOptions,\n SetCommitsOptions,\n RewriteSourcesHook,\n ResolveSourceMapHook,\n IncludeEntry,\n ModuleMetadata,\n ModuleMetadataCallback,\n} from './types';\nimport { determineReleaseName, readCommitEnvVar } from './utils';\n\nexport type NormalizedOptions = {\n org: string | undefined;\n project: string | string[] | undefined;\n authToken: string | undefined;\n url: string;\n headers: Record<string, string> | undefined;\n debug: boolean;\n silent: boolean;\n errorHandler: ((err: Error) => void) | undefined;\n telemetry: boolean;\n disable: boolean;\n sourcemaps:\n | {\n disable?: boolean | 'disable-upload';\n assets?: string | string[];\n ignore?: string | string[];\n rewriteSources?: RewriteSourcesHook;\n resolveSourceMap?: ResolveSourceMapHook;\n filesToDeleteAfterUpload?: string | string[] | Promise<string | string[] | undefined>;\n }\n | undefined;\n release: {\n name: string | undefined;\n inject: boolean;\n create: boolean;\n finalize: boolean;\n vcsRemote: string;\n setCommits:\n | (SetCommitsOptions & {\n shouldNotThrowOnFailure?: boolean;\n })\n | false\n | undefined;\n dist?: string;\n deploy?:\n | {\n env: string;\n started?: number | string;\n finished?: number | string;\n time?: number;\n name?: string;\n url?: string;\n }\n | false;\n uploadLegacySourcemaps?: string | IncludeEntry | Array<string | IncludeEntry>;\n };\n bundleSizeOptimizations:\n | {\n excludeDebugStatements?: boolean;\n excludeTracing?: boolean;\n excludeChannelInjection?: boolean;\n excludeReplayCanvas?: boolean;\n excludeReplayShadowDom?: boolean;\n excludeReplayIframe?: boolean;\n excludeReplayWorker?: boolean;\n }\n | undefined;\n reactComponentAnnotation:\n | {\n enabled?: boolean;\n ignoredComponents?: string[];\n _experimentalInjectIntoHtml?: boolean;\n }\n | undefined;\n _metaOptions: {\n telemetry: {\n metaFramework: string | undefined;\n bundlerMajorVersion: string | undefined;\n };\n };\n applicationKey: string | undefined;\n moduleMetadata: ModuleMetadata | ModuleMetadataCallback | undefined;\n _experiments: {\n injectBuildInformation?: boolean;\n } & Record<string, unknown>;\n};\n\nexport const SENTRY_SAAS_URL = 'https://sentry.io';\n\n// oxlint-disable-next-line complexity\nexport function normalizeUserOptions(userOptions: UserOptions): NormalizedOptions {\n const options = {\n org: userOptions.org ?? process.env['SENTRY_ORG'],\n project:\n userOptions.project ??\n (process.env['SENTRY_PROJECT']?.includes(',')\n ? process.env['SENTRY_PROJECT'].split(',').map(p => p.trim())\n : process.env['SENTRY_PROJECT']),\n authToken: userOptions.authToken ?? process.env['SENTRY_AUTH_TOKEN'],\n url: userOptions.url ?? process.env['SENTRY_URL'] ?? SENTRY_SAAS_URL,\n headers: userOptions.headers,\n debug: userOptions.debug ?? false,\n silent: userOptions.silent ?? false,\n errorHandler: userOptions.errorHandler,\n telemetry: userOptions.telemetry ?? true,\n disable: userOptions.disable ?? false,\n sourcemaps: userOptions.sourcemaps,\n release: {\n ...userOptions.release,\n name: userOptions.release?.name ?? process.env['SENTRY_RELEASE'] ?? determineReleaseName(),\n inject: userOptions.release?.inject ?? true,\n create: userOptions.release?.create ?? true,\n finalize: userOptions.release?.finalize ?? true,\n vcsRemote: userOptions.release?.vcsRemote ?? process.env['SENTRY_VSC_REMOTE'] ?? 'origin',\n // oxlint-disable-next-line typescript/no-unnecessary-type-assertion -- rule false positive: the cast carries the internal `shouldNotThrowOnFailure` field; tsc errors without it\n setCommits: userOptions.release?.setCommits as\n | (SetCommitsOptions & { shouldNotThrowOnFailure?: boolean })\n | false\n | undefined,\n },\n bundleSizeOptimizations: userOptions.bundleSizeOptimizations,\n reactComponentAnnotation: userOptions.reactComponentAnnotation,\n _metaOptions: {\n telemetry: {\n metaFramework: userOptions._metaOptions?.telemetry?.metaFramework,\n bundlerMajorVersion: userOptions._metaOptions?.telemetry?.bundlerMajorVersion,\n },\n },\n applicationKey: userOptions.applicationKey,\n moduleMetadata: userOptions.moduleMetadata,\n _experiments: userOptions._experiments ?? {},\n };\n\n if (options.release.setCommits === undefined) {\n const vercelCommitSha = readCommitEnvVar('VERCEL_GIT_COMMIT_SHA');\n if (\n process.env['VERCEL'] &&\n vercelCommitSha &&\n process.env['VERCEL_GIT_REPO_SLUG'] &&\n process.env['VERCEL_GIT_REPO_OWNER'] &&\n // We only want to set commits for the production env because Sentry becomes extremely noisy (eg on slack) for\n // preview environments because the previous commit is always the \"stem\" commit of the preview/PR causing Sentry\n // to notify you for other people creating PRs.\n process.env['VERCEL_TARGET_ENV'] === 'production'\n ) {\n options.release.setCommits = {\n shouldNotThrowOnFailure: true,\n commit: vercelCommitSha,\n previousCommit: readCommitEnvVar('VERCEL_GIT_PREVIOUS_SHA'),\n repo: `${process.env['VERCEL_GIT_REPO_OWNER']}/${process.env['VERCEL_GIT_REPO_SLUG']}`,\n ignoreEmpty: true,\n ignoreMissing: true,\n };\n } else {\n options.release.setCommits = {\n shouldNotThrowOnFailure: true,\n auto: true,\n ignoreEmpty: true,\n ignoreMissing: true,\n };\n }\n }\n\n const vercelEnv = getVercelEnv();\n if (options.release.deploy === undefined && process.env['VERCEL'] && vercelEnv) {\n options.release.deploy = {\n env: vercelEnv,\n url: process.env['VERCEL_URL'] ? `https://${process.env['VERCEL_URL']}` : undefined,\n };\n }\n\n return options;\n}\n\n/**\n * Validates a few combinations of options that are not checked by Sentry CLI.\n *\n * For all other options, we can rely on Sentry CLI to validate them. In fact,\n * we can't validate them in the plugin because Sentry CLI might pick up options from\n * its config file.\n *\n * @param options the internal options\n * @param logger the logger\n *\n * @returns `true` if the options are valid, `false` otherwise\n */\nexport function validateOptions(options: NormalizedOptions, logger: Logger): boolean {\n const setCommits = options.release?.setCommits;\n if (setCommits) {\n if (!setCommits.auto && !(setCommits.repo && setCommits.commit)) {\n logger.error(\n 'The `setCommits` option was specified but is missing required properties.',\n 'Please set either `auto` or both, `repo` and `commit`.',\n );\n return false;\n }\n if (setCommits.auto && setCommits.repo && setCommits) {\n logger.warn(\n 'The `setCommits` options includes `auto` but also `repo` and `commit`.',\n 'Ignoring `repo` and `commit`.',\n 'Please only set either `auto` or both, `repo` and `commit`.',\n );\n }\n }\n\n if (options.release?.deploy && typeof options.release.deploy === 'object' && !options.release.deploy.env) {\n logger.error(\n 'The `deploy` option was specified but is missing the required `env` property.',\n 'Please set the `env` property.',\n );\n return false;\n }\n\n if (options.project && Array.isArray(options.project)) {\n if (options.project.length === 0) {\n logger.error(\n 'The `project` option was specified as an array but is empty.',\n 'Please provide at least one project slug.',\n );\n return false;\n }\n // Check each project is a non-empty string\n const invalidProjects = options.project.filter(p => typeof p !== 'string' || p.trim() === '');\n if (invalidProjects.length > 0) {\n logger.error('The `project` option contains invalid project slugs.', 'All projects must be non-empty strings.');\n return false;\n }\n }\n\n return true;\n}\n"],"names":["determineReleaseName","readCommitEnvVar","getVercelEnv"],"mappings":";;;;;AA0FO,MAAM,eAAA,GAAkB;AAGxB,SAAS,qBAAqB,WAAA,EAA6C;AAChF,EAAA,MAAM,OAAA,GAAU;AAAA,IACd,GAAA,EAAK,WAAA,CAAY,GAAA,IAAO,OAAA,CAAQ,IAAI,YAAY,CAAA;AAAA,IAChD,OAAA,EACE,WAAA,CAAY,OAAA,KACX,OAAA,CAAQ,GAAA,CAAI,gBAAgB,CAAA,EAAG,QAAA,CAAS,GAAG,CAAA,GACxC,OAAA,CAAQ,GAAA,CAAI,gBAAgB,CAA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,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,IAAI,QAAQ,OAAA,IAAW,KAAA,CAAM,OAAA,CAAQ,OAAA,CAAQ,OAAO,CAAA,EAAG;AACrD,IAAA,IAAI,OAAA,CAAQ,OAAA,CAAQ,MAAA,KAAW,CAAA,EAAG;AAChC,MAAA,MAAA,CAAO,KAAA;AAAA,QACL,8DAAA;AAAA,QACA;AAAA,OACF;AACA,MAAA,OAAO,KAAA;AAAA,IACT;AAEA,IAAA,MAAM,eAAA,GAAkB,OAAA,CAAQ,OAAA,CAAQ,MAAA,CAAO,CAAA,CAAA,KAAK,OAAO,CAAA,KAAM,QAAA,IAAY,CAAA,CAAE,IAAA,EAAK,KAAM,EAAE,CAAA;AAC5F,IAAA,IAAI,eAAA,CAAgB,SAAS,CAAA,EAAG;AAC9B,MAAA,MAAA,CAAO,KAAA,CAAM,wDAAwD,yCAAyC,CAAA;AAC9G,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,EACF;AAEA,EAAA,OAAO,IAAA;AACT;;;;;;"}
1
+ {"version":3,"file":"options-mapping.js","sources":["../../../src/core/options-mapping.ts"],"sourcesContent":["import { getVercelEnv } from '@sentry/core';\nimport type { Logger } from './logger';\nimport type {\n Options as UserOptions,\n SetCommitsOptions,\n RewriteSourcesHook,\n ResolveSourceMapHook,\n IncludeEntry,\n ModuleMetadata,\n ModuleMetadataCallback,\n} from './types';\nimport { determineReleaseName, readCommitEnvVar } from './utils';\n\nexport type NormalizedOptions = {\n org: string | undefined;\n project: string | string[] | undefined;\n authToken: string | undefined;\n url: string;\n headers: Record<string, string> | undefined;\n debug: boolean;\n silent: boolean;\n errorHandler: ((err: Error) => void) | undefined;\n telemetry: boolean;\n disable: boolean;\n sourcemaps:\n | {\n disable?: boolean | 'disable-upload';\n assets?: string | string[];\n ignore?: string | string[];\n rewriteSources?: RewriteSourcesHook;\n resolveSourceMap?: ResolveSourceMapHook;\n filesToDeleteAfterUpload?: string | string[] | Promise<string | string[] | undefined>;\n deleteSourcemapsAfterUpload?: boolean;\n }\n | undefined;\n release: {\n name: string | undefined;\n inject: boolean;\n create: boolean;\n finalize: boolean;\n vcsRemote: string;\n setCommits:\n | (SetCommitsOptions & {\n shouldNotThrowOnFailure?: boolean;\n })\n | false\n | undefined;\n dist?: string;\n deploy?:\n | {\n env: string;\n started?: number | string;\n finished?: number | string;\n time?: number;\n name?: string;\n url?: string;\n }\n | false;\n uploadLegacySourcemaps?: string | IncludeEntry | Array<string | IncludeEntry>;\n };\n bundleSizeOptimizations:\n | {\n excludeDebugStatements?: boolean;\n excludeTracing?: boolean;\n excludeChannelInjection?: boolean;\n excludeReplayCanvas?: boolean;\n excludeReplayShadowDom?: boolean;\n excludeReplayIframe?: boolean;\n excludeReplayWorker?: boolean;\n }\n | undefined;\n reactComponentAnnotation:\n | {\n enabled?: boolean;\n ignoredComponents?: string[];\n _experimentalInjectIntoHtml?: boolean;\n }\n | undefined;\n _metaOptions: {\n telemetry: {\n metaFramework: string | undefined;\n bundlerMajorVersion: string | undefined;\n };\n };\n applicationKey: string | undefined;\n moduleMetadata: ModuleMetadata | ModuleMetadataCallback | undefined;\n _experiments: {\n injectBuildInformation?: boolean;\n } & Record<string, unknown>;\n};\n\nexport const SENTRY_SAAS_URL = 'https://sentry.io';\n\n// oxlint-disable-next-line complexity\nexport function normalizeUserOptions(userOptions: UserOptions): NormalizedOptions {\n const options = {\n org: userOptions.org ?? process.env['SENTRY_ORG'],\n project:\n userOptions.project ??\n (process.env['SENTRY_PROJECT']?.includes(',')\n ? process.env['SENTRY_PROJECT'].split(',').map(p => p.trim())\n : process.env['SENTRY_PROJECT']),\n authToken: userOptions.authToken ?? process.env['SENTRY_AUTH_TOKEN'],\n url: userOptions.url ?? process.env['SENTRY_URL'] ?? SENTRY_SAAS_URL,\n headers: userOptions.headers,\n debug: userOptions.debug ?? false,\n silent: userOptions.silent ?? false,\n errorHandler: userOptions.errorHandler,\n telemetry: userOptions.telemetry ?? true,\n disable: userOptions.disable ?? false,\n sourcemaps: userOptions.sourcemaps,\n release: {\n ...userOptions.release,\n name: userOptions.release?.name ?? process.env['SENTRY_RELEASE'] ?? determineReleaseName(),\n inject: userOptions.release?.inject ?? true,\n create: userOptions.release?.create ?? true,\n finalize: userOptions.release?.finalize ?? true,\n vcsRemote: userOptions.release?.vcsRemote ?? process.env['SENTRY_VSC_REMOTE'] ?? 'origin',\n // oxlint-disable-next-line typescript/no-unnecessary-type-assertion -- rule false positive: the cast carries the internal `shouldNotThrowOnFailure` field; tsc errors without it\n setCommits: userOptions.release?.setCommits as\n | (SetCommitsOptions & { shouldNotThrowOnFailure?: boolean })\n | false\n | undefined,\n },\n bundleSizeOptimizations: userOptions.bundleSizeOptimizations,\n reactComponentAnnotation: userOptions.reactComponentAnnotation,\n _metaOptions: {\n telemetry: {\n metaFramework: userOptions._metaOptions?.telemetry?.metaFramework,\n bundlerMajorVersion: userOptions._metaOptions?.telemetry?.bundlerMajorVersion,\n },\n },\n applicationKey: userOptions.applicationKey,\n moduleMetadata: userOptions.moduleMetadata,\n _experiments: userOptions._experiments ?? {},\n };\n\n if (options.release.setCommits === undefined) {\n const vercelCommitSha = readCommitEnvVar('VERCEL_GIT_COMMIT_SHA');\n if (\n process.env['VERCEL'] &&\n vercelCommitSha &&\n process.env['VERCEL_GIT_REPO_SLUG'] &&\n process.env['VERCEL_GIT_REPO_OWNER'] &&\n // We only want to set commits for the production env because Sentry becomes extremely noisy (eg on slack) for\n // preview environments because the previous commit is always the \"stem\" commit of the preview/PR causing Sentry\n // to notify you for other people creating PRs.\n process.env['VERCEL_TARGET_ENV'] === 'production'\n ) {\n options.release.setCommits = {\n shouldNotThrowOnFailure: true,\n commit: vercelCommitSha,\n previousCommit: readCommitEnvVar('VERCEL_GIT_PREVIOUS_SHA'),\n repo: `${process.env['VERCEL_GIT_REPO_OWNER']}/${process.env['VERCEL_GIT_REPO_SLUG']}`,\n ignoreEmpty: true,\n ignoreMissing: true,\n };\n } else {\n options.release.setCommits = {\n shouldNotThrowOnFailure: true,\n auto: true,\n ignoreEmpty: true,\n ignoreMissing: true,\n };\n }\n }\n\n const vercelEnv = getVercelEnv();\n if (options.release.deploy === undefined && process.env['VERCEL'] && vercelEnv) {\n options.release.deploy = {\n env: vercelEnv,\n url: process.env['VERCEL_URL'] ? `https://${process.env['VERCEL_URL']}` : undefined,\n };\n }\n\n return options;\n}\n\n/**\n * Validates a few combinations of options that are not checked by Sentry CLI.\n *\n * For all other options, we can rely on Sentry CLI to validate them. In fact,\n * we can't validate them in the plugin because Sentry CLI might pick up options from\n * its config file.\n *\n * @param options the internal options\n * @param logger the logger\n *\n * @returns `true` if the options are valid, `false` otherwise\n */\nexport function validateOptions(options: NormalizedOptions, logger: Logger): boolean {\n const setCommits = options.release?.setCommits;\n if (setCommits) {\n if (!setCommits.auto && !(setCommits.repo && setCommits.commit)) {\n logger.error(\n 'The `setCommits` option was specified but is missing required properties.',\n 'Please set either `auto` or both, `repo` and `commit`.',\n );\n return false;\n }\n if (setCommits.auto && setCommits.repo && setCommits) {\n logger.warn(\n 'The `setCommits` options includes `auto` but also `repo` and `commit`.',\n 'Ignoring `repo` and `commit`.',\n 'Please only set either `auto` or both, `repo` and `commit`.',\n );\n }\n }\n\n if (options.release?.deploy && typeof options.release.deploy === 'object' && !options.release.deploy.env) {\n logger.error(\n 'The `deploy` option was specified but is missing the required `env` property.',\n 'Please set the `env` property.',\n );\n return false;\n }\n\n if (options.sourcemaps?.deleteSourcemapsAfterUpload && options.sourcemaps.disable) {\n logger.warn(\n 'The `sourcemaps.deleteSourcemapsAfterUpload` option is set but source map upload is disabled via `sourcemaps.disable`.',\n 'Source maps will not be deleted.',\n );\n }\n\n if (options.project && Array.isArray(options.project)) {\n if (options.project.length === 0) {\n logger.error(\n 'The `project` option was specified as an array but is empty.',\n 'Please provide at least one project slug.',\n );\n return false;\n }\n // Check each project is a non-empty string\n const invalidProjects = options.project.filter(p => typeof p !== 'string' || p.trim() === '');\n if (invalidProjects.length > 0) {\n logger.error('The `project` option contains invalid project slugs.', 'All projects must be non-empty strings.');\n return false;\n }\n }\n\n return true;\n}\n"],"names":["determineReleaseName","readCommitEnvVar","getVercelEnv"],"mappings":";;;;;AA2FO,MAAM,eAAA,GAAkB;AAGxB,SAAS,qBAAqB,WAAA,EAA6C;AAChF,EAAA,MAAM,OAAA,GAAU;AAAA,IACd,GAAA,EAAK,WAAA,CAAY,GAAA,IAAO,OAAA,CAAQ,IAAI,YAAY,CAAA;AAAA,IAChD,OAAA,EACE,WAAA,CAAY,OAAA,KACX,OAAA,CAAQ,GAAA,CAAI,gBAAgB,CAAA,EAAG,QAAA,CAAS,GAAG,CAAA,GACxC,OAAA,CAAQ,GAAA,CAAI,gBAAgB,CAAA,CAAE,KAAA,CAAM,GAAG,CAAA,CAAE,GAAA,CAAI,CAAA,CAAA,KAAK,CAAA,CAAE,IAAA,EAAM,CAAA,GAC1D,OAAA,CAAQ,GAAA,CAAI,gBAAgB,CAAA,CAAA;AAAA,IAClC,SAAA,EAAW,WAAA,CAAY,SAAA,IAAa,OAAA,CAAQ,IAAI,mBAAmB,CAAA;AAAA,IACnE,KAAK,WAAA,CAAY,GAAA,IAAO,OAAA,CAAQ,GAAA,CAAI,YAAY,CAAA,IAAK,eAAA;AAAA,IACrD,SAAS,WAAA,CAAY,OAAA;AAAA,IACrB,KAAA,EAAO,YAAY,KAAA,IAAS,KAAA;AAAA,IAC5B,MAAA,EAAQ,YAAY,MAAA,IAAU,KAAA;AAAA,IAC9B,cAAc,WAAA,CAAY,YAAA;AAAA,IAC1B,SAAA,EAAW,YAAY,SAAA,IAAa,IAAA;AAAA,IACpC,OAAA,EAAS,YAAY,OAAA,IAAW,KAAA;AAAA,IAChC,YAAY,WAAA,CAAY,UAAA;AAAA,IACxB,OAAA,EAAS;AAAA,MACP,GAAG,WAAA,CAAY,OAAA;AAAA,MACf,IAAA,EAAM,YAAY,OAAA,EAAS,IAAA,IAAQ,QAAQ,GAAA,CAAI,gBAAgB,KAAKA,0BAA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EAAA,OAAO,IAAA;AACT;;;;;;"}
@@ -69,6 +69,10 @@ function setTelemetryDataOnScope(options, scope, buildTool, buildToolMajorVersio
69
69
  scope.setTag("custom-error-handler", !!errorHandler);
70
70
  scope.setTag("sourcemaps-assets", !!sourcemaps?.assets);
71
71
  scope.setTag("delete-after-upload", !!sourcemaps?.filesToDeleteAfterUpload);
72
+ scope.setTag(
73
+ "delete-sourcemaps-after-upload",
74
+ sourcemaps?.deleteSourcemapsAfterUpload === void 0 ? "auto" : String(sourcemaps.deleteSourcemapsAfterUpload)
75
+ );
72
76
  scope.setTag("sourcemaps-disabled", !!sourcemaps?.disable);
73
77
  scope.setTag("react-annotate", !!reactComponentAnnotation?.enabled);
74
78
  scope.setTag("node", process.version);
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.js","sources":["../../../../src/core/sentry/telemetry.ts"],"sourcesContent":["import type { Client } from '@sentry/core';\nimport type { ServerRuntimeClientOptions } from '@sentry/core/server';\nimport { applySdkMetadata } from '@sentry/core';\nimport { ServerRuntimeClient } from '@sentry/core/server';\nimport type { NormalizedOptions } from '../options-mapping';\nimport { SENTRY_SAAS_URL } from '../options-mapping';\nimport { Scope } from '@sentry/core';\nimport { createStackParser } from '@sentry/core';\nimport { nodeStackLineParser } from '@sentry/core/server';\nimport { makeOptionallyEnabledNodeTransport } from './transports';\nimport { SentryCliAdapter } from '../cli';\nimport { LIB_VERSION } from '../version';\n\nconst SENTRY_SAAS_HOSTNAME = 'sentry.io';\n\nconst stackParser = createStackParser(nodeStackLineParser());\n\nexport function createSentryInstance(\n options: NormalizedOptions,\n shouldSendTelemetry: Promise<boolean>,\n buildTool: string,\n buildToolMajorVersion: string | undefined,\n): { sentryScope: Scope; sentryClient: Client } {\n const clientOptions: ServerRuntimeClientOptions = {\n platform: 'node',\n runtime: { name: 'node', version: global.process.version },\n\n dsn: 'https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737',\n\n tracesSampleRate: 0.3,\n traceLifecycle: 'static',\n sampleRate: 1,\n\n release: LIB_VERSION,\n integrations: [],\n tracePropagationTargets: ['sentry.io/api'],\n\n stackParser,\n\n beforeSend: event => {\n event.exception?.values?.forEach(exception => {\n delete exception.stacktrace;\n });\n\n delete event.server_name; // Server name might contain PII\n return event;\n },\n\n // Deprecated, but still applied because this client runs on the static trace lifecycle.\n // oxlint-disable-next-line typescript/no-deprecated\n beforeSendTransaction: event => {\n delete event.server_name; // Server name might contain PII\n return event;\n },\n\n // We create a transport that stalls sending events until we know that we're allowed to (i.e. when Sentry CLI told\n // us that the upload URL is the Sentry SaaS URL)\n transport: makeOptionallyEnabledNodeTransport(shouldSendTelemetry),\n };\n\n applySdkMetadata(clientOptions, 'node');\n\n const client = new ServerRuntimeClient(clientOptions);\n const scope = new Scope();\n scope.setClient(client);\n\n // Integration tests snapshot the emitted transaction, so the sampling decision must not depend on chance.\n if (process.env['SENTRY_TEST_OUT_DIR']) {\n scope.setPropagationContext({ ...scope.getPropagationContext(), sampleRand: 0 });\n }\n\n setTelemetryDataOnScope(options, scope, buildTool, buildToolMajorVersion);\n\n return { sentryScope: scope, sentryClient: client };\n}\n\nexport function setTelemetryDataOnScope(\n options: NormalizedOptions,\n scope: Scope,\n buildTool: string,\n buildToolMajorVersion?: string,\n): void {\n const { org, project, release, errorHandler, sourcemaps, reactComponentAnnotation } = options;\n\n scope.setTag('upload-legacy-sourcemaps', !!release.uploadLegacySourcemaps);\n if (release.uploadLegacySourcemaps) {\n scope.setTag(\n 'uploadLegacySourcemapsEntries',\n Array.isArray(release.uploadLegacySourcemaps) ? release.uploadLegacySourcemaps.length : 1,\n );\n }\n\n scope.setTag('module-metadata', !!options.moduleMetadata);\n scope.setTag('inject-build-information', !!options._experiments.injectBuildInformation);\n\n // Optional release pipeline steps\n if (release.setCommits) {\n scope.setTag('set-commits', release.setCommits.auto === true ? 'auto' : 'manual');\n } else {\n scope.setTag('set-commits', 'undefined');\n }\n scope.setTag('finalize-release', release.finalize);\n scope.setTag('deploy-options', !!release.deploy);\n\n // Miscellaneous options\n scope.setTag('custom-error-handler', !!errorHandler);\n scope.setTag('sourcemaps-assets', !!sourcemaps?.assets);\n scope.setTag('delete-after-upload', !!sourcemaps?.filesToDeleteAfterUpload);\n scope.setTag('sourcemaps-disabled', !!sourcemaps?.disable);\n\n scope.setTag('react-annotate', !!reactComponentAnnotation?.enabled);\n\n scope.setTag('node', process.version);\n scope.setTag('platform', process.platform);\n\n scope.setTag('meta-framework', options._metaOptions.telemetry.metaFramework ?? 'none');\n\n scope.setTag('application-key-set', options.applicationKey !== undefined);\n\n scope.setTag('ci', !!process.env['CI']);\n\n scope.setTags({\n organization: org,\n project: Array.isArray(project) ? project.join(', ') : (project ?? 'undefined'),\n bundler: buildTool,\n });\n\n if (buildToolMajorVersion) {\n scope.setTag('bundler-major-version', buildToolMajorVersion);\n }\n\n scope.setUser({ id: org });\n}\n\nexport async function allowedToSendTelemetry(options: NormalizedOptions): Promise<boolean> {\n const { telemetry, url } = options;\n\n // `options.telemetry` defaults to true\n if (telemetry === false) {\n return false;\n }\n\n if (url === SENTRY_SAAS_URL) {\n return true;\n }\n\n // Ask the CLI which Sentry server URL it resolves to. This can differ from the default (or the\n // configured `url`) because the CLI also honors a possibly existing `.sentryclirc` file.\n const cliInfoUrl = await new SentryCliAdapter(options).getServerUrl();\n\n if (cliInfoUrl === undefined) {\n return false;\n }\n\n return new URL(cliInfoUrl).hostname === SENTRY_SAAS_HOSTNAME;\n}\n\n/**\n * Flushing the SDK client can fail. We never want to crash the plugin because of telemetry.\n */\nexport async function safeFlushTelemetry(sentryClient: Client): Promise<void> {\n try {\n await sentryClient.flush(2000);\n } catch {\n // Noop when flushing fails.\n // We don't even need to log anything because there's likely nothing the user can do and they likely will not care.\n }\n}\n"],"names":["createStackParser","nodeStackLineParser","LIB_VERSION","makeOptionallyEnabledNodeTransport","applySdkMetadata","ServerRuntimeClient","Scope","SENTRY_SAAS_URL","SentryCliAdapter"],"mappings":";;;;;;;;;A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A,CAAO,yBAAyB,qBAAqB,CAAA;AAAA,EAC7D;AAEA,EAAA,KAAA,CAAM,OAAA,CAAQ,EAAE,EAAA,EAAI,GAAA,EAAK,CAAA;AAC3B;AAEA,eAAsB,uBAAuB,OAAA,EAA8C;AACzF,EAAA,MAAM,EAAE,SAAA,EAAW,GAAA,EAAI,GAAI,OAAA;AAG3B,EAAA,IAAI,cAAc,KAAA,EAAO;AACvB,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,IAAI,QAAQC,8BAAA,EAAiB;AAC3B,IAAA,OAAO,IAAA;AAAA,EACT;AAIA,EAAA,MAAM,aAAa,MAAM,IAAIC,oBAAA,CAAiB,OAAO,EAAE,YAAA,EAAa;AAEpE,EAAA,IAAI,eAAe,MAAA,EAAW;AAC5B,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,OAAO,IAAI,GAAA,CAAI,UAAU,CAAA,CAAE,QAAA,KAAa,oBAAA;AAC1C;AAKA,eAAsB,mBAAmB,YAAA,EAAqC;AAC5E,EAAA,IAAI;AACF,IAAA,MAAM,YAAA,CAAa,MAAM,GAAI,CAAA;AAAA,EAC/B,CAAA,CAAA,MAAQ;AAAA,EAGR;AACF;;;;;;;"}
1
+ {"version":3,"file":"telemetry.js","sources":["../../../../src/core/sentry/telemetry.ts"],"sourcesContent":["import type { Client } from '@sentry/core';\nimport type { ServerRuntimeClientOptions } from '@sentry/core/server';\nimport { applySdkMetadata } from '@sentry/core';\nimport { ServerRuntimeClient } from '@sentry/core/server';\nimport type { NormalizedOptions } from '../options-mapping';\nimport { SENTRY_SAAS_URL } from '../options-mapping';\nimport { Scope } from '@sentry/core';\nimport { createStackParser } from '@sentry/core';\nimport { nodeStackLineParser } from '@sentry/core/server';\nimport { makeOptionallyEnabledNodeTransport } from './transports';\nimport { SentryCliAdapter } from '../cli';\nimport { LIB_VERSION } from '../version';\n\nconst SENTRY_SAAS_HOSTNAME = 'sentry.io';\n\nconst stackParser = createStackParser(nodeStackLineParser());\n\nexport function createSentryInstance(\n options: NormalizedOptions,\n shouldSendTelemetry: Promise<boolean>,\n buildTool: string,\n buildToolMajorVersion: string | undefined,\n): { sentryScope: Scope; sentryClient: Client } {\n const clientOptions: ServerRuntimeClientOptions = {\n platform: 'node',\n runtime: { name: 'node', version: global.process.version },\n\n dsn: 'https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737',\n\n tracesSampleRate: 0.3,\n traceLifecycle: 'static',\n sampleRate: 1,\n\n release: LIB_VERSION,\n integrations: [],\n tracePropagationTargets: ['sentry.io/api'],\n\n stackParser,\n\n beforeSend: event => {\n event.exception?.values?.forEach(exception => {\n delete exception.stacktrace;\n });\n\n delete event.server_name; // Server name might contain PII\n return event;\n },\n\n // Deprecated, but still applied because this client runs on the static trace lifecycle.\n // oxlint-disable-next-line typescript/no-deprecated\n beforeSendTransaction: event => {\n delete event.server_name; // Server name might contain PII\n return event;\n },\n\n // We create a transport that stalls sending events until we know that we're allowed to (i.e. when Sentry CLI told\n // us that the upload URL is the Sentry SaaS URL)\n transport: makeOptionallyEnabledNodeTransport(shouldSendTelemetry),\n };\n\n applySdkMetadata(clientOptions, 'node');\n\n const client = new ServerRuntimeClient(clientOptions);\n const scope = new Scope();\n scope.setClient(client);\n\n // Integration tests snapshot the emitted transaction, so the sampling decision must not depend on chance.\n if (process.env['SENTRY_TEST_OUT_DIR']) {\n scope.setPropagationContext({ ...scope.getPropagationContext(), sampleRand: 0 });\n }\n\n setTelemetryDataOnScope(options, scope, buildTool, buildToolMajorVersion);\n\n return { sentryScope: scope, sentryClient: client };\n}\n\nexport function setTelemetryDataOnScope(\n options: NormalizedOptions,\n scope: Scope,\n buildTool: string,\n buildToolMajorVersion?: string,\n): void {\n const { org, project, release, errorHandler, sourcemaps, reactComponentAnnotation } = options;\n\n scope.setTag('upload-legacy-sourcemaps', !!release.uploadLegacySourcemaps);\n if (release.uploadLegacySourcemaps) {\n scope.setTag(\n 'uploadLegacySourcemapsEntries',\n Array.isArray(release.uploadLegacySourcemaps) ? release.uploadLegacySourcemaps.length : 1,\n );\n }\n\n scope.setTag('module-metadata', !!options.moduleMetadata);\n scope.setTag('inject-build-information', !!options._experiments.injectBuildInformation);\n\n // Optional release pipeline steps\n if (release.setCommits) {\n scope.setTag('set-commits', release.setCommits.auto === true ? 'auto' : 'manual');\n } else {\n scope.setTag('set-commits', 'undefined');\n }\n scope.setTag('finalize-release', release.finalize);\n scope.setTag('deploy-options', !!release.deploy);\n\n // Miscellaneous options\n scope.setTag('custom-error-handler', !!errorHandler);\n scope.setTag('sourcemaps-assets', !!sourcemaps?.assets);\n scope.setTag('delete-after-upload', !!sourcemaps?.filesToDeleteAfterUpload);\n scope.setTag(\n 'delete-sourcemaps-after-upload',\n sourcemaps?.deleteSourcemapsAfterUpload === undefined ? 'auto' : String(sourcemaps.deleteSourcemapsAfterUpload),\n );\n scope.setTag('sourcemaps-disabled', !!sourcemaps?.disable);\n\n scope.setTag('react-annotate', !!reactComponentAnnotation?.enabled);\n\n scope.setTag('node', process.version);\n scope.setTag('platform', process.platform);\n\n scope.setTag('meta-framework', options._metaOptions.telemetry.metaFramework ?? 'none');\n\n scope.setTag('application-key-set', options.applicationKey !== undefined);\n\n scope.setTag('ci', !!process.env['CI']);\n\n scope.setTags({\n organization: org,\n project: Array.isArray(project) ? project.join(', ') : (project ?? 'undefined'),\n bundler: buildTool,\n });\n\n if (buildToolMajorVersion) {\n scope.setTag('bundler-major-version', buildToolMajorVersion);\n }\n\n scope.setUser({ id: org });\n}\n\nexport async function allowedToSendTelemetry(options: NormalizedOptions): Promise<boolean> {\n const { telemetry, url } = options;\n\n // `options.telemetry` defaults to true\n if (telemetry === false) {\n return false;\n }\n\n if (url === SENTRY_SAAS_URL) {\n return true;\n }\n\n // Ask the CLI which Sentry server URL it resolves to. This can differ from the default (or the\n // configured `url`) because the CLI also honors a possibly existing `.sentryclirc` file.\n const cliInfoUrl = await new SentryCliAdapter(options).getServerUrl();\n\n if (cliInfoUrl === undefined) {\n return false;\n }\n\n return new URL(cliInfoUrl).hostname === SENTRY_SAAS_HOSTNAME;\n}\n\n/**\n * Flushing the SDK client can fail. We never want to crash the plugin because of telemetry.\n */\nexport async function safeFlushTelemetry(sentryClient: Client): Promise<void> {\n try {\n await sentryClient.flush(2000);\n } catch {\n // Noop when flushing fails.\n // We don't even need to log anything because there's likely nothing the user can do and they likely will not care.\n }\n}\n"],"names":["createStackParser","nodeStackLineParser","LIB_VERSION","makeOptionallyEnabledNodeTransport","applySdkMetadata","ServerRuntimeClient","Scope","SENTRY_SAAS_URL","SentryCliAdapter"],"mappings":";;;;;;;;;AAaA,MAAM,oBAAA,GAAuB,WAAA;AAE7B,MAAM,WAAA,GAAcA,sBAAA,CAAkBC,0BAAA,EAAqB,CAAA;AAEpD,SAAS,oBAAA,CACd,OAAA,EACA,mBAAA,EACA,SAAA,EACA,qBAAA,EAC8C;AAC9C,EAAA,MAAM,aAAA,GAA4C;AAAA,IAChD,QAAA,EAAU,MAAA;AAAA,IACV,SAAS,EAAE,IAAA,EAAM,QAAQ,OAAA,EAAS,MAAA,CAAO,QAAQ,OAAA,EAAQ;AAAA,IAEzD,GAAA,EAAK,sEAAA;AAAA,IAEL,gBAAA,EAAkB,GAAA;AAAA,IAClB,cAAA,EAAgB,QAAA;AAAA,IAChB,UAAA,EAAY,CAAA;AAAA,IAEZ,OAAA,EAASC,mBAAA;AAAA,IACT,cAAc,EAAC;AAAA,IACf,uBAAA,EAAyB,CAAC,eAAe,CAAA;AAAA,IAEzC,WAAA;AAAA,IAEA,YAAY,CAAA,KAAA,KAAS;AACnB,MAAA,KAAA,CAAM,SAAA,EAAW,MAAA,EAAQ,OAAA,CAAQ,CAAA,SAAA,KAAa;AAC5C,QAAA,OAAO,SAAA,CAAU,UAAA;AAAA,MACnB,CAAC,CAAA;AAED,MAAA,OAAO,KAAA,CAAM,WAAA;AACb,MAAA,OAAO,KAAA;AAAA,IACT,CAAA;AAAA;AAAA;AAAA,IAIA,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AA;AAAA,EAC/B,CAAA,CAAA,MAAQ;AAAA,EAGR;AACF;;;;;;;"}
@@ -0,0 +1,63 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const NO_CHANGE = { enableHidden: false, deleteAfterUpload: false };
4
+ function decideSourceMapHandling(kind, options, uploadPossible) {
5
+ const deleteOption = options.sourcemaps?.deleteSourcemapsAfterUpload;
6
+ if (!uploadPossible || options.sourcemaps?.disable) {
7
+ return NO_CHANGE;
8
+ }
9
+ switch (kind) {
10
+ case "off":
11
+ return {
12
+ ...NO_CHANGE,
13
+ log: {
14
+ level: "warn",
15
+ message: "Source map generation is turned off in your bundler, so Sentry cannot un-minify your stack traces. Remove the setting to let the plugin generate hidden source maps, upload them to Sentry and remove them from the build output."
16
+ }
17
+ };
18
+ case "inline":
19
+ return {
20
+ ...NO_CHANGE,
21
+ log: {
22
+ level: "warn",
23
+ message: "Source maps are inlined into your bundles. They are uploaded to Sentry, but inline source maps ship your source code to users and cannot be removed after the upload. Remove the setting to let the plugin generate hidden source maps instead."
24
+ }
25
+ };
26
+ case "unset":
27
+ if (deleteOption === false) {
28
+ return {
29
+ enableHidden: true,
30
+ deleteAfterUpload: false,
31
+ log: {
32
+ level: "info",
33
+ message: "Enabling hidden source maps. They are uploaded to Sentry and kept in the build output."
34
+ }
35
+ };
36
+ }
37
+ return {
38
+ enableHidden: true,
39
+ deleteAfterUpload: true,
40
+ log: {
41
+ level: "info",
42
+ message: "Enabling hidden source maps. They are uploaded to Sentry and removed from the build output. Set `sourcemaps.deleteSourcemapsAfterUpload: false` to keep them."
43
+ }
44
+ };
45
+ case "hidden":
46
+ return { enableHidden: false, deleteAfterUpload: deleteOption === true };
47
+ case "visible":
48
+ if (deleteOption !== true) {
49
+ return NO_CHANGE;
50
+ }
51
+ return {
52
+ enableHidden: true,
53
+ deleteAfterUpload: true,
54
+ log: {
55
+ level: "info",
56
+ message: "Switching to hidden source maps because `sourcemaps.deleteSourcemapsAfterUpload` is set. Without the `sourceMappingURL` comment browsers do not request the removed map files."
57
+ }
58
+ };
59
+ }
60
+ }
61
+
62
+ exports.decideSourceMapHandling = decideSourceMapHandling;
63
+ //# sourceMappingURL=sourcemap-settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourcemap-settings.js","sources":["../../../src/core/sourcemap-settings.ts"],"sourcesContent":["import type { NormalizedOptions } from './options-mapping';\n\n/**\n * The user's source map setting in the bundler, reduced to what matters for upload and deletion.\n *\n * - `unset`: the user did not configure source maps\n * - `off`: source map generation is turned off\n * - `visible`: separate map files with a `sourceMappingURL` comment\n * - `hidden`: separate map files without the comment\n * - `inline`: the map is embedded into the bundle\n */\nexport type SourceMapKind = 'unset' | 'off' | 'visible' | 'hidden' | 'inline';\n\nexport type SourceMapDecision = {\n /** Switch the bundler to hidden source maps. */\n enableHidden: boolean;\n /** Remove the source maps from the build output once they are uploaded. */\n deleteAfterUpload: boolean;\n log?: { level: 'info' | 'warn'; message: string };\n};\n\nconst NO_CHANGE: SourceMapDecision = { enableHidden: false, deleteAfterUpload: false };\n\n/**\n * Decides whether the plugin turns hidden source maps on and whether it removes the maps from the\n * build output after the upload. The plugin only turns maps on when an upload can run, and only\n * removes maps it turned on itself unless `deleteSourcemapsAfterUpload` says otherwise.\n */\nexport function decideSourceMapHandling(\n kind: SourceMapKind,\n options: NormalizedOptions,\n uploadPossible: boolean,\n): SourceMapDecision {\n const deleteOption = options.sourcemaps?.deleteSourcemapsAfterUpload;\n\n if (!uploadPossible || options.sourcemaps?.disable) {\n return NO_CHANGE;\n }\n\n switch (kind) {\n case 'off':\n return {\n ...NO_CHANGE,\n log: {\n level: 'warn',\n message:\n 'Source map generation is turned off in your bundler, so Sentry cannot un-minify your stack traces. ' +\n 'Remove the setting to let the plugin generate hidden source maps, upload them to Sentry and remove them from the build output.',\n },\n };\n\n case 'inline':\n return {\n ...NO_CHANGE,\n log: {\n level: 'warn',\n message:\n 'Source maps are inlined into your bundles. They are uploaded to Sentry, but inline source maps ship your source code to users and cannot be removed after the upload. ' +\n 'Remove the setting to let the plugin generate hidden source maps instead.',\n },\n };\n\n case 'unset':\n if (deleteOption === false) {\n return {\n enableHidden: true,\n deleteAfterUpload: false,\n log: {\n level: 'info',\n message: 'Enabling hidden source maps. They are uploaded to Sentry and kept in the build output.',\n },\n };\n }\n return {\n enableHidden: true,\n deleteAfterUpload: true,\n log: {\n level: 'info',\n message:\n 'Enabling hidden source maps. They are uploaded to Sentry and removed from the build output. ' +\n 'Set `sourcemaps.deleteSourcemapsAfterUpload: false` to keep them.',\n },\n };\n\n case 'hidden':\n return { enableHidden: false, deleteAfterUpload: deleteOption === true };\n\n case 'visible':\n if (deleteOption !== true) {\n return NO_CHANGE;\n }\n return {\n enableHidden: true,\n deleteAfterUpload: true,\n log: {\n level: 'info',\n message:\n 'Switching to hidden source maps because `sourcemaps.deleteSourcemapsAfterUpload` is set. ' +\n 'Without the `sourceMappingURL` comment browsers do not request the removed map files.',\n },\n };\n }\n}\n"],"names":[],"mappings":";;AAqBA,MAAM,SAAA,GAA+B,EAAE,YAAA,EAAc,KAAA,EAAO,mBAAmB,KAAA,EAAM;AAO9E,SAAS,uBAAA,CACd,IAAA,EACA,OAAA,EACA,cAAA,EACmB;AACnB,EAAA,MAAM,YAAA,GAAe,QAAQ,UAAA,EAAY,2BAAA;AAEzC,EAAA,IAAI,CAAC,cAAA,IAAkB,OAAA,CAAQ,UAAA,EAAY,OAAA,EAAS;AAClD,IAAA,OAAO,SAAA;AAAA,EACT;AAEA,EAAA,QAAQ,IAAA;AAAM,IACZ,KAAK,KAAA;AACH,MAAA,OAAO;AAAA,QACL,GAAG,SAAA;AAAA,QACH,GAAA,EAAK;AAAA,UACH,KAAA,EAAO,MAAA;AAAA,UACP,OAAA,EACE;AAAA;AAEJ,OACF;AAAA,IAEF,KAAK,QAAA;AACH,MAAA,OAAO;AAAA,QACL,GAAG,SAAA;AAAA,QACH,GAAA,EAAK;AAAA,UACH,KAAA,EAAO,MAAA;AAAA,UACP,OAAA,EACE;AAAA;AAEJ,OACF;AAAA,IAEF,KAAK,OAAA;AACH,MAAA,IAAI,iBAAiB,KAAA,EAAO;AAC1B,QAAA,OAAO;AAAA,UACL,YAAA,EAAc,IAAA;AAAA,UACd,iBAAA,EAAmB,KAAA;AAAA,UACnB,GAAA,EAAK;AAAA,YACH,KAAA,EAAO,MAAA;AAAA,YACP,OAAA,EAAS;AAAA;AACX,SACF;AAAA,MACF;AACA,MAAA,OAAO;AAAA,QACL,YAAA,EAAc,IAAA;AAAA,QACd,iBAAA,EAAmB,IAAA;AAAA,QACnB,GAAA,EAAK;AAAA,UACH,KAAA,EAAO,MAAA;AAAA,UACP,OAAA,EACE;AAAA;AAEJ,OACF;AAAA,IAEF,KAAK,QAAA;AACH,MAAA,OAAO,EAAE,YAAA,EAAc,KAAA,EAAO,iBAAA,EAAmB,iBAAiB,IAAA,EAAK;AAAA,IAEzE,KAAK,SAAA;AACH,MAAA,IAAI,iBAAiB,IAAA,EAAM;AACzB,QAAA,OAAO,SAAA;AAAA,MACT;AACA,MAAA,OAAO;AAAA,QACL,YAAA,EAAc,IAAA;AAAA,QACd,iBAAA,EAAmB,IAAA;AAAA,QACnB,GAAA,EAAK;AAAA,UACH,KAAA,EAAO,MAAA;AAAA,UACP,OAAA,EACE;AAAA;AAEJ,OACF;AAAA;AAEN;;;;"}
@@ -0,0 +1,57 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const path = require('path');
4
+ const glob = require('glob');
5
+
6
+ function _interopNamespace(e) {
7
+ if (e && e.__esModule) return e;
8
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
9
+ if (e) {
10
+ for (const k in e) {
11
+ n[k] = e[k];
12
+ }
13
+ }
14
+ n.default = e;
15
+ return n;
16
+ }
17
+
18
+ const path__namespace = /*#__PURE__*/_interopNamespace(path);
19
+
20
+ function createUploadFilter(options) {
21
+ const cwd = process.cwd();
22
+ const assets = options.sourcemaps?.assets;
23
+ const matchesAssets = assets === void 0 ? () => true : createMatcher(
24
+ toArray(assets).map((pattern) => toAbsolutePattern(cwd, pattern)),
25
+ { cwd, dot: false }
26
+ );
27
+ const ignore = toArray(options.sourcemaps?.ignore ?? []);
28
+ const matchesIgnore = ignore.length === 0 ? () => false : createMatcher(ignore, { cwd, dot: true });
29
+ return (filePath) => matchesAssets(filePath) && !matchesIgnore(filePath);
30
+ }
31
+ function createMatcher(patterns, { cwd, dot }) {
32
+ const matcher = new glob.Ignore([], { nocase: process.platform === "darwin" || process.platform === "win32" });
33
+ matcher.mmopts.dot = dot;
34
+ for (const pattern of patterns) {
35
+ matcher.add(pattern);
36
+ }
37
+ return (filePath) => {
38
+ const fullpath = path__namespace.resolve(cwd, filePath);
39
+ const relative = toGlobRelativePath(cwd, fullpath);
40
+ return matcher.ignored({ fullpath: () => fullpath, relative: () => relative });
41
+ };
42
+ }
43
+ function toAbsolutePattern(cwd, pattern) {
44
+ return path__namespace.isAbsolute(pattern) ? pattern : `${glob.escape(cwd.split(path__namespace.sep).join("/"))}/${pattern}`;
45
+ }
46
+ function toGlobRelativePath(cwd, fullpath) {
47
+ const relative = path__namespace.relative(cwd, fullpath);
48
+ const levelsUp = relative.split(path__namespace.sep).filter((part) => part === "..").length;
49
+ const sharedFolder = path__namespace.resolve(cwd, ...new Array(levelsUp).fill(".."));
50
+ return levelsUp > 0 && sharedFolder === path__namespace.parse(cwd).root ? fullpath : relative;
51
+ }
52
+ function toArray(patterns) {
53
+ return Array.isArray(patterns) ? patterns : [patterns];
54
+ }
55
+
56
+ exports.createUploadFilter = createUploadFilter;
57
+ //# sourceMappingURL=upload-filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload-filter.js","sources":["../../../src/core/upload-filter.ts"],"sourcesContent":["import * as path from 'path';\nimport { escape as escapeGlob, Ignore } from 'glob';\nimport type { NormalizedOptions } from './options-mapping';\n\nexport type UploadFilter = (filePath: string) => boolean;\n\n/**\n * Mirrors the glob of the upload from disk for files that are not on disk yet: a file is\n * uploaded when it matches one of `sourcemaps.assets` (all files when unset) and none of\n * `sourcemaps.ignore`.\n */\nexport function createUploadFilter(options: NormalizedOptions): UploadFilter {\n const cwd = process.cwd();\n\n const assets = options.sourcemaps?.assets;\n // `glob` walks `assets` from the working directory, so a relative pattern is tested against\n // the full path. It skips dot files and folders unless a pattern names them.\n const matchesAssets =\n assets === undefined\n ? () => true\n : createMatcher(\n toArray(assets).map(pattern => toAbsolutePattern(cwd, pattern)),\n { cwd, dot: false },\n );\n\n // `glob` tests `ignore` against the path relative to the working directory, and it matches\n // dot files and folders.\n const ignore = toArray(options.sourcemaps?.ignore ?? []);\n const matchesIgnore = ignore.length === 0 ? () => false : createMatcher(ignore, { cwd, dot: true });\n\n return filePath => matchesAssets(filePath) && !matchesIgnore(filePath);\n}\n\n// `glob` exports the matcher behind its `ignore` option, so both options follow the rules of\n// the upload from disk.\nfunction createMatcher(patterns: string[], { cwd, dot }: { cwd: string; dot: boolean }): UploadFilter {\n const matcher = new Ignore([], { nocase: process.platform === 'darwin' || process.platform === 'win32' });\n // `Ignore` always parses in `dot: true` mode, so the option is set before the patterns are added.\n matcher.mmopts.dot = dot;\n for (const pattern of patterns) {\n matcher.add(pattern);\n }\n return filePath => {\n const fullpath = path.resolve(cwd, filePath);\n const relative = toGlobRelativePath(cwd, fullpath);\n return matcher.ignored({ fullpath: () => fullpath, relative: () => relative } as Parameters<Ignore['ignored']>[0]);\n };\n}\n\nfunction toAbsolutePattern(cwd: string, pattern: string): string {\n return path.isAbsolute(pattern) ? pattern : `${escapeGlob(cwd.split(path.sep).join('/'))}/${pattern}`;\n}\n\n// Like path-scurry: a file outside the working directory gets a `../` path, unless the two\n// share only the file system root. Then it keeps its full path.\nfunction toGlobRelativePath(cwd: string, fullpath: string): string {\n const relative = path.relative(cwd, fullpath);\n const levelsUp = relative.split(path.sep).filter(part => part === '..').length;\n const sharedFolder = path.resolve(cwd, ...new Array<string>(levelsUp).fill('..'));\n return levelsUp > 0 && sharedFolder === path.parse(cwd).root ? fullpath : relative;\n}\n\nfunction toArray(patterns: string | string[]): string[] {\n return Array.isArray(patterns) ? patterns : [patterns];\n}\n"],"names":["Ignore","path","escapeGlob"],"mappings":";;;;;;;;;;;;;;;;;;;AAWO,SAAS,mBAAmB,OAAA,EAA0C;AAC3E,EAAA,MAAM,GAAA,GAAM,QAAQ,GAAA,EAAI;AAExB,EAAA,MAAM,MAAA,GAAS,QAAQ,UAAA,EAAY,MAAA;AAGnC,EAAA,MAAM,aAAA,GACJ,MAAA,KAAW,MAAA,GACP,MAAM,IAAA,GACN,aAAA;AAAA,IACE,OAAA,CAAQ,MAAM,CAAA,CAAE,GAAA,CAAI,aAAW,iBAAA,CAAkB,GAAA,EAAK,OAAO,CAAC,CAAA;AAAA,IAC9D,EAAE,GAAA,EAAK,GAAA,EAAK,KAAA;AAAM,GACpB;AAIN,EAAA,MAAM,SAAS,OAAA,CAAQ,OAAA,CAAQ,UAAA,EAAY,MAAA,IAAU,EAAE,CAAA;AACvD,EAAA,MAAM,aAAA,GAAgB,MAAA,CAAO,MAAA,KAAW,CAAA,GAAI,MAAM,KAAA,GAAQ,aAAA,CAAc,MAAA,EAAQ,EAAE,GAAA,EAAK,GAAA,EAAK,IAAA,EAAM,CAAA;AAElG,EAAA,OAAO,cAAY,aAAA,CAAc,QAAQ,CAAA,IAAK,CAAC,cAAc,QAAQ,CAAA;AACvE;AAIA,SAAS,aAAA,CAAc,QAAA,EAAoB,EAAE,GAAA,EAAK,KAAI,EAAgD;AACpG,EAAA,MAAM,OAAA,GAAU,IAAIA,WAAA,CAAO,EAAC,EAAG,EAAE,MAAA,EAAQ,OAAA,CAAQ,QAAA,KAAa,QAAA,IAAY,OAAA,CAAQ,QAAA,KAAa,SAAS,CAAA;AAExG,EAAA,OAAA,CAAQ,OAAO,GAAA,GAAM,GAAA;AACrB,EAAA,KAAA,MAAW,WAAW,QAAA,EAAU;AAC9B,IAAA,OAAA,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,QAAA,GAAW,CAAC,QAAQ,CAAA;AACvD;;;;"}
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const LIB_VERSION = "11.10.0";
3
+ const LIB_VERSION = "11.12.0";
4
4
 
5
5
  exports.LIB_VERSION = LIB_VERSION;
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"11.10.0\";\n"],"names":[],"mappings":";;AAAO,MAAM,WAAA,GAAc;;;;"}
1
+ {"version":3,"file":"version.js","sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"11.12.0\";\n"],"names":[],"mappings":";;AAAO,MAAM,WAAA,GAAc;;;;"}