@sentry/bundler-plugins 11.13.0 → 11.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/bun/index.js +6 -2
- package/build/cjs/bun/index.js.map +1 -1
- package/build/cjs/core/build-plugin-manager.js +6 -2
- package/build/cjs/core/build-plugin-manager.js.map +1 -1
- package/build/cjs/core/debug-id-upload.js +1 -1
- package/build/cjs/core/debug-id-upload.js.map +1 -1
- package/build/cjs/core/index.js +3 -0
- package/build/cjs/core/index.js.map +1 -1
- package/build/cjs/core/options-mapping.js +6 -1
- package/build/cjs/core/options-mapping.js.map +1 -1
- package/build/cjs/core/sentry/telemetry.js +3 -0
- package/build/cjs/core/sentry/telemetry.js.map +1 -1
- package/build/cjs/core/sentry/transports.js +1 -1
- package/build/cjs/core/sourcemap-settings.js +85 -5
- package/build/cjs/core/sourcemap-settings.js.map +1 -1
- package/build/cjs/core/utils.js +14 -6
- package/build/cjs/core/utils.js.map +1 -1
- package/build/cjs/core/version.js +1 -1
- package/build/cjs/core/version.js.map +1 -1
- package/build/cjs/esbuild/index.js +17 -11
- package/build/cjs/esbuild/index.js.map +1 -1
- package/build/cjs/rollup/index.js +20 -12
- package/build/cjs/rollup/index.js.map +1 -1
- package/build/cjs/rollup/source-map-handling.js +19 -1
- package/build/cjs/rollup/source-map-handling.js.map +1 -1
- package/build/cjs/vite/release-html-injection.js +33 -0
- package/build/cjs/vite/release-html-injection.js.map +1 -0
- package/build/cjs/vite/source-map-hooks.js +8 -6
- package/build/cjs/vite/source-map-hooks.js.map +1 -1
- package/build/cjs/webpack/index.js +40 -8
- package/build/cjs/webpack/index.js.map +1 -1
- package/build/esm/bun/index.js +6 -2
- package/build/esm/bun/index.js.map +1 -1
- package/build/esm/core/build-plugin-manager.js +7 -3
- package/build/esm/core/build-plugin-manager.js.map +1 -1
- package/build/esm/core/debug-id-upload.js +1 -1
- package/build/esm/core/debug-id-upload.js.map +1 -1
- package/build/esm/core/index.js +3 -3
- package/build/esm/core/index.js.map +1 -1
- package/build/esm/core/options-mapping.js +7 -2
- package/build/esm/core/options-mapping.js.map +1 -1
- package/build/esm/core/sentry/telemetry.js +3 -0
- package/build/esm/core/sentry/telemetry.js.map +1 -1
- package/build/esm/core/sentry/transports.js +1 -1
- package/build/esm/core/sourcemap-settings.js +84 -6
- package/build/esm/core/sourcemap-settings.js.map +1 -1
- package/build/esm/core/utils.js +11 -4
- package/build/esm/core/utils.js.map +1 -1
- package/build/esm/core/version.js +1 -1
- package/build/esm/core/version.js.map +1 -1
- package/build/esm/esbuild/index.js +17 -11
- package/build/esm/esbuild/index.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/rollup/index.js +20 -12
- package/build/esm/rollup/index.js.map +1 -1
- package/build/esm/rollup/source-map-handling.js +19 -1
- package/build/esm/rollup/source-map-handling.js.map +1 -1
- package/build/esm/vite/release-html-injection.js +33 -0
- package/build/esm/vite/release-html-injection.js.map +1 -0
- package/build/esm/vite/source-map-hooks.js +9 -7
- package/build/esm/vite/source-map-hooks.js.map +1 -1
- package/build/esm/webpack/index.js +40 -8
- package/build/esm/webpack/index.js.map +1 -1
- package/build/types/bun/index.d.ts.map +1 -1
- package/build/types/core/build-plugin-manager.d.ts.map +1 -1
- package/build/types/core/debug-id-upload.d.ts +1 -1
- package/build/types/core/index.d.ts +2 -2
- package/build/types/core/index.d.ts.map +1 -1
- package/build/types/core/options-mapping.d.ts +4 -1
- package/build/types/core/options-mapping.d.ts.map +1 -1
- package/build/types/core/sentry/telemetry.d.ts.map +1 -1
- package/build/types/core/sourcemap-settings.d.ts +19 -0
- package/build/types/core/sourcemap-settings.d.ts.map +1 -1
- package/build/types/core/types.d.ts +54 -1
- package/build/types/core/types.d.ts.map +1 -1
- package/build/types/core/utils.d.ts +7 -0
- package/build/types/core/utils.d.ts.map +1 -1
- package/build/types/core/version.d.ts +1 -1
- package/build/types/esbuild/index.d.ts.map +1 -1
- package/build/types/rollup/index.d.ts +36 -5
- package/build/types/rollup/index.d.ts.map +1 -1
- package/build/types/rollup/source-map-handling.d.ts +5 -0
- package/build/types/rollup/source-map-handling.d.ts.map +1 -1
- package/build/types/vite/release-html-injection.d.ts +31 -0
- package/build/types/vite/release-html-injection.d.ts.map +1 -0
- package/build/types/vite/source-map-hooks.d.ts +1 -0
- package/build/types/vite/source-map-hooks.d.ts.map +1 -1
- package/build/types/webpack/index.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options-mapping.js","names":["determineReleaseName","getVercelEnv","readCommitEnvVar","canAutoDetectRepository"],"sources":["../../../src/core/options-mapping.ts"],"sourcesContent":["import { getVercelEnv } from '@sentry/core';\nimport type { Logger } from './logger';\nimport type {\n InternalOptions as UserOptions,\n SetCommitsOptions,\n RewriteSourcesHook,\n ResolveSourceMapHook,\n IncludeEntry,\n ModuleMetadata,\n ModuleMetadataCallback,\n} from './types';\nimport { determineReleaseName, canAutoDetectRepository, readCommitEnvVar } from './utils';\n\nexport type NormalizedOptions = {\n org: string | undefined;\n project: string | string[] | undefined;\n authToken: string | undefined;\n url: string | undefined;\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 | ((environment?: string) => boolean | undefined);\n sdkEnabledSourceMaps?: boolean | ((environment?: string) => boolean | 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 // No sentry.io default: the CLI then uses the server an `sntrys_` org token was issued for, and\n // sentry.io otherwise. A default here would send self-hosted tokens to sentry.io.\n url: userOptions.url ?? process.env['SENTRY_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 const vercelEnv = getVercelEnv();\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 vercelEnv === '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 if (process.env['VERCEL'] && vercelEnv !== 'production' && !canAutoDetectRepository()) {\n // Vercel's own builders have no git remote and no other CI variables, so `--auto` can only fail there.\n // Builds that have either, such as `vercel build` in GitHub Actions, keep `--auto` below.\n options.release.setCommits = false;\n } else {\n options.release.setCommits = {\n shouldNotThrowOnFailure: true,\n auto: true,\n ignoreEmpty: true,\n ignoreMissing: true,\n };\n }\n }\n\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"],"mappings":";;;AA4FA,MAAa,kBAAkB;AAG/B,SAAgB,qBAAqB,aAA6C;CAChF,M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AO;AACT"}
|
|
1
|
+
{"version":3,"file":"options-mapping.js","names":["resolveReleaseName","getVercelEnv","readCommitEnvVar","canAutoDetectRepository"],"sources":["../../../src/core/options-mapping.ts"],"sourcesContent":["import { getVercelEnv } from '@sentry/core';\nimport type { Logger } from './logger';\nimport type {\n InternalOptions as UserOptions,\n SetCommitsOptions,\n RewriteSourcesHook,\n ResolveSourceMapHook,\n IncludeEntry,\n ModuleMetadata,\n ModuleMetadataCallback,\n} from './types';\nimport { canAutoDetectRepository, readCommitEnvVar, resolveReleaseName } from './utils';\n\nexport type NormalizedOptions = {\n org: string | undefined;\n project: string | string[] | undefined;\n authToken: string | undefined;\n url: string | undefined;\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 upload?: boolean;\n injectDebugIds?: boolean;\n delete?: boolean;\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 | ((environment?: string) => boolean | undefined);\n sdkEnabledSourceMaps?: boolean | ((environment?: string) => boolean | undefined);\n }\n | undefined;\n release: {\n name: string | undefined;\n inject: boolean | 'html';\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 // No sentry.io default: the CLI then uses the server an `sntrys_` org token was issued for, and\n // sentry.io otherwise. A default here would send self-hosted tokens to sentry.io.\n url: userOptions.url ?? process.env['SENTRY_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: resolveReleaseName(userOptions.release?.name),\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 const vercelEnv = getVercelEnv();\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 vercelEnv === '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 if (process.env['VERCEL'] && vercelEnv !== 'production' && !canAutoDetectRepository()) {\n // Vercel's own builders have no git remote and no other CI variables, so `--auto` can only fail there.\n // Builds that have either, such as `vercel build` in GitHub Actions, keep `--auto` below.\n options.release.setCommits = false;\n } else {\n options.release.setCommits = {\n shouldNotThrowOnFailure: true,\n auto: true,\n ignoreEmpty: true,\n ignoreMissing: true,\n };\n }\n }\n\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 const sourcemaps = options.sourcemaps;\n const usesFeatureOptions = sourcemaps?.upload !== undefined || sourcemaps?.injectDebugIds !== undefined;\n if (usesFeatureOptions && sourcemaps?.disable !== undefined) {\n logger.warn(\n '`sourcemaps.disable` is ignored because `sourcemaps.upload` or `sourcemaps.injectDebugIds` is set.',\n 'Please remove `sourcemaps.disable`.',\n );\n }\n if (sourcemaps?.injectDebugIds === false && sourcemaps.upload === true) {\n logger.warn(\n '`sourcemaps.upload` is set, but `sourcemaps.injectDebugIds` is `false`.',\n 'Source maps are not uploaded, because the upload matches files by debug ID.',\n );\n }\n if (sourcemaps?.delete !== undefined && sourcemaps.deleteSourcemapsAfterUpload !== undefined) {\n logger.warn(\n '`sourcemaps.deleteSourcemapsAfterUpload` is ignored because `sourcemaps.delete` is set.',\n 'Please remove `sourcemaps.deleteSourcemapsAfterUpload`.',\n );\n }\n if (sourcemaps?.delete === false && sourcemaps.filesToDeleteAfterUpload !== undefined) {\n logger.warn(\n '`sourcemaps.filesToDeleteAfterUpload` still deletes the files it matches, although `sourcemaps.delete` is `false`.',\n 'Remove `sourcemaps.filesToDeleteAfterUpload` to keep the source maps.',\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"],"mappings":";;;AA+FA,MAAa,kBAAkB;AAG/B,SAAgB,qBAAqB,aAA6C;CAChF,MAAM,UAAU;EACd,KAAK,YAAY,OAAO,QAAQ,IAAI;EACpC,SACE,YAAY,YACX,QAAQ,IAAI,iBAAiB,EAAE,SAAS,GAAG,IACxC,QAAQ,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC,KAAI,MAAK,EAAE,KAAK,CAAC,IAC1D,QAAQ,IAAI;EAClB,WAAW,YAAY,aAAa,QAAQ,IAAI;EAGhD,KAAK,YAAY,OAAO,QAAQ,IAAI;EACpC,SAAS,YAAY;EACrB,OAAO,YAAY,SAAS;EAC5B,QAAQ,YAAY,UAAU;EAC9B,cAAc,YAAY;EAC1B,WAAW,YAAY,aAAa;EACpC,SAAS,YAAY,WAAW;EAChC,YAAY,YAAY;EACxB,SAAS;GACP,GAAG,YAAY;GACf,MAAMA,cAAAA,mBAAmB,YAAY,SAAS,IAAI;GAClD,QAAQ,YAAY,SAAS,UAAU;GACvC,QAAQ,YAAY,SAAS,UAAU;GACvC,UAAU,YAAY,SAAS,YAAY;GAC3C,WAAW,YAAY,SAAS,aAAa,QAAQ,IAAI,wBAAwB;GAEjF,YAAY,YAAY,SAAS;EAInC;EACA,yBAAyB,YAAY;EACrC,0BAA0B,YAAY;EACtC,cAAc,EACZ,WAAW;GACT,eAAe,YAAY,cAAc,WAA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AD2B,YAAY,WAAW,KAAA,KAAa,YAAY,mBAAmB,KAAA,MACpE,YAAY,YAAY,KAAA,GAChD,OAAO,KACL,sGACA,qCACF;CAEF,IAAI,YAAY,mBAAmB,SAAS,WAAW,WAAW,MAChE,OAAO,KACL,2EACA,6EACF;CAEF,IAAI,YAAY,WAAW,KAAA,KAAa,WAAW,gCAAgC,KAAA,GACjF,OAAO,KACL,2FACA,yDACF;CAEF,IAAI,YAAY,WAAW,SAAS,WAAW,6BAA6B,KAAA,GAC1E,OAAO,KACL,sHACA,uEACF;CAGF,IAAI,QAAQ,SAAS,UAAU,OAAO,QAAQ,QAAQ,WAAW,YAAY,CAAC,QAAQ,QAAQ,OAAO,KAAK;EACxG,OAAO,MACL,iFACA,gCACF;EACA,OAAO;CACT;CAEA,IAAI,QAAQ,WAAW,MAAM,QAAQ,QAAQ,OAAO,GAAG;EACrD,IAAI,QAAQ,QAAQ,WAAW,GAAG;GAChC,OAAO,MACL,gEACA,2CACF;GACA,OAAO;EACT;EAGA,IADwB,QAAQ,QAAQ,QAAO,MAAK,OAAO,MAAM,YAAY,EAAE,KAAK,MAAM,EACxE,CAAC,CAAC,SAAS,GAAG;GAC9B,OAAO,MAAM,wDAAwD,yCAAyC;GAC9G,OAAO;EACT;CACF;CAEA,OAAO;AACT"}
|
|
@@ -64,6 +64,9 @@ function setTelemetryDataOnScope(options, scope, buildTool, buildToolMajorVersio
|
|
|
64
64
|
scope.setTag("delete-after-upload", !!sourcemaps?.filesToDeleteAfterUpload);
|
|
65
65
|
scope.setTag("delete-sourcemaps-after-upload", typeof sourcemaps?.deleteSourcemapsAfterUpload === "function" ? "function" : sourcemaps?.deleteSourcemapsAfterUpload === void 0 ? "auto" : String(sourcemaps.deleteSourcemapsAfterUpload));
|
|
66
66
|
scope.setTag("sourcemaps-disabled", !!sourcemaps?.disable);
|
|
67
|
+
scope.setTag("sourcemaps-upload", sourcemaps?.upload === void 0 ? "auto" : String(sourcemaps.upload));
|
|
68
|
+
scope.setTag("sourcemaps-inject-debug-ids", sourcemaps?.injectDebugIds === void 0 ? "auto" : String(sourcemaps.injectDebugIds));
|
|
69
|
+
scope.setTag("sourcemaps-delete", sourcemaps?.delete === void 0 ? "auto" : String(sourcemaps.delete));
|
|
67
70
|
scope.setTag("react-annotate", !!reactComponentAnnotation?.enabled);
|
|
68
71
|
scope.setTag("node", process.version);
|
|
69
72
|
scope.setTag("platform", process.platform);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.js","names":["createStackParser","nodeStackLineParser","LIB_VERSION","makeOptionallyEnabledNodeTransport","applySdkMetadata","ServerRuntimeClient","Scope","SentryCliAdapter"],"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 typeof sourcemaps?.deleteSourcemapsAfterUpload === 'function'\n ? 'function'\n : sourcemaps?.deleteSourcemapsAfterUpload === undefined\n ? 'auto'\n : 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 } = options;\n const url = options.url ?? SENTRY_SAAS_URL;\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"],"mappings":";;;;;;;AAaA,MAA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QAAQ,cAAc;CACxD,MAAM,OAAO,4BAA4B,CAAC,CAAC,QAAQ,aAAa,sBAAsB;CAGtF,IAAI,QAAQ,YACV,MAAM,OAAO,eAAe,QAAQ,WAAW,SAAS,OAAO,SAAS,QAAQ;MAEhF,MAAM,OAAO,eAAe,WAAW;CAEzC,MAAM,OAAO,oBAAoB,QAAQ,QAAQ;CACjD,MAAM,OAAO,kBAAkB,CAAC,CAAC,QAAQ,MAAM;CAG/C,MAAM,OAAO,wBAAwB,CAAC,CAAC,YAAY;CACnD,MAAM,OAAO,qBAAqB,CAAC,CAAC,YAAY,MAAM;CACtD,MAAM,OAAO,uBAAuB,CAAC,CAAC,YAAY,wBAAwB;CAC1E,MAAM,OACJ,kCACA,OAAO,YAAY,gCAAgC,aAC/C,aACA,YAAY,gCAAgC,KAAA,IAC1C,SACA,OAAO,WAAW,2BAA2B,CACrD;CACA,MAAM,OAAO,uBAAuB,CAAC,CAAC,YAAY,OAAO;
|
|
1
|
+
{"version":3,"file":"telemetry.js","names":["createStackParser","nodeStackLineParser","LIB_VERSION","makeOptionallyEnabledNodeTransport","applySdkMetadata","ServerRuntimeClient","Scope","SentryCliAdapter"],"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 typeof sourcemaps?.deleteSourcemapsAfterUpload === 'function'\n ? 'function'\n : sourcemaps?.deleteSourcemapsAfterUpload === undefined\n ? 'auto'\n : String(sourcemaps.deleteSourcemapsAfterUpload),\n );\n scope.setTag('sourcemaps-disabled', !!sourcemaps?.disable);\n scope.setTag('sourcemaps-upload', sourcemaps?.upload === undefined ? 'auto' : String(sourcemaps.upload));\n scope.setTag(\n 'sourcemaps-inject-debug-ids',\n sourcemaps?.injectDebugIds === undefined ? 'auto' : String(sourcemaps.injectDebugIds),\n );\n scope.setTag('sourcemaps-delete', sourcemaps?.delete === undefined ? 'auto' : String(sourcemaps.delete));\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 } = options;\n const url = options.url ?? SENTRY_SAAS_URL;\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"],"mappings":";;;;;;;AAaA,MAAM,uBAAuB;AAE7B,MAAM,eAAA,GAAcA,aAAAA,kBAAAA,EAAAA,GAAkBC,oBAAAA,oBAAAA,CAAoB,CAAC;AAE3D,SAAgB,qBACd,SACA,qBACA,WACA,uBAC8C;CAC9C,MAAM,gBAA4C;EAChD,UAAU;EACV,SAAS;GAAE,MAAM;GAAQ,SAAS,OAAO,QAAQ;EAAQ;EAEzD,KAAK;EAEL,kBAAkB;EAClB,gBAAgB;EAChB,YAAY;EAEZ,SAASC,gBAAAA;EACT,cAAc,CAAC;EACf,yBAAyB,CAAC,eAAe;EAEzC;EAEA,aAAY,UAAS;GACnB,MAAM,WAAW,QAAQ,SAAQ,cAAa;IAC5C,OAAO,UAAU;GACnB,CAAC;GAED,OAAO,MAAM;GACb,OAAO;EACT;EAIA,wBAAuB,UAAS;GAC9B,OAAO,MAAM;GACb,OAAO;EACT;EAIA,WAAWC,mBAAAA,mCAAmC,mBAAmB;CACnE;CAEAC,CAAAA,GAAAA,aAAAA,iBAAAA,CAAiB,eAAe,MAAM;CAEtC,MAAM,SAAS,IAAIC,oBAAAA,oBAAoB,aAAa;CACpD,MAAM,QA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,YAAY,mBAAmB,KAAA,IAAY,SAAS,OAAO,WAAW,cAAc,CACtF;CACA,MAAM,OAAO,qBAAqB,YAAY,WAAW,KAAA,IAAY,SAAS,OAAO,WAAW,MAAM,CAAC;CAEvG,MAAM,OAAO,kBAAkB,CAAC,CAAC,0BAA0B,OAAO;CAElE,MAAM,OAAO,QAAQ,QAAQ,OAAO;CACpC,MAAM,OAAO,YAAY,QAAQ,QAAQ;CAEzC,MAAM,OAAO,kBAAkB,QAAQ,aAAa,UAAU,iBAAiB,MAAM;CAErF,MAAM,OAAO,uBAAuB,QAAQ,mBAAmB,KAAA,CAAS;CAExE,MAAM,OAAO,MAAM,CAAC,CAAC,QAAQ,IAAI,KAAK;CAEtC,MAAM,QAAQ;EACZ,cAAc;EACd,SAAS,MAAM,QAAQ,OAAO,IAAI,QAAQ,KAAK,IAAI,IAAK,WAAW;EACnE,SAAS;CACX,CAAC;CAED,IAAI,uBACF,MAAM,OAAO,yBAAyB,qBAAqB;CAG7D,MAAM,QAAQ,EAAE,IAAI,IAAI,CAAC;AAC3B;AAEA,eAAsB,uBAAuB,SAA8C;CACzF,MAAM,EAAE,cAAc;CACtB,MAAM,MAAM,QAAQ,OAAA;CAGpB,IAAI,cAAc,OAChB,OAAO;CAGT,IAAI,QAAA,qBACF,OAAO;CAKT,MAAM,aAAa,MAAM,IAAIC,YAAAA,iBAAiB,OAAO,CAAC,CAAC,aAAa;CAEpE,IAAI,eAAe,KAAA,GACjB,OAAO;CAGT,OAAO,IAAI,IAAI,UAAU,CAAC,CAAC,aAAa;AAC1C;;;;AAKA,eAAsB,mBAAmB,cAAqC;CAC5E,IAAI;EACF,MAAM,aAAa,MAAM,GAAI;CAC/B,QAAQ,CAGR;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
|
|
2
|
-
let node_path = require("node:path");
|
|
3
2
|
let _sentry_core = require("@sentry/core");
|
|
3
|
+
let node_path = require("node:path");
|
|
4
4
|
let node_https = require("node:https");
|
|
5
5
|
node_https = require_runtime.__toESM(node_https);
|
|
6
6
|
let node_stream = require("node:stream");
|
|
@@ -1,13 +1,32 @@
|
|
|
1
|
+
let _sentry_core = require("@sentry/core");
|
|
1
2
|
// src/core/sourcemap-settings.ts
|
|
2
3
|
const NO_CHANGE = {
|
|
3
4
|
enableHidden: false,
|
|
4
5
|
deleteAfterUpload: false
|
|
5
6
|
};
|
|
7
|
+
const SOURCE_MAPS_OFF_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.";
|
|
8
|
+
const INLINE_SOURCE_MAPS_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.";
|
|
9
|
+
/**
|
|
10
|
+
* Reads `sourcemaps.upload` and `sourcemaps.injectDebugIds`. When neither is set,
|
|
11
|
+
* `sourcemaps.disable` decides.
|
|
12
|
+
*/
|
|
13
|
+
function getSourceMapFeatures(options) {
|
|
14
|
+
const { injectDebugIds, upload } = (0, _sentry_core.resolveSourceMapsFeatures)(options.sourcemaps);
|
|
15
|
+
return {
|
|
16
|
+
injectDebugIds,
|
|
17
|
+
upload,
|
|
18
|
+
stampEmittedFiles: injectDebugIds && !upload
|
|
19
|
+
};
|
|
20
|
+
}
|
|
6
21
|
/** Reads `sourcemaps.deleteSourcemapsAfterUpload`, calling the internal function form if given. */
|
|
7
22
|
function getDeleteSourcemapsAfterUpload(options, environment) {
|
|
8
23
|
const value = options.sourcemaps?.deleteSourcemapsAfterUpload;
|
|
9
24
|
return typeof value === "function" ? value(environment) : value;
|
|
10
25
|
}
|
|
26
|
+
/** Reads `sourcemaps.delete`. When it is unset, `sourcemaps.deleteSourcemapsAfterUpload` decides. */
|
|
27
|
+
function getDeleteOption(options, environment) {
|
|
28
|
+
return options.sourcemaps?.delete ?? getDeleteSourcemapsAfterUpload(options, environment);
|
|
29
|
+
}
|
|
11
30
|
/** Reads the internal `sourcemaps.sdkEnabledSourceMaps` option, calling its function form if given. */
|
|
12
31
|
function getSdkEnabledSourceMaps(options, environment) {
|
|
13
32
|
const value = options.sourcemaps?.sdkEnabledSourceMaps;
|
|
@@ -19,15 +38,17 @@ function getSdkEnabledSourceMaps(options, environment) {
|
|
|
19
38
|
* removes maps it turned on itself unless `deleteSourcemapsAfterUpload` says otherwise.
|
|
20
39
|
*/
|
|
21
40
|
function decideSourceMapHandling(kind, options, uploadPossible, environment) {
|
|
41
|
+
const features = getSourceMapFeatures(options);
|
|
42
|
+
if (options.sourcemaps?.delete !== void 0) return decideWithDeleteOption(kind, options.sourcemaps.delete, features, uploadPossible);
|
|
22
43
|
const deleteOption = getDeleteSourcemapsAfterUpload(options, environment);
|
|
23
44
|
const sdkEnabledSourceMaps = getSdkEnabledSourceMaps(options, environment);
|
|
24
|
-
if (!uploadPossible ||
|
|
45
|
+
if (!uploadPossible || !features.upload) {
|
|
25
46
|
if (deleteOption !== true || kind !== "hidden" && kind !== "visible") return NO_CHANGE;
|
|
26
|
-
if (
|
|
47
|
+
if (!features.upload && !sdkEnabledSourceMaps) return {
|
|
27
48
|
...NO_CHANGE,
|
|
28
49
|
log: {
|
|
29
50
|
level: "warn",
|
|
30
|
-
message:
|
|
51
|
+
message: `\`sourcemaps.deleteSourcemapsAfterUpload\` is set, but source map upload is disabled with ${(0, _sentry_core.resolveSourceMapsFeatures)(options.sourcemaps).legacyDisable ? "`sourcemaps.disable`" : "`sourcemaps.upload` or `sourcemaps.injectDebugIds`"}, so the source maps are not removed.`
|
|
31
52
|
}
|
|
32
53
|
};
|
|
33
54
|
return {
|
|
@@ -45,14 +66,14 @@ function decideSourceMapHandling(kind, options, uploadPossible, environment) {
|
|
|
45
66
|
...NO_CHANGE,
|
|
46
67
|
log: {
|
|
47
68
|
level: "warn",
|
|
48
|
-
message:
|
|
69
|
+
message: SOURCE_MAPS_OFF_MESSAGE
|
|
49
70
|
}
|
|
50
71
|
};
|
|
51
72
|
case "inline": return {
|
|
52
73
|
...NO_CHANGE,
|
|
53
74
|
log: {
|
|
54
75
|
level: "warn",
|
|
55
|
-
message:
|
|
76
|
+
message: INLINE_SOURCE_MAPS_MESSAGE
|
|
56
77
|
}
|
|
57
78
|
};
|
|
58
79
|
case "unset":
|
|
@@ -93,8 +114,67 @@ function decideSourceMapHandling(kind, options, uploadPossible, environment) {
|
|
|
93
114
|
};
|
|
94
115
|
}
|
|
95
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* The decision when `sourcemaps.delete` is set. Unlike `deleteSourcemapsAfterUpload`, it does not
|
|
119
|
+
* depend on an upload: `true` removes every source map of the build, and `false` keeps the hidden
|
|
120
|
+
* source maps the plugin turns on, also when nothing is uploaded.
|
|
121
|
+
*/
|
|
122
|
+
function decideWithDeleteOption(kind, deleteSourceMaps, features, uploadPossible) {
|
|
123
|
+
switch (kind) {
|
|
124
|
+
case "off": return uploadPossible ? {
|
|
125
|
+
...NO_CHANGE,
|
|
126
|
+
log: {
|
|
127
|
+
level: "warn",
|
|
128
|
+
message: SOURCE_MAPS_OFF_MESSAGE
|
|
129
|
+
}
|
|
130
|
+
} : NO_CHANGE;
|
|
131
|
+
case "inline": return uploadPossible ? {
|
|
132
|
+
...NO_CHANGE,
|
|
133
|
+
log: {
|
|
134
|
+
level: "warn",
|
|
135
|
+
message: INLINE_SOURCE_MAPS_MESSAGE
|
|
136
|
+
}
|
|
137
|
+
} : NO_CHANGE;
|
|
138
|
+
case "unset":
|
|
139
|
+
if (deleteSourceMaps) return uploadPossible ? {
|
|
140
|
+
enableHidden: true,
|
|
141
|
+
deleteAfterUpload: true,
|
|
142
|
+
removeAllSourceMaps: true,
|
|
143
|
+
log: {
|
|
144
|
+
level: "info",
|
|
145
|
+
message: "Enabling hidden source maps. They are uploaded to Sentry and removed from the build output."
|
|
146
|
+
}
|
|
147
|
+
} : NO_CHANGE;
|
|
148
|
+
if (!features.injectDebugIds) return NO_CHANGE;
|
|
149
|
+
return {
|
|
150
|
+
enableHidden: true,
|
|
151
|
+
deleteAfterUpload: false,
|
|
152
|
+
log: {
|
|
153
|
+
level: "info",
|
|
154
|
+
message: uploadPossible ? "Enabling hidden source maps. They are uploaded to Sentry and kept in the build output." : "Enabling hidden source maps. They are not uploaded to Sentry and are kept in the build output, because `sourcemaps.delete` is `false`."
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
case "hidden":
|
|
158
|
+
case "visible":
|
|
159
|
+
if (!deleteSourceMaps) return NO_CHANGE;
|
|
160
|
+
return {
|
|
161
|
+
enableHidden: kind === "visible",
|
|
162
|
+
deleteAfterUpload: true,
|
|
163
|
+
removeAllSourceMaps: true,
|
|
164
|
+
log: uploadPossible ? kind === "visible" ? {
|
|
165
|
+
level: "info",
|
|
166
|
+
message: "Switching to hidden source maps because `sourcemaps.delete` is set. Without the `sourceMappingURL` comment browsers do not request the removed map files."
|
|
167
|
+
} : void 0 : {
|
|
168
|
+
level: "warn",
|
|
169
|
+
message: "Source maps are not uploaded, but they are removed from the build output because `sourcemaps.delete` is set."
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}
|
|
96
174
|
exports.decideSourceMapHandling = decideSourceMapHandling;
|
|
175
|
+
exports.getDeleteOption = getDeleteOption;
|
|
97
176
|
exports.getDeleteSourcemapsAfterUpload = getDeleteSourcemapsAfterUpload;
|
|
98
177
|
exports.getSdkEnabledSourceMaps = getSdkEnabledSourceMaps;
|
|
178
|
+
exports.getSourceMapFeatures = getSourceMapFeatures;
|
|
99
179
|
|
|
100
180
|
//# sourceMappingURL=sourcemap-settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sourcemap-settings.js","names":[],"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 /**\n * With `deleteAfterUpload`, remove every source map of the build, also those of CSS and of chunks\n * the upload leaves out. Set when the plugin or the SDK turned the source maps on.\n */\n removeAllSourceMaps?: boolean;\n log?: { level: 'info' | 'warn'; message: string };\n};\n\nconst NO_CHANGE: SourceMapDecision = { enableHidden: false, deleteAfterUpload: false };\n\n/** Reads `sourcemaps.deleteSourcemapsAfterUpload`, calling the internal function form if given. */\nexport function getDeleteSourcemapsAfterUpload(options: NormalizedOptions, environment?: string): boolean | undefined {\n const value = options.sourcemaps?.deleteSourcemapsAfterUpload;\n return typeof value === 'function' ? value(environment) : value;\n}\n\n/** Reads the internal `sourcemaps.sdkEnabledSourceMaps` option, calling its function form if given. */\nexport function getSdkEnabledSourceMaps(options: NormalizedOptions, environment?: string): boolean {\n const value = options.sourcemaps?.sdkEnabledSourceMaps;\n return (typeof value === 'function' ? value(environment) : value) === true;\n}\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 environment?: string,\n): SourceMapDecision {\n const deleteOption = getDeleteSourcemapsAfterUpload(options, environment);\n const sdkEnabledSourceMaps = getSdkEnabledSourceMaps(options, environment);\n\n if (!uploadPossible || options.sourcemaps?.disable) {\n if (deleteOption !== true || (kind !== 'hidden' && kind !== 'visible')) {\n return NO_CHANGE;\n }\n // Users set `sourcemaps.disable` to upload the maps themselves. Maps the\n // SDK turned on are still removed, as the SDKs' own globs did.\n if (options.sourcemaps?.disable && !sdkEnabledSourceMaps) {\n return {\n ...NO_CHANGE,\n log: {\n level: 'warn',\n message:\n '`sourcemaps.deleteSourcemapsAfterUpload` is set, but source map upload is disabled with `sourcemaps.disable`, so the source maps are not removed.',\n },\n };\n }\n return {\n enableHidden: kind === 'visible',\n deleteAfterUpload: true,\n removeAllSourceMaps: sdkEnabledSourceMaps,\n log: {\n level: 'warn',\n message:\n 'Source maps are not uploaded, but they are removed from the build output because `sourcemaps.deleteSourcemapsAfterUpload` is set.',\n },\n };\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 removeAllSourceMaps: 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 if (deleteOption !== true) {\n return NO_CHANGE;\n }\n return { enableHidden: false, deleteAfterUpload: true, removeAllSourceMaps: sdkEnabledSourceMaps };\n\n case 'visible':\n if (deleteOption !== true) {\n return NO_CHANGE;\n }\n return {\n enableHidden: true,\n deleteAfterUpload: true,\n removeAllSourceMaps: sdkEnabledSourceMaps,\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"],"mappings":";AA0BA,MAAM,YAA+B;CAAE,cAAc;CAAO,mBAAmB;AAAM;;AAGrF,SAAgB,+BAA+B,SAA4B,aAA2C;CACpH,MAAM,QAAQ,QAAQ,YAAY;CAClC,OAAO,OAAO,UAAU,aAAa,MAAM,WAAW,IAAI;AAC5D;;AAGA,SAAgB,wBAAwB,SAA4B,aAA+B;CACjG,MAAM,QAAQ,QAAQ,YAAY;CAClC,QAAQ,OAAO,UAAU,aAAa,MAAM,WAAW,IAAI,WAAW;AACxE;;;;;;AAOA,SAAgB,wBACd,MACA,SACA,gBACA,aACmB;CACnB,MAAM,eAAe,+BAA+B,SAAS,WAAW;CACxE,MAAM,uBAAuB,wBAAwB,SAAS,WAAW;CAEzE,IAAI,CAAC,kBAAkB,QAAQ,YAAY,SAAS;EAClD,IAAI,iBAAiB,QAAS,SAAS,YAAY,SAAS,WAC1D,OAAO;EAIT,IAAI,QAAQ,YAAY,WAAW,CAAC,sBAClC,OAAO;GACL,GAAG;GACH,KAAK;IACH,OAAO;IACP,SACE;GACJ;EACF;EAEF,OAAO;GACL,cAAc,SAAS;GACvB,mBAAmB;GACnB,qBAAqB;GACrB,KAAK;IACH,OAAO;IACP,SACE;GACJ;EACF;CACF;CAEA,QAAQ,MAAR;EACE,KAAK,OACH,OAAO;GACL,GAAG;GACH,KAAK;IACH,OAAO;IACP,SACE;GAEJ;EACF;EAEF,KAAK,UACH,OAAO;GACL,GAAG;GACH,KAAK;IACH,OAAO;IACP,SACE;GAEJ;EACF;EAEF,KAAK;GACH,IAAI,iBAAiB,OACnB,OAAO;IACL,cAAc;IACd,mBAAmB;IACnB,KAAK;KACH,OAAO;KACP,SAAS;IACX;GACF;GAEF,OAAO;IACL,cAAc;IACd,mBAAmB;IACnB,qBAAqB;IACrB,KAAK;KACH,OAAO;KACP,SACE;IAEJ;GACF;EAEF,KAAK;GACH,IAAI,iBAAiB,MACnB,OAAO;GAET,OAAO;IAAE,cAAc;IAAO,mBAAmB;IAAM,qBAAqB;GAAqB;EAEnG,KAAK;GACH,IAAI,iBAAiB,MACnB,OAAO;GAET,OAAO;IACL,cAAc;IACd,mBAAmB;IACnB,qBAAqB;IACrB,KAAK;KACH,OAAO;KACP,SACE;IAEJ;GACF;CACJ;AACF"}
|
|
1
|
+
{"version":3,"file":"sourcemap-settings.js","names":["resolveSourceMapsFeatures"],"sources":["../../../src/core/sourcemap-settings.ts"],"sourcesContent":["import { resolveSourceMapsFeatures } from '@sentry/core';\nimport 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 /**\n * With `deleteAfterUpload`, remove every source map of the build, also those of CSS and of chunks\n * the upload leaves out. Set when the plugin or the SDK turned the source maps on.\n */\n removeAllSourceMaps?: boolean;\n log?: { level: 'info' | 'warn'; message: string };\n};\n\nconst NO_CHANGE: SourceMapDecision = { enableHidden: false, deleteAfterUpload: false };\n\nconst SOURCE_MAPS_OFF_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\nconst INLINE_SOURCE_MAPS_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\nexport type SourceMapFeatures = {\n /** The plugin adds debug IDs to the bundles and their source maps. */\n injectDebugIds: boolean;\n /** The plugin uploads the source maps. Never `true` without `injectDebugIds`. */\n upload: boolean;\n /**\n * The plugin writes the debug IDs into the emitted files and source maps. The upload only stamps\n * temp copies, so without an upload the emitted files get them and a later manual upload needs\n * no inject step.\n */\n stampEmittedFiles: boolean;\n};\n\n/**\n * Reads `sourcemaps.upload` and `sourcemaps.injectDebugIds`. When neither is set,\n * `sourcemaps.disable` decides.\n */\nexport function getSourceMapFeatures(options: NormalizedOptions): SourceMapFeatures {\n const { injectDebugIds, upload } = resolveSourceMapsFeatures(options.sourcemaps);\n\n return { injectDebugIds, upload, stampEmittedFiles: injectDebugIds && !upload };\n}\n\n/** Reads `sourcemaps.deleteSourcemapsAfterUpload`, calling the internal function form if given. */\nexport function getDeleteSourcemapsAfterUpload(options: NormalizedOptions, environment?: string): boolean | undefined {\n const value = options.sourcemaps?.deleteSourcemapsAfterUpload;\n return typeof value === 'function' ? value(environment) : value;\n}\n\n/** Reads `sourcemaps.delete`. When it is unset, `sourcemaps.deleteSourcemapsAfterUpload` decides. */\nexport function getDeleteOption(options: NormalizedOptions, environment?: string): boolean | undefined {\n return options.sourcemaps?.delete ?? getDeleteSourcemapsAfterUpload(options, environment);\n}\n\n/** Reads the internal `sourcemaps.sdkEnabledSourceMaps` option, calling its function form if given. */\nexport function getSdkEnabledSourceMaps(options: NormalizedOptions, environment?: string): boolean {\n const value = options.sourcemaps?.sdkEnabledSourceMaps;\n return (typeof value === 'function' ? value(environment) : value) === true;\n}\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 environment?: string,\n): SourceMapDecision {\n const features = getSourceMapFeatures(options);\n\n if (options.sourcemaps?.delete !== undefined) {\n return decideWithDeleteOption(kind, options.sourcemaps.delete, features, uploadPossible);\n }\n\n const deleteOption = getDeleteSourcemapsAfterUpload(options, environment);\n const sdkEnabledSourceMaps = getSdkEnabledSourceMaps(options, environment);\n\n if (!uploadPossible || !features.upload) {\n if (deleteOption !== true || (kind !== 'hidden' && kind !== 'visible')) {\n return NO_CHANGE;\n }\n // Users switch the upload off to upload the maps themselves. Maps the\n // SDK turned on are still removed, as the SDKs' own globs did.\n if (!features.upload && !sdkEnabledSourceMaps) {\n return {\n ...NO_CHANGE,\n log: {\n level: 'warn',\n message: `\\`sourcemaps.deleteSourcemapsAfterUpload\\` is set, but source map upload is disabled with ${\n resolveSourceMapsFeatures(options.sourcemaps).legacyDisable\n ? '`sourcemaps.disable`'\n : '`sourcemaps.upload` or `sourcemaps.injectDebugIds`'\n }, so the source maps are not removed.`,\n },\n };\n }\n return {\n enableHidden: kind === 'visible',\n deleteAfterUpload: true,\n removeAllSourceMaps: sdkEnabledSourceMaps,\n log: {\n level: 'warn',\n message:\n 'Source maps are not uploaded, but they are removed from the build output because `sourcemaps.deleteSourcemapsAfterUpload` is set.',\n },\n };\n }\n\n switch (kind) {\n case 'off':\n return {\n ...NO_CHANGE,\n log: {\n level: 'warn',\n message: SOURCE_MAPS_OFF_MESSAGE,\n },\n };\n\n case 'inline':\n return {\n ...NO_CHANGE,\n log: {\n level: 'warn',\n message: INLINE_SOURCE_MAPS_MESSAGE,\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 removeAllSourceMaps: 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 if (deleteOption !== true) {\n return NO_CHANGE;\n }\n return { enableHidden: false, deleteAfterUpload: true, removeAllSourceMaps: sdkEnabledSourceMaps };\n\n case 'visible':\n if (deleteOption !== true) {\n return NO_CHANGE;\n }\n return {\n enableHidden: true,\n deleteAfterUpload: true,\n removeAllSourceMaps: sdkEnabledSourceMaps,\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\n/**\n * The decision when `sourcemaps.delete` is set. Unlike `deleteSourcemapsAfterUpload`, it does not\n * depend on an upload: `true` removes every source map of the build, and `false` keeps the hidden\n * source maps the plugin turns on, also when nothing is uploaded.\n */\nfunction decideWithDeleteOption(\n kind: SourceMapKind,\n deleteSourceMaps: boolean,\n features: SourceMapFeatures,\n uploadPossible: boolean,\n): SourceMapDecision {\n switch (kind) {\n case 'off':\n return uploadPossible ? { ...NO_CHANGE, log: { level: 'warn', message: SOURCE_MAPS_OFF_MESSAGE } } : NO_CHANGE;\n\n case 'inline':\n return uploadPossible ? { ...NO_CHANGE, log: { level: 'warn', message: INLINE_SOURCE_MAPS_MESSAGE } } : NO_CHANGE;\n\n case 'unset':\n if (deleteSourceMaps) {\n // Maps that are only turned on to be removed again are not turned on.\n return uploadPossible\n ? {\n enableHidden: true,\n deleteAfterUpload: true,\n removeAllSourceMaps: true,\n log: {\n level: 'info',\n message: 'Enabling hidden source maps. They are uploaded to Sentry and removed from the build output.',\n },\n }\n : NO_CHANGE;\n }\n // Without debug IDs the maps are of no use to Sentry.\n if (!features.injectDebugIds) {\n return NO_CHANGE;\n }\n return {\n enableHidden: true,\n deleteAfterUpload: false,\n log: {\n level: 'info',\n message: uploadPossible\n ? 'Enabling hidden source maps. They are uploaded to Sentry and kept in the build output.'\n : 'Enabling hidden source maps. They are not uploaded to Sentry and are kept in the build output, because `sourcemaps.delete` is `false`.',\n },\n };\n\n case 'hidden':\n case 'visible':\n if (!deleteSourceMaps) {\n return NO_CHANGE;\n }\n return {\n enableHidden: kind === 'visible',\n deleteAfterUpload: true,\n removeAllSourceMaps: true,\n log: uploadPossible\n ? kind === 'visible'\n ? {\n level: 'info',\n message:\n 'Switching to hidden source maps because `sourcemaps.delete` is set. ' +\n 'Without the `sourceMappingURL` comment browsers do not request the removed map files.',\n }\n : undefined\n : {\n level: 'warn',\n message:\n 'Source maps are not uploaded, but they are removed from the build output because `sourcemaps.delete` is set.',\n },\n };\n }\n}\n"],"mappings":";;AA2BA,MAAM,YAA+B;CAAE,cAAc;CAAO,mBAAmB;AAAM;AAErF,MAAM,0BACJ;AAGF,MAAM,6BACJ;;;;;AAoBF,SAAgB,qBAAqB,SAA+C;CAClF,MAAM,EAAE,gBAAgB,YAAA,GAAWA,aAAAA,0BAAAA,CAA0B,QAAQ,UAAU;CAE/E,OAAO;EAAE;EAAgB;EAAQ,mBAAmB,kBAAkB,CAAC;CAAO;AAChF;;AAGA,SAAgB,+BAA+B,SAA4B,aAA2C;CACpH,MAAM,QAAQ,QAAQ,YAAY;CAClC,OAAO,OAAO,UAAU,aAAa,MAAM,WAAW,IAAI;AAC5D;;AAGA,SAAgB,gBAAgB,SAA4B,aAA2C;CACrG,OAAO,QAAQ,YAAY,UAAU,+BAA+B,SAAS,WAAW;AAC1F;;AAGA,SAAgB,wBAAwB,SAA4B,aAA+B;CACjG,MAAM,QAAQ,QAAQ,YAAY;CAClC,QAAQ,OAAO,UAAU,aAAa,MAAM,WAAW,IAAI,WAAW;AACxE;;;;;;AAOA,SAAgB,wBACd,MACA,SACA,gBACA,aACmB;CACnB,MAAM,WAAW,qBAAqB,OAAO;CAE7C,IAAI,QAAQ,YAAY,WAAW,KAAA,GACjC,OAAO,uBAAuB,MAAM,QAAQ,WAAW,QAAQ,UAAU,cAAc;CAGzF,MAAM,eAAe,+BAA+B,SAAS,WAAW;CACxE,MAAM,uBAAuB,wBAAwB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GAAE,GAAG;GAAW,KAAK;IAAE,OAAO;IAAQ,SAAS;GAA2B;EAAE,IAAI;EAE1G,KAAK;GACH,IAAI,kBAEF,OAAO,iBACH;IACE,cAAc;IACd,mBAAmB;IACnB,qBAAqB;IACrB,KAAK;KACH,OAAO;KACP,SAAS;IACX;GACF,IACA;GAGN,IAAI,CAAC,SAAS,gBACZ,OAAO;GAET,OAAO;IACL,cAAc;IACd,mBAAmB;IACnB,KAAK;KACH,OAAO;KACP,SAAS,iBACL,2FACA;IACN;GACF;EAEF,KAAK;EACL,KAAK;GACH,IAAI,CAAC,kBACH,OAAO;GAET,OAAO;IACL,cAAc,SAAS;IACvB,mBAAmB;IACnB,qBAAqB;IACrB,KAAK,iBACD,SAAS,YACP;KACE,OAAO;KACP,SACE;IAEJ,IACA,KAAA,IACF;KACE,OAAO;KACP,SACE;IACJ;GACN;CACJ;AACF"}
|
package/build/cjs/core/utils.js
CHANGED
|
@@ -12,6 +12,7 @@ child_process = require_runtime.__toESM(child_process);
|
|
|
12
12
|
let magic_string = require("magic-string");
|
|
13
13
|
magic_string = require_runtime.__toESM(magic_string);
|
|
14
14
|
let _sentry_core_server = require("@sentry/core/server");
|
|
15
|
+
let _sentry_core = require("@sentry/core");
|
|
15
16
|
// src/core/utils.ts
|
|
16
17
|
/**
|
|
17
18
|
* Checks whether the given input is already an array, and if it isn't, wraps it in one.
|
|
@@ -158,6 +159,15 @@ function canAutoDetectRepository() {
|
|
|
158
159
|
function determineReleaseName() {
|
|
159
160
|
return (0, _sentry_core_server._INTERNAL_getReleaseFromCommitEnv)(warnAboutPlaceholderCommitEnvVar) || gitRevision();
|
|
160
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Resolves the release name the way the bundler plugins do: the configured name, then the `SENTRY_RELEASE`
|
|
164
|
+
* environment variable, then a name detected from CI environment variables or git.
|
|
165
|
+
*
|
|
166
|
+
* Framework SDKs that pass the release to the SDK at runtime use this to get the same name the plugin uses.
|
|
167
|
+
*/
|
|
168
|
+
function resolveReleaseName(name) {
|
|
169
|
+
return name ?? process.env["SENTRY_RELEASE"] ?? determineReleaseName();
|
|
170
|
+
}
|
|
161
171
|
const warnedPlaceholderEnvVars = /* @__PURE__ */ new Set();
|
|
162
172
|
function warnAboutPlaceholderCommitEnvVar(name) {
|
|
163
173
|
if (warnedPlaceholderEnvVars.has(name)) return;
|
|
@@ -171,23 +181,20 @@ function warnAboutPlaceholderCommitEnvVar(name) {
|
|
|
171
181
|
function readCommitEnvVar(name) {
|
|
172
182
|
return (0, _sentry_core_server._INTERNAL_readCommitEnvVar)(name, warnAboutPlaceholderCommitEnvVar);
|
|
173
183
|
}
|
|
174
|
-
function stringifyForCodeInjection(value) {
|
|
175
|
-
return JSON.stringify(value)?.replace(/</g, "\\u003c");
|
|
176
|
-
}
|
|
177
184
|
/**
|
|
178
185
|
* Generates code for the global injector which is responsible for setting the global
|
|
179
186
|
* `SENTRY_RELEASE` & `SENTRY_BUILD_INFO` variables.
|
|
180
187
|
*/
|
|
181
188
|
function generateReleaseInjectorCode({ release, injectBuildInformation }) {
|
|
182
|
-
let code = `e.SENTRY_RELEASE={id:${stringifyForCodeInjection(release)}};`;
|
|
189
|
+
let code = `e.SENTRY_RELEASE={id:${(0, _sentry_core.stringifyForCodeInjection)(release)}};`;
|
|
183
190
|
if (injectBuildInformation) {
|
|
184
191
|
const buildInfo = getBuildInformation();
|
|
185
|
-
code += `e.SENTRY_BUILD_INFO=${stringifyForCodeInjection(buildInfo)};`;
|
|
192
|
+
code += `e.SENTRY_BUILD_INFO=${(0, _sentry_core.stringifyForCodeInjection)(buildInfo)};`;
|
|
186
193
|
}
|
|
187
194
|
return new CodeInjection(code);
|
|
188
195
|
}
|
|
189
196
|
function generateModuleMetadataInjectorCode(metadata) {
|
|
190
|
-
return new CodeInjection(`e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])}return e}({},e._sentryModuleMetadata[(new e.Error).stack],${stringifyForCodeInjection(metadata)});`);
|
|
197
|
+
return new CodeInjection(`e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])}return e}({},e._sentryModuleMetadata[(new e.Error).stack],${(0, _sentry_core.stringifyForCodeInjection)(metadata)});`);
|
|
191
198
|
}
|
|
192
199
|
function getBuildInformation() {
|
|
193
200
|
const packageJson = getPackageJson();
|
|
@@ -279,6 +286,7 @@ exports.getTurborepoEnvPassthroughWarning = getTurborepoEnvPassthroughWarning;
|
|
|
279
286
|
exports.parseMajorVersion = parseMajorVersion;
|
|
280
287
|
exports.readCommitEnvVar = readCommitEnvVar;
|
|
281
288
|
exports.replaceBooleanFlagsInCode = replaceBooleanFlagsInCode;
|
|
289
|
+
exports.resolveReleaseName = resolveReleaseName;
|
|
282
290
|
exports.stringToUUID = stringToUUID;
|
|
283
291
|
exports.stripQueryAndHashFromPath = stripQueryAndHashFromPath;
|
|
284
292
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["path","os","fs","crypto","childProcess","getReleaseFromCommitEnv","readCoreCommitEnvVar","MagicString"],"sources":["../../../src/core/utils.ts"],"sourcesContent":["/* oxlint-disable max-lines */\nimport path from 'path';\nimport fs from 'fs';\nimport os from 'os';\nimport crypto from 'crypto';\nimport childProcess from 'child_process';\nimport type { SourceMap } from 'magic-string';\nimport MagicString from 'magic-string';\nimport {\n _INTERNAL_getReleaseFromCommitEnv as getReleaseFromCommitEnv,\n _INTERNAL_readCommitEnvVar as readCoreCommitEnvVar,\n} from '@sentry/core/server';\n\n/**\n * Checks whether the given input is already an array, and if it isn't, wraps it in one.\n *\n * @param maybeArray Input to turn into an array, if necessary\n * @returns The input, if already an array, or an array with the input as the only element, if not\n */\nexport function arrayify<T = unknown>(maybeArray: T | T[]): T[] {\n return Array.isArray(maybeArray) ? maybeArray : [maybeArray];\n}\n\ntype PackageJson = Record<string, unknown>;\n\n/**\n * Get the closes package.json from a given starting point upwards.\n * This handles a few edge cases:\n * * Check if a given file package.json appears to be an actual NPM package.json file\n * * Stop at the home dir, to avoid looking too deeply\n */\nexport function getPackageJson({ cwd, stopAt }: { cwd?: string; stopAt?: string } = {}): PackageJson | undefined {\n return lookupPackageJson(cwd ?? process.cwd(), path.normalize(stopAt ?? os.homedir()));\n}\n\nexport function parseMajorVersion(ver: string): number | undefined {\n let version = ver;\n // if it has a `v` prefix, remove it\n if (version.startsWith('v')) {\n version = version.slice(1);\n }\n\n // First, try simple lookup of exact, ~ and ^ versions\n const regex = /^[\\^~]?(\\d+)(\\.\\d+)?(\\.\\d+)?(-.+)?/;\n\n const match = version.match(regex);\n if (match) {\n return parseInt(match[1] as string, 10);\n }\n\n // Try to parse e.g. 1.x\n const coerced = parseInt(version, 10);\n if (!Number.isNaN(coerced)) {\n return coerced;\n }\n\n // Match <= and >= ranges.\n const gteLteRegex = /^[<>]=\\s*(\\d+)(\\.\\d+)?(\\.\\d+)?(-.+)?/;\n const gteLteMatch = version.match(gteLteRegex);\n if (gteLteMatch) {\n return parseInt(gteLteMatch[1] as string, 10);\n }\n\n // match < ranges\n const ltRegex = /^<\\s*(\\d+)(\\.\\d+)?(\\.\\d+)?(-.+)?/;\n const ltMatch = version.match(ltRegex);\n if (ltMatch) {\n // Two scenarios:\n // a) < 2.0.0 --> return 1\n // b) < 2.1.0 --> return 2\n\n const major = parseInt(ltMatch[1] as string, 10);\n\n if (\n // minor version > 0\n (typeof ltMatch[2] === 'string' && parseInt(ltMatch[2].slice(1), 10) > 0) ||\n // patch version > 0\n (typeof ltMatch[3] === 'string' && parseInt(ltMatch[3].slice(1), 10) > 0)\n ) {\n return major;\n }\n\n return major - 1;\n }\n\n // match > ranges\n const gtRegex = /^>\\s*(\\d+)(\\.\\d+)?(\\.\\d+)?(-.+)?/;\n const gtMatch = version.match(gtRegex);\n if (gtMatch) {\n // We always return the version here, even though it _may_ be incorrect\n // E.g. if given > 2.0.0, it should be 2 if there exists any 2.x.x version, else 3\n // Since there is no way for us to know this, we're going to assume any kind of patch/feature release probably exists\n return parseInt(gtMatch[1] as string, 10);\n }\n return undefined;\n}\n\n// This is an explicit list of packages where we want to include the (major) version number.\nconst PACKAGES_TO_INCLUDE_VERSION = [\n 'react',\n '@angular/core',\n 'vue',\n 'ember-source',\n 'svelte',\n '@sveltejs/kit',\n 'webpack',\n 'vite',\n 'gatsby',\n 'next',\n 'remix',\n 'rollup',\n 'esbuild',\n];\n\nexport function getDependencies(packageJson: PackageJson): {\n deps: string[];\n depsVersions: Record<string, number>;\n} {\n const dependencies: Record<string, string> = Object.assign(\n {},\n packageJson['devDependencies'] ?? {},\n packageJson['dependencies'] ?? {},\n );\n\n const deps = Object.keys(dependencies).sort();\n\n const depsVersions: Record<string, number> = deps.reduce(\n (depsVersions, depName) => {\n if (PACKAGES_TO_INCLUDE_VERSION.includes(depName)) {\n const version = dependencies[depName] as string;\n const majorVersion = parseMajorVersion(version);\n if (majorVersion) {\n depsVersions[depName] = majorVersion;\n }\n }\n return depsVersions;\n },\n {} as Record<string, number>,\n );\n\n return { deps, depsVersions };\n}\n\nfunction findPackageJson(cwd: string, stopAt: string): string | undefined {\n let dirName = path.resolve(cwd);\n\n for (;;) {\n // Stop if we reach this dir\n if (path.normalize(dirName) === stopAt) {\n return undefined;\n }\n\n const jsonPath = path.join(dirName, 'package.json');\n if (fs.existsSync(jsonPath)) {\n return jsonPath;\n }\n\n const parentDirName = path.dirname(dirName);\n // We reached the file system root\n if (parentDirName === dirName) {\n return undefined;\n }\n\n dirName = parentDirName;\n }\n}\n\nfunction lookupPackageJson(cwd: string, stopAt: string): PackageJson | undefined {\n const jsonPath = findPackageJson(cwd, stopAt);\n\n if (!jsonPath) {\n return undefined;\n }\n\n try {\n const jsonStr = fs.readFileSync(jsonPath, 'utf8');\n const json = JSON.parse(jsonStr) as PackageJson;\n\n // Ensure it is an actual package.json\n // This is very much not bulletproof, but should be good enough\n if ('name' in json || 'private' in json) {\n return json;\n }\n } catch {\n // Ignore and walk up\n }\n\n // Continue up the tree, if we find a fitting package.json\n const newCwd = path.dirname(path.resolve(`${jsonPath}/..`));\n return lookupPackageJson(newCwd, stopAt);\n}\n\n/**\n * Deterministically hashes a string and turns the hash into a uuid.\n */\nexport function stringToUUID(str: string): string {\n const sha256Hash = crypto.createHash('sha256').update(str).digest('hex');\n\n // Position 16 is fixed to either 8, 9, a, or b in the uuid v4 spec (10xx in binary)\n // RFC 4122 section 4.4\n const v4variant = ['8', '9', 'a', 'b'][sha256Hash.substring(16, 17).charCodeAt(0) % 4] as string;\n\n return `${sha256Hash.substring(0, 8)}-${sha256Hash.substring(8, 12)}-4${sha256Hash.substring(13, 16)}-${v4variant}${sha256Hash.substring(17, 20)}-${sha256Hash.substring(20, 32)}`.toLowerCase();\n}\n\nfunction gitRevision(): string | undefined {\n let gitRevision: string | undefined;\n try {\n gitRevision = childProcess\n .execSync('git rev-parse HEAD', { stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true })\n .toString()\n .trim();\n } catch {\n // noop\n }\n return gitRevision;\n}\n\n// Mirrors the CLI's `set-commits --auto` fallback for builds without an `origin` remote. Vercel is left out\n// because the CLI only reads `VERCEL_GIT_*` on production builds.\nconst CI_REPOSITORY_ENV_VARS = [\n 'GITHUB_REPOSITORY',\n 'CI_PROJECT_PATH',\n 'BITBUCKET_REPO_FULL_NAME',\n 'RENDER_GIT_REPO_SLUG',\n 'RAILWAY_GIT_REPO_NAME',\n 'CIRCLE_PROJECT_REPONAME',\n 'BUILDKITE_REPO',\n 'BUILD_REPOSITORY_URI',\n] as const;\n\n/**\n * Whether `set-commits --auto` can find the repository: from the `origin` git remote, or from CI variables.\n */\nexport function canAutoDetectRepository(): boolean {\n if (\n CI_REPOSITORY_ENV_VARS.some(name => process.env[name]) ||\n (process.env['NETLIFY'] && process.env['REPOSITORY_URL'])\n ) {\n return true;\n }\n try {\n childProcess.execSync('git remote get-url origin', { stdio: 'ignore', windowsHide: true });\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Tries to guess a release name based on environmental data.\n */\nexport function determineReleaseName(): string | undefined {\n return getReleaseFromCommitEnv(warnAboutPlaceholderCommitEnvVar) || gitRevision();\n}\n\n// Release detection and commit association can read the same variable in one build.\nconst warnedPlaceholderEnvVars = new Set<string>();\n\nfunction warnAboutPlaceholderCommitEnvVar(name: string): void {\n if (warnedPlaceholderEnvVars.has(name)) {\n return;\n }\n warnedPlaceholderEnvVars.add(name);\n // This runs before the plugin logger exists, so `silent: true` does not suppress it. That is\n // deliberate: a warning that is easy to miss is how this misconfiguration went unnoticed.\n // eslint-disable-next-line no-console\n console.warn(\n `[@sentry/bundler-plugins] Ignoring the ${name} environment variable as a release name, because its value is its own name. Set the release explicitly, or fix the variable in your build environment.`,\n );\n}\n\n/**\n * Reads an environment variable that should hold a commit SHA, ignoring a value that is the\n * variable's own name. See `_INTERNAL_readCommitEnvVar` in `@sentry/core/server`.\n */\nexport function readCommitEnvVar(name: string): string | undefined {\n return readCoreCommitEnvVar(name, warnAboutPlaceholderCommitEnvVar);\n}\n\nfunction stringifyForCodeInjection(value: unknown): string | undefined {\n // Bundles may be inlined in HTML, where JSON quoting does not escape script tags or HTML comments.\n return JSON.stringify(value)?.replace(/</g, '\\\\u003c');\n}\n\n/**\n * Generates code for the global injector which is responsible for setting the global\n * `SENTRY_RELEASE` & `SENTRY_BUILD_INFO` variables.\n */\nexport function generateReleaseInjectorCode({\n release,\n injectBuildInformation,\n}: {\n release: string;\n injectBuildInformation: boolean;\n}): CodeInjection {\n let code = `e.SENTRY_RELEASE={id:${stringifyForCodeInjection(release)}};`;\n\n if (injectBuildInformation) {\n const buildInfo = getBuildInformation();\n\n code += `e.SENTRY_BUILD_INFO=${stringifyForCodeInjection(buildInfo)};`;\n }\n\n return new CodeInjection(code);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function generateModuleMetadataInjectorCode(metadata: any): CodeInjection {\n // We are merging the metadata objects in case modules are bundled twice with the plugin\n // Use try-catch to avoid issues when bundlers rename global variables like 'window' to 'k'\n return new CodeInjection(\n `e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])}return e}({},e._sentryModuleMetadata[(new e.Error).stack],${stringifyForCodeInjection(\n metadata,\n )});`,\n );\n}\n\nexport function getBuildInformation(): {\n deps: string[];\n depsVersions: Record<string, number>;\n nodeVersion: number | undefined;\n} {\n const packageJson = getPackageJson();\n\n const { deps, depsVersions } = packageJson ? getDependencies(packageJson) : { deps: [], depsVersions: {} };\n\n return {\n deps,\n depsVersions,\n nodeVersion: parseMajorVersion(process.version),\n };\n}\n\nexport function stripQueryAndHashFromPath(path: string): string {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return path.split('?')[0]!.split('#')[0]!;\n}\n\nexport function replaceBooleanFlagsInCode(\n code: string,\n replacementValues: Record<string, boolean | undefined>,\n): { code: string; map: SourceMap } | null {\n const ms = new MagicString(code);\n\n Object.keys(replacementValues).forEach(key => {\n const value = replacementValues[key];\n\n if (typeof value === 'boolean') {\n ms.replaceAll(key, JSON.stringify(value));\n }\n });\n\n if (ms.hasChanged()) {\n return {\n code: ms.toString(),\n map: ms.generateMap({ hires: 'boundary' }),\n };\n }\n\n return null;\n}\n\n// https://turbo.build/repo/docs/reference/system-environment-variables#environment-variables-in-tasks\nexport function getTurborepoEnvPassthroughWarning(envVarName: string): string {\n return process.env['TURBO_HASH']\n ? `\\nYou seem to be using Turborepo, did you forget to put ${envVarName} in \\`passThroughEnv\\`? https://turbo.build/repo/docs/reference/configuration#passthroughenv`\n : '';\n}\n\n/**\n * Gets the projects from the project option. This might be a single project or an array of projects.\n */\nexport function getProjects(project: string | string[] | undefined): string[] | undefined {\n if (Array.isArray(project)) {\n return project;\n }\n\n if (project) {\n return [project];\n }\n\n return undefined;\n}\n\n/**\n * Checks if a chunk contains only import/export statements and no substantial code.\n *\n * In Vite MPA (multi-page application) mode, HTML entry points create \"facade\" chunks\n * that only contain import statements to load shared modules. These should not have\n * Sentry code injected. However, in SPA mode, the main bundle also has an HTML facade\n * but contains substantial application code that SHOULD have debug IDs injected.\n *\n * @ref https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/829\n * @ref https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/839\n */\nexport function containsOnlyImports(code: string): boolean {\n const codeWithoutImports = code\n // Remove side effect imports: import '/path'; or import \"./path\";\n // Using explicit negated character classes to avoid polynomial backtracking\n .replace(/^\\s*import\\s+(?:'[^'\\n]*'|\"[^\"\\n]*\"|`[^`\\n]*`)[\\s;]*$/gm, '')\n // Remove named/default imports: import x from '/path'; import { x } from '/path';\n .replace(/^\\s*import\\b[^'\"`\\n]*\\bfrom\\s+(?:'[^'\\n]*'|\"[^\"\\n]*\"|`[^`\\n]*`)[\\s;]*$/gm, '')\n // Remove re-exports: export * from '/path'; export { x } from '/path';\n .replace(/^\\s*export\\b[^'\"`\\n]*\\bfrom\\s+(?:'[^'\\n]*'|\"[^\"\\n]*\"|`[^`\\n]*`)[\\s;]*$/gm, '')\n // Remove block comments\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n // Remove line comments\n .replace(/\\/\\/.*$/gm, '')\n // Remove \"use strict\" directives\n .replace(/[\"']use strict[\"']\\s*;?/g, '')\n .trim();\n\n return codeWithoutImports.length === 0;\n}\n\nexport class CodeInjection {\n // The code below is mostly ternary operators because it saves bundle size.\n // The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)\n private readonly header: string;\n private readonly footer: string;\n\n constructor(private body: string = '') {\n // `globalThis` is checked first so the other identifiers are never evaluated\n // where it exists. A downstream bundler that runs over an already-injected\n // chunk can turn a free `global` into a `const` it declares further down the\n // file (Nitro's node compat does this). Reading that binding from the top of\n // the file hits the temporal dead zone, and `typeof` throws there instead of\n // returning \"undefined\", so the whole injection was silently swallowed by the\n // `catch` below and the chunk registered no debug ID.\n this.header = `!function(){try{var e=\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof self?self:{};`;\n this.footer = '}catch(e){}}();';\n }\n\n public code(): string {\n if (this.isEmpty()) {\n return '';\n }\n\n return this.header + this.body + this.footer;\n }\n\n public isEmpty(): boolean {\n return this.body.length === 0;\n }\n\n public append(code: CodeInjection | string): void {\n if (code instanceof CodeInjection) {\n this.body += code.body;\n } else {\n this.body += code;\n }\n }\n\n public clear(): void {\n this.body = '';\n }\n\n public clone(): CodeInjection {\n return new CodeInjection(this.body);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,SAAsB,YAA0B;CAC9D,OAAO,MAAM,QAAQ,UAAU,IAAI,aAAa,CAAC,UAAU;AAC7D;;;;;;;AAUA,SAAgB,eAAe,EAAE,KAAK,WAA8C,CAAC,GAA4B;CAC/G,OAAO,kBAAkB,OAAO,QAAQ,IAAI,GAAGA,KAAAA,QAAK,UAAU,UAAUC,GAAAA,QAAG,QAAQ,CAAC,CAAC;AACvF;AAEA,SAAgB,kBAAkB,KAAiC;CACjE,IAAI,UAAU;CAEd,IAAI,QAAQ,WAAW,GAAG,GACxB,UAAU,QAAQ,MAAM,CAAC;CAM3B,MAAM,QAAQ,QAAQ,MAAM,oCAAK;CACjC,IAAI,OACF,OAAO,SAAS,MAAM,IAAc,EAAE;CAIxC,MAAM,UAAU,SAAS,SAAS,EAAE;CACpC,IAAI,CAAC,OAAO,MAAM,OAAO,GACvB,OAAO;CAKT,MAAM,cAAc,QAAQ,MAAM,sCAAW;CAC7C,IAAI,aACF,OAAO,SAAS,YAAY,IAAc,EAAE;CAK9C,M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KAAK,QAAQ;CAEjB;CAEO,QAAc;EACnB,KAAK,OAAO;CACd;CAEO,QAAuB;EAC5B,OAAO,IAAI,cAAc,KAAK,IAAI;CACpC;AACF"}
|
|
1
|
+
{"version":3,"file":"utils.js","names":["path","os","fs","crypto","childProcess","getReleaseFromCommitEnv","readCoreCommitEnvVar","stringifyForCodeInjection","MagicString"],"sources":["../../../src/core/utils.ts"],"sourcesContent":["/* oxlint-disable max-lines */\nimport path from 'path';\nimport fs from 'fs';\nimport os from 'os';\nimport crypto from 'crypto';\nimport childProcess from 'child_process';\nimport type { SourceMap } from 'magic-string';\nimport MagicString from 'magic-string';\nimport {\n _INTERNAL_getReleaseFromCommitEnv as getReleaseFromCommitEnv,\n _INTERNAL_readCommitEnvVar as readCoreCommitEnvVar,\n} from '@sentry/core/server';\nimport { stringifyForCodeInjection } from '@sentry/core';\n\n/**\n * Checks whether the given input is already an array, and if it isn't, wraps it in one.\n *\n * @param maybeArray Input to turn into an array, if necessary\n * @returns The input, if already an array, or an array with the input as the only element, if not\n */\nexport function arrayify<T = unknown>(maybeArray: T | T[]): T[] {\n return Array.isArray(maybeArray) ? maybeArray : [maybeArray];\n}\n\ntype PackageJson = Record<string, unknown>;\n\n/**\n * Get the closes package.json from a given starting point upwards.\n * This handles a few edge cases:\n * * Check if a given file package.json appears to be an actual NPM package.json file\n * * Stop at the home dir, to avoid looking too deeply\n */\nexport function getPackageJson({ cwd, stopAt }: { cwd?: string; stopAt?: string } = {}): PackageJson | undefined {\n return lookupPackageJson(cwd ?? process.cwd(), path.normalize(stopAt ?? os.homedir()));\n}\n\nexport function parseMajorVersion(ver: string): number | undefined {\n let version = ver;\n // if it has a `v` prefix, remove it\n if (version.startsWith('v')) {\n version = version.slice(1);\n }\n\n // First, try simple lookup of exact, ~ and ^ versions\n const regex = /^[\\^~]?(\\d+)(\\.\\d+)?(\\.\\d+)?(-.+)?/;\n\n const match = version.match(regex);\n if (match) {\n return parseInt(match[1] as string, 10);\n }\n\n // Try to parse e.g. 1.x\n const coerced = parseInt(version, 10);\n if (!Number.isNaN(coerced)) {\n return coerced;\n }\n\n // Match <= and >= ranges.\n const gteLteRegex = /^[<>]=\\s*(\\d+)(\\.\\d+)?(\\.\\d+)?(-.+)?/;\n const gteLteMatch = version.match(gteLteRegex);\n if (gteLteMatch) {\n return parseInt(gteLteMatch[1] as string, 10);\n }\n\n // match < ranges\n const ltRegex = /^<\\s*(\\d+)(\\.\\d+)?(\\.\\d+)?(-.+)?/;\n const ltMatch = version.match(ltRegex);\n if (ltMatch) {\n // Two scenarios:\n // a) < 2.0.0 --> return 1\n // b) < 2.1.0 --> return 2\n\n const major = parseInt(ltMatch[1] as string, 10);\n\n if (\n // minor version > 0\n (typeof ltMatch[2] === 'string' && parseInt(ltMatch[2].slice(1), 10) > 0) ||\n // patch version > 0\n (typeof ltMatch[3] === 'string' && parseInt(ltMatch[3].slice(1), 10) > 0)\n ) {\n return major;\n }\n\n return major - 1;\n }\n\n // match > ranges\n const gtRegex = /^>\\s*(\\d+)(\\.\\d+)?(\\.\\d+)?(-.+)?/;\n const gtMatch = version.match(gtRegex);\n if (gtMatch) {\n // We always return the version here, even though it _may_ be incorrect\n // E.g. if given > 2.0.0, it should be 2 if there exists any 2.x.x version, else 3\n // Since there is no way for us to know this, we're going to assume any kind of patch/feature release probably exists\n return parseInt(gtMatch[1] as string, 10);\n }\n return undefined;\n}\n\n// This is an explicit list of packages where we want to include the (major) version number.\nconst PACKAGES_TO_INCLUDE_VERSION = [\n 'react',\n '@angular/core',\n 'vue',\n 'ember-source',\n 'svelte',\n '@sveltejs/kit',\n 'webpack',\n 'vite',\n 'gatsby',\n 'next',\n 'remix',\n 'rollup',\n 'esbuild',\n];\n\nexport function getDependencies(packageJson: PackageJson): {\n deps: string[];\n depsVersions: Record<string, number>;\n} {\n const dependencies: Record<string, string> = Object.assign(\n {},\n packageJson['devDependencies'] ?? {},\n packageJson['dependencies'] ?? {},\n );\n\n const deps = Object.keys(dependencies).sort();\n\n const depsVersions: Record<string, number> = deps.reduce(\n (depsVersions, depName) => {\n if (PACKAGES_TO_INCLUDE_VERSION.includes(depName)) {\n const version = dependencies[depName] as string;\n const majorVersion = parseMajorVersion(version);\n if (majorVersion) {\n depsVersions[depName] = majorVersion;\n }\n }\n return depsVersions;\n },\n {} as Record<string, number>,\n );\n\n return { deps, depsVersions };\n}\n\nfunction findPackageJson(cwd: string, stopAt: string): string | undefined {\n let dirName = path.resolve(cwd);\n\n for (;;) {\n // Stop if we reach this dir\n if (path.normalize(dirName) === stopAt) {\n return undefined;\n }\n\n const jsonPath = path.join(dirName, 'package.json');\n if (fs.existsSync(jsonPath)) {\n return jsonPath;\n }\n\n const parentDirName = path.dirname(dirName);\n // We reached the file system root\n if (parentDirName === dirName) {\n return undefined;\n }\n\n dirName = parentDirName;\n }\n}\n\nfunction lookupPackageJson(cwd: string, stopAt: string): PackageJson | undefined {\n const jsonPath = findPackageJson(cwd, stopAt);\n\n if (!jsonPath) {\n return undefined;\n }\n\n try {\n const jsonStr = fs.readFileSync(jsonPath, 'utf8');\n const json = JSON.parse(jsonStr) as PackageJson;\n\n // Ensure it is an actual package.json\n // This is very much not bulletproof, but should be good enough\n if ('name' in json || 'private' in json) {\n return json;\n }\n } catch {\n // Ignore and walk up\n }\n\n // Continue up the tree, if we find a fitting package.json\n const newCwd = path.dirname(path.resolve(`${jsonPath}/..`));\n return lookupPackageJson(newCwd, stopAt);\n}\n\n/**\n * Deterministically hashes a string and turns the hash into a uuid.\n */\nexport function stringToUUID(str: string): string {\n const sha256Hash = crypto.createHash('sha256').update(str).digest('hex');\n\n // Position 16 is fixed to either 8, 9, a, or b in the uuid v4 spec (10xx in binary)\n // RFC 4122 section 4.4\n const v4variant = ['8', '9', 'a', 'b'][sha256Hash.substring(16, 17).charCodeAt(0) % 4] as string;\n\n return `${sha256Hash.substring(0, 8)}-${sha256Hash.substring(8, 12)}-4${sha256Hash.substring(13, 16)}-${v4variant}${sha256Hash.substring(17, 20)}-${sha256Hash.substring(20, 32)}`.toLowerCase();\n}\n\nfunction gitRevision(): string | undefined {\n let gitRevision: string | undefined;\n try {\n gitRevision = childProcess\n .execSync('git rev-parse HEAD', { stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true })\n .toString()\n .trim();\n } catch {\n // noop\n }\n return gitRevision;\n}\n\n// Mirrors the CLI's `set-commits --auto` fallback for builds without an `origin` remote. Vercel is left out\n// because the CLI only reads `VERCEL_GIT_*` on production builds.\nconst CI_REPOSITORY_ENV_VARS = [\n 'GITHUB_REPOSITORY',\n 'CI_PROJECT_PATH',\n 'BITBUCKET_REPO_FULL_NAME',\n 'RENDER_GIT_REPO_SLUG',\n 'RAILWAY_GIT_REPO_NAME',\n 'CIRCLE_PROJECT_REPONAME',\n 'BUILDKITE_REPO',\n 'BUILD_REPOSITORY_URI',\n] as const;\n\n/**\n * Whether `set-commits --auto` can find the repository: from the `origin` git remote, or from CI variables.\n */\nexport function canAutoDetectRepository(): boolean {\n if (\n CI_REPOSITORY_ENV_VARS.some(name => process.env[name]) ||\n (process.env['NETLIFY'] && process.env['REPOSITORY_URL'])\n ) {\n return true;\n }\n try {\n childProcess.execSync('git remote get-url origin', { stdio: 'ignore', windowsHide: true });\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Tries to guess a release name based on environmental data.\n */\nexport function determineReleaseName(): string | undefined {\n return getReleaseFromCommitEnv(warnAboutPlaceholderCommitEnvVar) || gitRevision();\n}\n\n/**\n * Resolves the release name the way the bundler plugins do: the configured name, then the `SENTRY_RELEASE`\n * environment variable, then a name detected from CI environment variables or git.\n *\n * Framework SDKs that pass the release to the SDK at runtime use this to get the same name the plugin uses.\n */\nexport function resolveReleaseName(name?: string): string | undefined {\n return name ?? process.env['SENTRY_RELEASE'] ?? determineReleaseName();\n}\n\n// Release detection and commit association can read the same variable in one build.\nconst warnedPlaceholderEnvVars = new Set<string>();\n\nfunction warnAboutPlaceholderCommitEnvVar(name: string): void {\n if (warnedPlaceholderEnvVars.has(name)) {\n return;\n }\n warnedPlaceholderEnvVars.add(name);\n // This runs before the plugin logger exists, so `silent: true` does not suppress it. That is\n // deliberate: a warning that is easy to miss is how this misconfiguration went unnoticed.\n // eslint-disable-next-line no-console\n console.warn(\n `[@sentry/bundler-plugins] Ignoring the ${name} environment variable as a release name, because its value is its own name. Set the release explicitly, or fix the variable in your build environment.`,\n );\n}\n\n/**\n * Reads an environment variable that should hold a commit SHA, ignoring a value that is the\n * variable's own name. See `_INTERNAL_readCommitEnvVar` in `@sentry/core/server`.\n */\nexport function readCommitEnvVar(name: string): string | undefined {\n return readCoreCommitEnvVar(name, warnAboutPlaceholderCommitEnvVar);\n}\n\n/**\n * Generates code for the global injector which is responsible for setting the global\n * `SENTRY_RELEASE` & `SENTRY_BUILD_INFO` variables.\n */\nexport function generateReleaseInjectorCode({\n release,\n injectBuildInformation,\n}: {\n release: string;\n injectBuildInformation: boolean;\n}): CodeInjection {\n let code = `e.SENTRY_RELEASE={id:${stringifyForCodeInjection(release)}};`;\n\n if (injectBuildInformation) {\n const buildInfo = getBuildInformation();\n\n code += `e.SENTRY_BUILD_INFO=${stringifyForCodeInjection(buildInfo)};`;\n }\n\n return new CodeInjection(code);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function generateModuleMetadataInjectorCode(metadata: any): CodeInjection {\n // We are merging the metadata objects in case modules are bundled twice with the plugin\n // Use try-catch to avoid issues when bundlers rename global variables like 'window' to 'k'\n return new CodeInjection(\n `e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])}return e}({},e._sentryModuleMetadata[(new e.Error).stack],${stringifyForCodeInjection(\n metadata,\n )});`,\n );\n}\n\nexport function getBuildInformation(): {\n deps: string[];\n depsVersions: Record<string, number>;\n nodeVersion: number | undefined;\n} {\n const packageJson = getPackageJson();\n\n const { deps, depsVersions } = packageJson ? getDependencies(packageJson) : { deps: [], depsVersions: {} };\n\n return {\n deps,\n depsVersions,\n nodeVersion: parseMajorVersion(process.version),\n };\n}\n\nexport function stripQueryAndHashFromPath(path: string): string {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return path.split('?')[0]!.split('#')[0]!;\n}\n\nexport function replaceBooleanFlagsInCode(\n code: string,\n replacementValues: Record<string, boolean | undefined>,\n): { code: string; map: SourceMap } | null {\n const ms = new MagicString(code);\n\n Object.keys(replacementValues).forEach(key => {\n const value = replacementValues[key];\n\n if (typeof value === 'boolean') {\n ms.replaceAll(key, JSON.stringify(value));\n }\n });\n\n if (ms.hasChanged()) {\n return {\n code: ms.toString(),\n map: ms.generateMap({ hires: 'boundary' }),\n };\n }\n\n return null;\n}\n\n// https://turbo.build/repo/docs/reference/system-environment-variables#environment-variables-in-tasks\nexport function getTurborepoEnvPassthroughWarning(envVarName: string): string {\n return process.env['TURBO_HASH']\n ? `\\nYou seem to be using Turborepo, did you forget to put ${envVarName} in \\`passThroughEnv\\`? https://turbo.build/repo/docs/reference/configuration#passthroughenv`\n : '';\n}\n\n/**\n * Gets the projects from the project option. This might be a single project or an array of projects.\n */\nexport function getProjects(project: string | string[] | undefined): string[] | undefined {\n if (Array.isArray(project)) {\n return project;\n }\n\n if (project) {\n return [project];\n }\n\n return undefined;\n}\n\n/**\n * Checks if a chunk contains only import/export statements and no substantial code.\n *\n * In Vite MPA (multi-page application) mode, HTML entry points create \"facade\" chunks\n * that only contain import statements to load shared modules. These should not have\n * Sentry code injected. However, in SPA mode, the main bundle also has an HTML facade\n * but contains substantial application code that SHOULD have debug IDs injected.\n *\n * @ref https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/829\n * @ref https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/839\n */\nexport function containsOnlyImports(code: string): boolean {\n const codeWithoutImports = code\n // Remove side effect imports: import '/path'; or import \"./path\";\n // Using explicit negated character classes to avoid polynomial backtracking\n .replace(/^\\s*import\\s+(?:'[^'\\n]*'|\"[^\"\\n]*\"|`[^`\\n]*`)[\\s;]*$/gm, '')\n // Remove named/default imports: import x from '/path'; import { x } from '/path';\n .replace(/^\\s*import\\b[^'\"`\\n]*\\bfrom\\s+(?:'[^'\\n]*'|\"[^\"\\n]*\"|`[^`\\n]*`)[\\s;]*$/gm, '')\n // Remove re-exports: export * from '/path'; export { x } from '/path';\n .replace(/^\\s*export\\b[^'\"`\\n]*\\bfrom\\s+(?:'[^'\\n]*'|\"[^\"\\n]*\"|`[^`\\n]*`)[\\s;]*$/gm, '')\n // Remove block comments\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n // Remove line comments\n .replace(/\\/\\/.*$/gm, '')\n // Remove \"use strict\" directives\n .replace(/[\"']use strict[\"']\\s*;?/g, '')\n .trim();\n\n return codeWithoutImports.length === 0;\n}\n\nexport class CodeInjection {\n // The code below is mostly ternary operators because it saves bundle size.\n // The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)\n private readonly header: string;\n private readonly footer: string;\n\n constructor(private body: string = '') {\n // `globalThis` is checked first so the other identifiers are never evaluated\n // where it exists. A downstream bundler that runs over an already-injected\n // chunk can turn a free `global` into a `const` it declares further down the\n // file (Nitro's node compat does this). Reading that binding from the top of\n // the file hits the temporal dead zone, and `typeof` throws there instead of\n // returning \"undefined\", so the whole injection was silently swallowed by the\n // `catch` below and the chunk registered no debug ID.\n this.header = `!function(){try{var e=\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof self?self:{};`;\n this.footer = '}catch(e){}}();';\n }\n\n public code(): string {\n if (this.isEmpty()) {\n return '';\n }\n\n return this.header + this.body + this.footer;\n }\n\n public isEmpty(): boolean {\n return this.body.length === 0;\n }\n\n public append(code: CodeInjection | string): void {\n if (code instanceof CodeInjection) {\n this.body += code.body;\n } else {\n this.body += code;\n }\n }\n\n public clear(): void {\n this.body = '';\n }\n\n public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2DAA2D,WAAW,gGACtE;AACN;;;;AAKA,SAAgB,YAAY,SAA8D;CACxF,IAAI,MAAM,QAAQ,OAAO,GACvB,OAAO;CAGT,IAAI,SACF,OAAO,CAAC,OAAO;AAInB;;;;;;;;;;;;AAaA,SAAgB,oBAAoB,MAAuB;CAiBzD,OAhB2B,KAGxB,QAAQ,2DAA2D,EAAE,CAAC,CAEtE,QAAQ,4EAA4E,EAAE,CAAC,CAEvF,QAAQ,4EAA4E,EAAE,CAAC,CAEvF,QAAQ,qBAAqB,EAAE,CAAC,CAEhC,QAAQ,aAAa,EAAE,CAAC,CAExB,QAAQ,4BAA4B,EAAE,CAAC,CACvC,KAEqB,CAAC,CAAC,WAAW;AACvC;AAEA,IAAa,gBAAb,MAAa,cAAc;CAMzB,YAAoB,OAAe,IAAI;EAAnB,KAAA,OAAA;EAQlB,KAAK,SAAS;EACd,KAAK,SAAS;CAChB;CAEO,OAAe;EACpB,IAAI,KAAK,QAAQ,GACf,OAAO;EAGT,OAAO,KAAK,SAAS,KAAK,OAAO,KAAK;CACxC;CAEO,UAAmB;EACxB,OAAO,KAAK,KAAK,WAAW;CAC9B;CAEO,OAAO,MAAoC;EAChD,IAAI,gBAAgB,eAClB,KAAK,QAAQ,KAAK;OAElB,KAAK,QAAQ;CAEjB;CAEO,QAAc;EACnB,KAAK,OAAO;CACd;CAEO,QAAuB;EAC5B,OAAO,IAAI,cAAc,KAAK,IAAI;CACpC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":[],"sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"11.
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"11.15.0\";\n"],"mappings":";AAAA,MAAa,cAAc"}
|
|
@@ -5,8 +5,10 @@ Object.defineProperties(exports, {
|
|
|
5
5
|
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
6
6
|
const require_utils = require("../core/utils.js");
|
|
7
7
|
const require_debug_id_upload = require("../core/debug-id-upload.js");
|
|
8
|
+
const require_sourcemap_settings = require("../core/sourcemap-settings.js");
|
|
8
9
|
const require_build_plugin_manager = require("../core/build-plugin-manager.js");
|
|
9
10
|
const require_index = require("../core/index.js");
|
|
11
|
+
let _sentry_core = require("@sentry/core");
|
|
10
12
|
let node_path = require("node:path");
|
|
11
13
|
node_path = require_runtime.__toESM(node_path);
|
|
12
14
|
let node_module = require("node:module");
|
|
@@ -41,8 +43,9 @@ function sentryEsbuildPlugin(userOptions = {}) {
|
|
|
41
43
|
setup() {}
|
|
42
44
|
};
|
|
43
45
|
if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
|
|
44
|
-
const
|
|
46
|
+
const { injectDebugIds, upload: uploadEnabled, stampEmittedFiles } = require_sourcemap_settings.getSourceMapFeatures(options);
|
|
45
47
|
const staticInjectionCode = new require_utils.CodeInjection();
|
|
48
|
+
if (options.release.inject === "html") logger.warn("`release.inject: 'html'` is not supported by the esbuild plugin. Injecting the release into the startup chunks instead.");
|
|
46
49
|
if (!options.release.inject) logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
|
|
47
50
|
else if (!options.release.name) logger.debug("No release name provided. Will not inject release. Please set the `release.name` option to identify your release.");
|
|
48
51
|
else staticInjectionCode.append(require_utils.generateReleaseInjectorCode({
|
|
@@ -86,7 +89,7 @@ function sentryEsbuildPlugin(userOptions = {}) {
|
|
|
86
89
|
...replacementStringValues
|
|
87
90
|
};
|
|
88
91
|
}
|
|
89
|
-
if (
|
|
92
|
+
if (injectDebugIds) {
|
|
90
93
|
onStart(() => debugIdWrappedPaths.clear());
|
|
91
94
|
initialOptions.logOverride = {
|
|
92
95
|
"import-is-undefined": "silent",
|
|
@@ -119,9 +122,9 @@ function sentryEsbuildPlugin(userOptions = {}) {
|
|
|
119
122
|
pluginName,
|
|
120
123
|
contents: `
|
|
121
124
|
import "_sentry-debug-id-injection-stub";
|
|
122
|
-
import * as OriginalModule from ${
|
|
125
|
+
import * as OriginalModule from ${(0, _sentry_core.stringifyForCodeInjection)(originalPath)};
|
|
123
126
|
export default OriginalModule.default;
|
|
124
|
-
export * from ${
|
|
127
|
+
export * from ${(0, _sentry_core.stringifyForCodeInjection)(originalPath)};`,
|
|
125
128
|
resolveDir: originalResolveDir
|
|
126
129
|
};
|
|
127
130
|
});
|
|
@@ -155,21 +158,21 @@ function sentryEsbuildPlugin(userOptions = {}) {
|
|
|
155
158
|
const upload = require_debug_id_upload.createDebugIdUploadFunction({ sentryBuildPluginManager });
|
|
156
159
|
initialOptions.metafile = true;
|
|
157
160
|
onEnd(async (result) => {
|
|
161
|
+
const outputDir = initialOptions.absWorkingDir ?? process.cwd();
|
|
162
|
+
const buildArtifacts = result.metafile ? Object.keys(result.metafile.outputs).map((output) => node_path.resolve(outputDir, output)) : [];
|
|
163
|
+
const { sourceMaps } = sentryBuildPluginManager;
|
|
164
|
+
const allMaps = buildArtifacts.filter((artifact) => artifact.endsWith(".map"));
|
|
158
165
|
try {
|
|
159
166
|
await sentryBuildPluginManager.createRelease();
|
|
160
|
-
const outputDir = initialOptions.absWorkingDir ?? process.cwd();
|
|
161
|
-
const buildArtifacts = result.metafile ? Object.keys(result.metafile.outputs).map((output) => node_path.resolve(outputDir, output)) : [];
|
|
162
|
-
const { sourceMaps } = sentryBuildPluginManager;
|
|
163
|
-
const allMaps = buildArtifacts.filter((artifact) => artifact.endsWith(".map"));
|
|
164
167
|
const deleteWithoutUpload = sourceMapDecision.deleteAfterUpload && !sourceMaps.uploadPossible;
|
|
165
|
-
if (
|
|
168
|
+
if (stampEmittedFiles) {
|
|
166
169
|
if (initialOptions.write === false) logger.debug("Build output is not written to disk. Skipping debug ID injection into build artifacts.");
|
|
167
170
|
else await Promise.all(buildArtifacts.filter(require_index.isJsFile).map((bundle) => require_debug_id_upload.addDebugIdToEmittedArtifacts(bundle, logger, options.sourcemaps?.resolveSourceMap)));
|
|
168
|
-
} else if (
|
|
171
|
+
} else if (uploadEnabled) {
|
|
169
172
|
const { uploaded, uploadedSourceMapPaths } = await upload(buildArtifacts.map((artifact) => artifact.split(node_path.sep).join("/")));
|
|
170
173
|
if (sourceMapDecision.deleteAfterUpload && !deleteWithoutUpload) {
|
|
171
174
|
const mapsToDelete = sourceMapDecision.removeAllSourceMaps ? allMaps : uploadedSourceMapPaths;
|
|
172
|
-
if (uploaded) await sourceMaps.deleteFromOutput(mapsToDelete);
|
|
175
|
+
if (uploaded || options.sourcemaps?.delete === true) await sourceMaps.deleteFromOutput(mapsToDelete);
|
|
173
176
|
else if (mapsToDelete.length > 0) logger.error("The source maps were not uploaded, so they stay in the build output.");
|
|
174
177
|
}
|
|
175
178
|
}
|
|
@@ -178,6 +181,9 @@ function sentryEsbuildPlugin(userOptions = {}) {
|
|
|
178
181
|
const isUploaded = (map) => require_index.isJsFile(bundleOf(map)) && sourceMaps.shouldUpload(bundleOf(map));
|
|
179
182
|
await sourceMaps.deleteFromOutput(sourceMapDecision.removeAllSourceMaps ? allMaps : allMaps.filter(isUploaded));
|
|
180
183
|
}
|
|
184
|
+
} catch (error) {
|
|
185
|
+
if (options.sourcemaps?.delete === true && sourceMapDecision.deleteAfterUpload) await sourceMaps.deleteFromOutput(allMaps);
|
|
186
|
+
throw error;
|
|
181
187
|
} finally {
|
|
182
188
|
freeGlobalDependencyOnBuildArtifacts();
|
|
183
189
|
await sentryBuildPluginManager.deleteArtifacts();
|