@sentry/bundler-plugins 11.9.0 → 11.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +5 -1
  2. package/build/cjs/bun/index.js +126 -0
  3. package/build/cjs/bun/index.js.map +1 -0
  4. package/build/cjs/core/build-plugin-manager.js +165 -33
  5. package/build/cjs/core/build-plugin-manager.js.map +1 -1
  6. package/build/cjs/core/component-annotation-oxc.js +1 -1
  7. package/build/cjs/core/debug-id-upload.js +64 -55
  8. package/build/cjs/core/debug-id-upload.js.map +1 -1
  9. package/build/cjs/core/index.js +2 -0
  10. package/build/cjs/core/index.js.map +1 -1
  11. package/build/cjs/core/options-mapping.js +6 -0
  12. package/build/cjs/core/options-mapping.js.map +1 -1
  13. package/build/cjs/core/sentry/telemetry.js +4 -0
  14. package/build/cjs/core/sentry/telemetry.js.map +1 -1
  15. package/build/cjs/core/sentry/transports.js +3 -3
  16. package/build/cjs/core/sentry/transports.js.map +1 -1
  17. package/build/cjs/core/sourcemap-settings.js +63 -0
  18. package/build/cjs/core/sourcemap-settings.js.map +1 -0
  19. package/build/cjs/core/utils.js +1 -1
  20. package/build/cjs/core/version.js +1 -1
  21. package/build/cjs/core/version.js.map +1 -1
  22. package/build/cjs/esbuild/index.js +2 -2
  23. package/build/cjs/esbuild/index.js.map +1 -1
  24. package/build/cjs/rollup/index.js +1 -1
  25. package/build/esm/bun/index.js +109 -0
  26. package/build/esm/bun/index.js.map +1 -0
  27. package/build/esm/core/build-plugin-manager.js +166 -34
  28. package/build/esm/core/build-plugin-manager.js.map +1 -1
  29. package/build/esm/core/debug-id-upload.js +62 -56
  30. package/build/esm/core/debug-id-upload.js.map +1 -1
  31. package/build/esm/core/index.js +1 -0
  32. package/build/esm/core/index.js.map +1 -1
  33. package/build/esm/core/options-mapping.js +6 -0
  34. package/build/esm/core/options-mapping.js.map +1 -1
  35. package/build/esm/core/sentry/telemetry.js +4 -0
  36. package/build/esm/core/sentry/telemetry.js.map +1 -1
  37. package/build/esm/core/sourcemap-settings.js +61 -0
  38. package/build/esm/core/sourcemap-settings.js.map +1 -0
  39. package/build/esm/core/version.js +1 -1
  40. package/build/esm/core/version.js.map +1 -1
  41. package/build/esm/esbuild/index.js +2 -2
  42. package/build/esm/esbuild/index.js.map +1 -1
  43. package/build/esm/package.json +1 -1
  44. package/build/types/bun/index.d.ts +25 -0
  45. package/build/types/bun/index.d.ts.map +1 -0
  46. package/build/types/core/build-plugin-manager.d.ts +57 -1
  47. package/build/types/core/build-plugin-manager.d.ts.map +1 -1
  48. package/build/types/core/debug-id-upload.d.ts +38 -2
  49. package/build/types/core/debug-id-upload.d.ts.map +1 -1
  50. package/build/types/core/index.d.ts +3 -0
  51. package/build/types/core/index.d.ts.map +1 -1
  52. package/build/types/core/options-mapping.d.ts +1 -0
  53. package/build/types/core/options-mapping.d.ts.map +1 -1
  54. package/build/types/core/sentry/telemetry.d.ts.map +1 -1
  55. package/build/types/core/sourcemap-settings.d.ts +28 -0
  56. package/build/types/core/sourcemap-settings.d.ts.map +1 -0
  57. package/build/types/core/types.d.ts +11 -0
  58. package/build/types/core/types.d.ts.map +1 -1
  59. package/build/types/core/version.d.ts +1 -1
  60. package/build/types/core/version.d.ts.map +1 -1
  61. package/build/types/esbuild/index.d.ts.map +1 -1
  62. package/package.json +12 -7
@@ -2,56 +2,93 @@ import fs__default from 'fs';
2
2
  import path__default from 'path';
3
3
  import * as url from 'url';
4
4
  import * as util from 'util';
5
- import { promisify } from 'util';
6
5
  import { stripQueryAndHashFromPath } from './utils.js';
7
6
 
8
7
  function createDebugIdUploadFunction({ sentryBuildPluginManager }) {
9
- return async (buildArtifactPaths) => {
8
+ return async (buildArtifactPaths, opts) => {
10
9
  const cleanedPaths = buildArtifactPaths.map(stripQueryAndHashFromPath);
11
- await sentryBuildPluginManager.uploadSourcemaps(cleanedPaths);
10
+ return sentryBuildPluginManager.uploadSourcemaps(cleanedPaths, opts);
12
11
  };
13
12
  }
14
13
  async function prepareBundleForDebugIdUpload(bundleFilePath, uploadFolder, chunkIndex, logger, rewriteSourcesHook, resolveSourceMapHook) {
15
14
  let bundleContent;
16
15
  try {
17
- bundleContent = await promisify(fs__default.readFile)(bundleFilePath, "utf8");
16
+ bundleContent = await fs__default.promises.readFile(bundleFilePath, "utf8");
18
17
  } catch (e) {
19
18
  logger.error(`Could not read bundle to determine debug ID and source map: ${bundleFilePath}`, e);
20
19
  return;
21
20
  }
22
- const debugId = determineDebugIdFromBundleSource(bundleContent);
23
- if (debugId === void 0) {
21
+ if (determineDebugIdFromBundleSource(bundleContent) === void 0) {
24
22
  logger.debug(
25
23
  `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}`
26
24
  );
27
25
  return;
28
26
  }
29
- const uniqueUploadName = `${debugId}-${chunkIndex}`;
30
- bundleContent = addDebugIdToBundleSource(bundleContent, debugId);
31
27
  const sourceMapPath = await determineSourceMapPathFromBundle(
32
28
  bundleFilePath,
33
29
  bundleContent,
34
30
  logger,
35
31
  resolveSourceMapHook
36
32
  );
37
- if (!sourceMapPath && !bundleHasInlineSourceMap(bundleContent)) {
38
- logger.debug(`Not uploading bundle without a source map: ${bundleFilePath}`);
33
+ let sourceMapSource;
34
+ if (sourceMapPath) {
35
+ try {
36
+ sourceMapSource = await fs__default.promises.readFile(sourceMapPath, "utf8");
37
+ } catch (e) {
38
+ logger.error(`Failed to read source map for debug ID upload: ${sourceMapPath}`, e);
39
+ return;
40
+ }
41
+ }
42
+ const result = prepareArtifactForUpload({
43
+ code: bundleContent,
44
+ mapSource: sourceMapSource,
45
+ mapDir: path__default.dirname(sourceMapPath ?? bundleFilePath),
46
+ rewriteSourcesHook
47
+ });
48
+ if (!result.ok) {
49
+ if (result.reason === "invalid-source-map") {
50
+ logger.error(`Failed to parse source map for debug ID upload: ${sourceMapPath}`);
51
+ } else {
52
+ logger.debug(`Not uploading bundle without a source map: ${bundleFilePath}`);
53
+ }
39
54
  return;
40
55
  }
41
- const writeSourceFilePromise = fs__default.promises.writeFile(
42
- path__default.join(uploadFolder, `${uniqueUploadName}.js`),
43
- bundleContent,
44
- "utf-8"
45
- );
46
- const writeSourceMapFilePromise = sourceMapPath ? prepareSourceMapForDebugIdUpload(
47
- sourceMapPath,
48
- path__default.join(uploadFolder, `${uniqueUploadName}.js.map`),
49
- debugId,
50
- rewriteSourcesHook,
51
- logger
52
- ) : Promise.resolve();
53
- await writeSourceFilePromise;
54
- await writeSourceMapFilePromise;
56
+ await writePreparedArtifact(uploadFolder, `${result.artifact.debugId}-${chunkIndex}`, result.artifact);
57
+ }
58
+ function prepareArtifactForUpload(input) {
59
+ const debugId = determineDebugIdFromBundleSource(input.code);
60
+ if (debugId === void 0) {
61
+ return { ok: false, reason: "no-debug-id" };
62
+ }
63
+ const bundleSource = addDebugIdToBundleSource(input.code, debugId);
64
+ if (input.mapSource === void 0) {
65
+ if (!bundleHasInlineSourceMap(input.code)) {
66
+ return { ok: false, reason: "no-source-map" };
67
+ }
68
+ return { ok: true, artifact: { debugId, bundleSource, sourceMapSource: void 0 } };
69
+ }
70
+ const map = parseSourceMap(input.mapSource);
71
+ if (!map) {
72
+ return { ok: false, reason: "invalid-source-map" };
73
+ }
74
+ setDebugIdOnSourceMap(map, debugId);
75
+ if (Array.isArray(map["sources"])) {
76
+ map["sources"] = map["sources"].map(
77
+ (source) => input.rewriteSourcesHook(source, map, { mapDir: input.mapDir })
78
+ );
79
+ }
80
+ return { ok: true, artifact: { debugId, bundleSource, sourceMapSource: JSON.stringify(map) } };
81
+ }
82
+ async function writePreparedArtifact(uploadFolder, uniqueUploadName, artifact) {
83
+ const writes = [
84
+ fs__default.promises.writeFile(path__default.join(uploadFolder, `${uniqueUploadName}.js`), artifact.bundleSource, "utf-8")
85
+ ];
86
+ if (artifact.sourceMapSource !== void 0) {
87
+ writes.push(
88
+ fs__default.promises.writeFile(path__default.join(uploadFolder, `${uniqueUploadName}.js.map`), artifact.sourceMapSource, "utf-8")
89
+ );
90
+ }
91
+ await Promise.all(writes);
55
92
  }
56
93
  function determineDebugIdFromBundleSource(code) {
57
94
  const match = code.match(
@@ -194,37 +231,6 @@ async function determineSourceMapPathFromBundle(bundlePath, bundleSource, logger
194
231
  );
195
232
  return void 0;
196
233
  }
197
- async function prepareSourceMapForDebugIdUpload(sourceMapPath, targetPath, debugId, rewriteSourcesHook, logger) {
198
- let sourceMapFileContent;
199
- try {
200
- sourceMapFileContent = await util.promisify(fs__default.readFile)(sourceMapPath, {
201
- encoding: "utf8"
202
- });
203
- } catch (e) {
204
- logger.error(`Failed to read source map for debug ID upload: ${sourceMapPath}`, e);
205
- return;
206
- }
207
- let map;
208
- try {
209
- map = JSON.parse(sourceMapFileContent);
210
- setDebugIdOnSourceMap(map, debugId);
211
- } catch {
212
- logger.error(`Failed to parse source map for debug ID upload: ${sourceMapPath}`);
213
- return;
214
- }
215
- if (map["sources"] && Array.isArray(map["sources"])) {
216
- const mapDir = path__default.dirname(sourceMapPath);
217
- map["sources"] = map["sources"].map((source) => rewriteSourcesHook(source, map, { mapDir }));
218
- }
219
- try {
220
- await util.promisify(fs__default.writeFile)(targetPath, JSON.stringify(map), {
221
- encoding: "utf8"
222
- });
223
- } catch (e) {
224
- logger.error(`Failed to prepare source map for debug ID upload: ${sourceMapPath}`, e);
225
- return;
226
- }
227
- }
228
234
  const PROTOCOL_REGEX = /^[a-zA-Z][a-zA-Z0-9+\-.]*:\/\//;
229
235
  function defaultRewriteSourcesHook(source) {
230
236
  if (source.match(PROTOCOL_REGEX)) {
@@ -234,5 +240,5 @@ function defaultRewriteSourcesHook(source) {
234
240
  }
235
241
  }
236
242
 
237
- export { addDebugIdToEmittedArtifacts, createDebugIdUploadFunction, defaultRewriteSourcesHook, determineSourceMapPathFromBundle, prepareBundleForDebugIdUpload, stampDebugId };
243
+ export { addDebugIdToEmittedArtifacts, createDebugIdUploadFunction, defaultRewriteSourcesHook, determineSourceMapPathFromBundle, prepareArtifactForUpload, prepareBundleForDebugIdUpload, stampDebugId, writePreparedArtifact };
238
244
  //# 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":["fs","path"],"mappings":";;;;;;;AAcO,SAAS,2BAAA,CAA4B,EAAE,wBAAA,EAAyB,EAA+B;AACpG,EAAA,OAAO,OAAO,kBAAA,KAAiC;AAG7C,IAAA,MAAM,YAAA,GAAe,kBAAA,CAAmB,GAAA,CAAI,yBAAyB,CAAA;AACrE,IAAA,MAAM,wBAAA,CAAyB,iBAAiB,YAAY,CAAA;AAAA,EAC9D,CAAA;AACF;AAEA,eAAsB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AA,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":["fs","path"],"mappings":";;;;;;AAaO,SAAS,2BAAA,CAA4B,EAAE,wBAAA,EAAyB,EAA+B;AACpG,EAAA,OAAO,OAAO,oBAA8B,IAAA,KAAuC;AAGjF,IAAA,MAAM,YAAA,GAAe,kBAAA,CAAmB,GAAA,CAAI,yBAAyB,CAAA;AACrE,IAAA,OAAO,wBAAA,CAAyB,gBAAA,CAAiB,YAAA,EAAc,IAAI,CAAA;AAAA,EACrE,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,MAAMA,WAAA,CAAG,QAAA,CAAS,QAAA,CAAS,gBAAgB,MAAM,CAAA;AAAA,EACnE,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,IAAI,gCAAA,CAAiC,aAAa,CAAA,KAAM,MAAA,EAAW;AACjE,IAAA,MAAA,CAAO,KAAA;AAAA,MACL,0KAA0K,cAAc,CAAA;AAAA,KAC1L;AACA,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,gBAAgB,MAAM,gCAAA;AAAA,IAC1B,cAAA;AAAA,IACA,aAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AAEA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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;;;;"}
@@ -5,6 +5,7 @@ export { getCodeInjectionPosition } from './get-code-injection-position.js';
5
5
  export { createComponentNameAnnotateHooks } from './component-annotate-hooks.js';
6
6
  export { createSentryBuildPluginManager } from './build-plugin-manager.js';
7
7
  export { addDebugIdToEmittedArtifacts, createDebugIdUploadFunction, stampDebugId } from './debug-id-upload.js';
8
+ export { decideSourceMapHandling } from './sourcemap-settings.js';
8
9
 
9
10
  function isJsFile(fileName) {
10
11
  const cleanFileName = stripQueryAndHashFromPath(fileName);
@@ -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":[],"mappings":";;;;;;;;AAMO,SAAS,SAAS,QAAA,EAA2B;AAClD,EAAA,MAAM,aAAA,GAAgB,0BAA0B,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,kBAAkB,yBAAA,CAA0B,cAAc,CAAA,CAAE,QAAA,CAAS,OAAO,CAAA,EAAG;AACjF,IAAA,OAAO,oBAAoB,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,IAAI,aAAA;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';\n"],"names":[],"mappings":";;;;;;;;;AAMO,SAAS,SAAS,QAAA,EAA2B;AAClD,EAAA,MAAM,aAAA,GAAgB,0BAA0B,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,kBAAkB,yBAAA,CAA0B,cAAc,CAAA,CAAE,QAAA,CAAS,OAAO,CAAA,EAAG;AACjF,IAAA,OAAO,oBAAoB,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,MA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
94
  );
95
95
  return false;
96
96
  }
97
+ if (options.sourcemaps?.deleteSourcemapsAfterUpload && options.sourcemaps.disable) {
98
+ logger.warn(
99
+ "The `sourcemaps.deleteSourcemapsAfterUpload` option is set but source map upload is disabled via `sourcemaps.disable`.",
100
+ "Source maps will not be deleted."
101
+ );
102
+ }
97
103
  if (options.project && Array.isArray(options.project)) {
98
104
  if (options.project.length === 0) {
99
105
  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":[],"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,CAAA,CAAE,KAAA,CAAM,GAAG,CAAA,CAAE,GAAA,CAAI,CAAA,CAAA,KAAK,CAAA,CAAE,IAAA,EAAM,CAAA,GAC1D,OAAA,CAAQ,GAAA,CAAI,gBAAgB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AQ,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":[],"mappings":";;;AA2FO,MAAM,eAAA,GAAkB;AAGxB,SAAS,qBAAqB,WAAA,EAA6C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ACF;AAAA,EACF;AAEA,EAAA,IAAI,OAAA,CAAQ,OAAA,EAAS,MAAA,IAAU,OAAO,OAAA,CAAQ,OAAA,CAAQ,MAAA,KAAW,QAAA,IAAY,CAAC,OAAA,CAAQ,OAAA,CAAQ,MAAA,CAAO,GAAA,EAAK;AACxG,IAAA,MAAA,CAAO,KAAA;AAAA,MACL,+EAAA;AAAA,MACA;AAAA,KACF;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,IAAI,OAAA,CAAQ,UAAA,EAAY,2BAAA,IAA+B,OAAA,CAAQ,WAAW,OAAA,EAAS;AACjF,IAAA,MAAA,CAAO,IAAA;AAAA,MACL,wHAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF;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;;;;"}
@@ -67,6 +67,10 @@ function setTelemetryDataOnScope(options, scope, buildTool, buildToolMajorVersio
67
67
  scope.setTag("custom-error-handler", !!errorHandler);
68
68
  scope.setTag("sourcemaps-assets", !!sourcemaps?.assets);
69
69
  scope.setTag("delete-after-upload", !!sourcemaps?.filesToDeleteAfterUpload);
70
+ scope.setTag(
71
+ "delete-sourcemaps-after-upload",
72
+ sourcemaps?.deleteSourcemapsAfterUpload === void 0 ? "auto" : String(sourcemaps.deleteSourcemapsAfterUpload)
73
+ );
70
74
  scope.setTag("sourcemaps-disabled", !!sourcemaps?.disable);
71
75
  scope.setTag("react-annotate", !!reactComponentAnnotation?.enabled);
72
76
  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":[],"mappings":";;;;;;;AAaA,MAAM,oBAAA,GAAuB,WAAA;AAE7B,MAAM,WAAA,GAAc,iBAAA,CAAkB,mBAAA,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,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,QAAQ,eAAA,EAAiB;AAC3B,IAAA,OAAO,IAAA;AAAA,EACT;AAIA,EAAA,MAAM,aAAa,MAAM,IAAI,gBAAA,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":[],"mappings":";;;;;;;AAaA,MAAM,oBAAA,GAAuB,WAAA;A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;AAAA,IACnE,OAAA,EAAS;AAAA,GACV,CAAA;AAED,EAAA,IAAI,qBAAA,EAAuB;AACzB,IAAA,KAAA,CAAM,MAAA,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,QAAQ,eAAA,EAAiB;AAC3B,IAAA,OAAO,IAAA;AAAA,EACT;AAIA,EAAA,MAAM,aAAa,MAAM,IAAI,gBAAA,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;;;;"}
@@ -0,0 +1,61 @@
1
+ const NO_CHANGE = { enableHidden: false, deleteAfterUpload: false };
2
+ function decideSourceMapHandling(kind, options, uploadPossible) {
3
+ const deleteOption = options.sourcemaps?.deleteSourcemapsAfterUpload;
4
+ if (!uploadPossible || options.sourcemaps?.disable) {
5
+ return NO_CHANGE;
6
+ }
7
+ switch (kind) {
8
+ case "off":
9
+ return {
10
+ ...NO_CHANGE,
11
+ log: {
12
+ level: "warn",
13
+ 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."
14
+ }
15
+ };
16
+ case "inline":
17
+ return {
18
+ ...NO_CHANGE,
19
+ log: {
20
+ level: "warn",
21
+ 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."
22
+ }
23
+ };
24
+ case "unset":
25
+ if (deleteOption === false) {
26
+ return {
27
+ enableHidden: true,
28
+ deleteAfterUpload: false,
29
+ log: {
30
+ level: "info",
31
+ message: "Enabling hidden source maps. They are uploaded to Sentry and kept in the build output."
32
+ }
33
+ };
34
+ }
35
+ return {
36
+ enableHidden: true,
37
+ deleteAfterUpload: true,
38
+ log: {
39
+ level: "info",
40
+ message: "Enabling hidden source maps. They are uploaded to Sentry and removed from the build output. Set `sourcemaps.deleteSourcemapsAfterUpload: false` to keep them."
41
+ }
42
+ };
43
+ case "hidden":
44
+ return { enableHidden: false, deleteAfterUpload: deleteOption === true };
45
+ case "visible":
46
+ if (deleteOption !== true) {
47
+ return NO_CHANGE;
48
+ }
49
+ return {
50
+ enableHidden: true,
51
+ deleteAfterUpload: true,
52
+ log: {
53
+ level: "info",
54
+ message: "Switching to hidden source maps because `sourcemaps.deleteSourcemapsAfterUpload` is set. Without the `sourceMappingURL` comment browsers do not request the removed map files."
55
+ }
56
+ };
57
+ }
58
+ }
59
+
60
+ export { decideSourceMapHandling };
61
+ //# 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;;;;"}
@@ -1,4 +1,4 @@
1
- const LIB_VERSION = "11.9.0";
1
+ const LIB_VERSION = "11.11.0";
2
2
 
3
3
  export { LIB_VERSION };
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"11.9.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.11.0\";\n"],"names":[],"mappings":"AAAO,MAAM,WAAA,GAAc;;;;"}
@@ -69,7 +69,7 @@ function sentryEsbuildPlugin(userOptions = {}) {
69
69
  });
70
70
  return {
71
71
  name: pluginName,
72
- setup({ initialOptions, onLoad, onResolve, onEnd }) {
72
+ setup({ initialOptions, onLoad, onResolve, onStart, onEnd }) {
73
73
  if (!staticInjectionCode.isEmpty()) {
74
74
  const virtualInjectionFilePath = path.resolve("_sentry-injection-stub");
75
75
  initialOptions.inject = initialOptions.inject || [];
@@ -97,7 +97,7 @@ function sentryEsbuildPlugin(userOptions = {}) {
97
97
  initialOptions.define = { ...initialOptions.define, ...replacementStringValues };
98
98
  }
99
99
  if (sourcemapsEnabled) {
100
- debugIdWrappedPaths.clear();
100
+ onStart(() => debugIdWrappedPaths.clear());
101
101
  if (!initialOptions.bundle) {
102
102
  logger.warn(
103
103
  "The Sentry esbuild plugin only supports esbuild with `bundle: true` being set in the esbuild build options. Esbuild will probably crash now. Sorry about that. If you need to upload sourcemaps without `bundle: true`, it is recommended to use Sentry CLI instead: https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/cli/"