@sentry/bundler-plugins 11.14.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 +5 -1
- 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/sourcemap-settings.js +85 -5
- package/build/cjs/core/sourcemap-settings.js.map +1 -1
- package/build/cjs/core/utils.js +10 -0
- 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 +14 -9
- 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 +6 -2
- 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/sourcemap-settings.js +84 -6
- package/build/esm/core/sourcemap-settings.js.map +1 -1
- package/build/esm/core/utils.js +10 -1
- 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 +14 -9
- 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":"telemetry.js","names":[],"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,MAAM,uBAAuB;AAE7B,MAAM,cAAc,kBAAkB,oBAAoB,CAAC;AAE3D,SAAgB,qBACd,SACA,qBACA,WACA,uBAC8C;CAC9C,MAAM,gBAA4C;EAChD,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AM,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":[],"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,cAAc,kBAAkB,oBAAoB,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,SAAS;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,WAAW,mCAAmC,mBAAmB;CACnE;CAEA,iBAAiB,eAAe,MAAM;CAEtC,MAAM,SAAS,IAAI,oBAAoB,aAAa;CACpD,MAAM,QAAQ,IAAI,MAAM;CACxB,MAAM,UAAU,MAAM;CAGtB,IAAI,QAAQ,IAAI,wBACd,MAAM,sBAAsB;EAAE,GAAG,MAAM,sBAAsB;EAAG,YAAY;CAAE,CAAC;CAGjF,wBAAwB,SAAS,OAAO,WAAW,qBAAqB;CAExE,OAAO;EAAE,aAAa;EAAO,cAAc;CAAO;AACpD;AAEA,SAAgB,wBACd,SACA,OACA,WACA,uBACM;CACN,MAAM,EAAE,KAAK,SAAS,SAAS,cAAc,YAAY,6BAA6B;CAEtF,MAAM,OAAO,4BAA4B,CAAC,CAAC,QAAQ,sBAAsB;CACzE,IAAI,QAAQ,wBACV,MAAM,OACJ,iCACA,MAAM,QAAQ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EtC,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,IAAI,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,13 +1,32 @@
|
|
|
1
|
+
import { resolveSourceMapsFeatures } from "@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 } = 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 ${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,6 +114,63 @@ function decideSourceMapHandling(kind, options, uploadPossible, environment) {
|
|
|
93
114
|
};
|
|
94
115
|
}
|
|
95
116
|
}
|
|
96
|
-
|
|
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
|
+
}
|
|
174
|
+
export { decideSourceMapHandling, getDeleteOption, getDeleteSourcemapsAfterUpload, getSdkEnabledSourceMaps, getSourceMapFeatures };
|
|
97
175
|
|
|
98
176
|
//# 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":[],"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,WAAW,0BAA0B,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,aA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BAAiB,MACnB,OAAO;GAET,OAAO;IACL,cAAc;IACd,mBAAmB;IACnB,qBAAqB;IACrB,KAAK;KACH,OAAO;KACP,SACE;IAEJ;GACF;CACJ;AACF;;;;;;AAOA,SAAS,uBACP,MACA,kBACA,UACA,gBACmB;CACnB,QAAQ,MAAR;EACE,KAAK,OACH,OAAO,iBAAiB;GAAE,GAAG;GAAW,KAAK;IAAE,OAAO;IAAQ,SAAS;GAAwB;EAAE,IAAI;EAEvG,KAAK,UACH,OAAO,iBAAiB;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/esm/core/utils.js
CHANGED
|
@@ -152,6 +152,15 @@ function canAutoDetectRepository() {
|
|
|
152
152
|
function determineReleaseName() {
|
|
153
153
|
return _INTERNAL_getReleaseFromCommitEnv(warnAboutPlaceholderCommitEnvVar) || gitRevision();
|
|
154
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Resolves the release name the way the bundler plugins do: the configured name, then the `SENTRY_RELEASE`
|
|
157
|
+
* environment variable, then a name detected from CI environment variables or git.
|
|
158
|
+
*
|
|
159
|
+
* Framework SDKs that pass the release to the SDK at runtime use this to get the same name the plugin uses.
|
|
160
|
+
*/
|
|
161
|
+
function resolveReleaseName(name) {
|
|
162
|
+
return name ?? process.env["SENTRY_RELEASE"] ?? determineReleaseName();
|
|
163
|
+
}
|
|
155
164
|
const warnedPlaceholderEnvVars = /* @__PURE__ */ new Set();
|
|
156
165
|
function warnAboutPlaceholderCommitEnvVar(name) {
|
|
157
166
|
if (warnedPlaceholderEnvVars.has(name)) return;
|
|
@@ -255,6 +264,6 @@ var CodeInjection = class CodeInjection {
|
|
|
255
264
|
return new CodeInjection(this.body);
|
|
256
265
|
}
|
|
257
266
|
};
|
|
258
|
-
export { CodeInjection, arrayify, canAutoDetectRepository, containsOnlyImports, determineReleaseName, generateModuleMetadataInjectorCode, generateReleaseInjectorCode, getBuildInformation, getDependencies, getPackageJson, getProjects, getTurborepoEnvPassthroughWarning, parseMajorVersion, readCommitEnvVar, replaceBooleanFlagsInCode, stringToUUID, stripQueryAndHashFromPath };
|
|
267
|
+
export { CodeInjection, arrayify, canAutoDetectRepository, containsOnlyImports, determineReleaseName, generateModuleMetadataInjectorCode, generateReleaseInjectorCode, getBuildInformation, getDependencies, getPackageJson, getProjects, getTurborepoEnvPassthroughWarning, parseMajorVersion, readCommitEnvVar, replaceBooleanFlagsInCode, resolveReleaseName, stringToUUID, stripQueryAndHashFromPath };
|
|
259
268
|
|
|
260
269
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["getReleaseFromCommitEnv","readCoreCommitEnvVar"],"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// 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 clone(): CodeInjection {\n return new CodeInjection(this.body);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,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,GAAG,KAAK,UAAU,UAAU,GAAG,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,MAAM,UAAU,QAAQ,MAAM,kCAAO;CACrC,IA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,WAAW,GAChB,OAAO;EACL,MAAM,GAAG,SAAS;EAClB,KAAK,GAAG,YAAY,EAAE,OAAO,WAAW,CAAC;CAC3C;CAGF,OAAO;AACT;AAGA,SAAgB,kCAAkC,YAA4B;CAC5E,OAAO,QAAQ,IAAI,gBACf,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
|
+
{"version":3,"file":"utils.js","names":["getReleaseFromCommitEnv","readCoreCommitEnvVar"],"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 clone(): CodeInjection {\n return new CodeInjection(this.body);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,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,GAAG,KAAK,UAAU,UAAU,GAAG,QAAQ,CAAC,CAAC;AACvF;A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,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"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { CodeInjection, generateModuleMetadataInjectorCode, generateReleaseInjectorCode } from "../core/utils.js";
|
|
3
3
|
import { addDebugIdToEmittedArtifacts, createDebugIdUploadFunction } from "../core/debug-id-upload.js";
|
|
4
|
+
import { getSourceMapFeatures } from "../core/sourcemap-settings.js";
|
|
4
5
|
import { createSentryBuildPluginManager } from "../core/build-plugin-manager.js";
|
|
5
6
|
import { getDebugIdSnippet, isJsFile } from "../core/index.js";
|
|
6
7
|
import { createRequire } from "node:module";
|
|
@@ -37,8 +38,9 @@ function sentryEsbuildPlugin(userOptions = {}) {
|
|
|
37
38
|
setup() {}
|
|
38
39
|
};
|
|
39
40
|
if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
|
|
40
|
-
const
|
|
41
|
+
const { injectDebugIds, upload: uploadEnabled, stampEmittedFiles } = getSourceMapFeatures(options);
|
|
41
42
|
const staticInjectionCode = new CodeInjection();
|
|
43
|
+
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.");
|
|
42
44
|
if (!options.release.inject) logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
|
|
43
45
|
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.");
|
|
44
46
|
else staticInjectionCode.append(generateReleaseInjectorCode({
|
|
@@ -82,7 +84,7 @@ function sentryEsbuildPlugin(userOptions = {}) {
|
|
|
82
84
|
...replacementStringValues
|
|
83
85
|
};
|
|
84
86
|
}
|
|
85
|
-
if (
|
|
87
|
+
if (injectDebugIds) {
|
|
86
88
|
onStart(() => debugIdWrappedPaths.clear());
|
|
87
89
|
initialOptions.logOverride = {
|
|
88
90
|
"import-is-undefined": "silent",
|
|
@@ -151,21 +153,21 @@ function sentryEsbuildPlugin(userOptions = {}) {
|
|
|
151
153
|
const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });
|
|
152
154
|
initialOptions.metafile = true;
|
|
153
155
|
onEnd(async (result) => {
|
|
156
|
+
const outputDir = initialOptions.absWorkingDir ?? process.cwd();
|
|
157
|
+
const buildArtifacts = result.metafile ? Object.keys(result.metafile.outputs).map((output) => path.resolve(outputDir, output)) : [];
|
|
158
|
+
const { sourceMaps } = sentryBuildPluginManager;
|
|
159
|
+
const allMaps = buildArtifacts.filter((artifact) => artifact.endsWith(".map"));
|
|
154
160
|
try {
|
|
155
161
|
await sentryBuildPluginManager.createRelease();
|
|
156
|
-
const outputDir = initialOptions.absWorkingDir ?? process.cwd();
|
|
157
|
-
const buildArtifacts = result.metafile ? Object.keys(result.metafile.outputs).map((output) => path.resolve(outputDir, output)) : [];
|
|
158
|
-
const { sourceMaps } = sentryBuildPluginManager;
|
|
159
|
-
const allMaps = buildArtifacts.filter((artifact) => artifact.endsWith(".map"));
|
|
160
162
|
const deleteWithoutUpload = sourceMapDecision.deleteAfterUpload && !sourceMaps.uploadPossible;
|
|
161
|
-
if (
|
|
163
|
+
if (stampEmittedFiles) {
|
|
162
164
|
if (initialOptions.write === false) logger.debug("Build output is not written to disk. Skipping debug ID injection into build artifacts.");
|
|
163
165
|
else await Promise.all(buildArtifacts.filter(isJsFile).map((bundle) => addDebugIdToEmittedArtifacts(bundle, logger, options.sourcemaps?.resolveSourceMap)));
|
|
164
|
-
} else if (
|
|
166
|
+
} else if (uploadEnabled) {
|
|
165
167
|
const { uploaded, uploadedSourceMapPaths } = await upload(buildArtifacts.map((artifact) => artifact.split(path.sep).join("/")));
|
|
166
168
|
if (sourceMapDecision.deleteAfterUpload && !deleteWithoutUpload) {
|
|
167
169
|
const mapsToDelete = sourceMapDecision.removeAllSourceMaps ? allMaps : uploadedSourceMapPaths;
|
|
168
|
-
if (uploaded) await sourceMaps.deleteFromOutput(mapsToDelete);
|
|
170
|
+
if (uploaded || options.sourcemaps?.delete === true) await sourceMaps.deleteFromOutput(mapsToDelete);
|
|
169
171
|
else if (mapsToDelete.length > 0) logger.error("The source maps were not uploaded, so they stay in the build output.");
|
|
170
172
|
}
|
|
171
173
|
}
|
|
@@ -174,6 +176,9 @@ function sentryEsbuildPlugin(userOptions = {}) {
|
|
|
174
176
|
const isUploaded = (map) => isJsFile(bundleOf(map)) && sourceMaps.shouldUpload(bundleOf(map));
|
|
175
177
|
await sourceMaps.deleteFromOutput(sourceMapDecision.removeAllSourceMaps ? allMaps : allMaps.filter(isUploaded));
|
|
176
178
|
}
|
|
179
|
+
} catch (error) {
|
|
180
|
+
if (options.sourcemaps?.delete === true && sourceMapDecision.deleteAfterUpload) await sourceMaps.deleteFromOutput(allMaps);
|
|
181
|
+
throw error;
|
|
177
182
|
} finally {
|
|
178
183
|
freeGlobalDependencyOnBuildArtifacts();
|
|
179
184
|
await sentryBuildPluginManager.deleteArtifacts();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/esbuild/index.ts"],"sourcesContent":["/* oxlint-disable max-lines */\nimport type { InternalOptions, SourceMapDecision, SourceMapKind } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n CodeInjection,\n addDebugIdToEmittedArtifacts,\n isJsFile,\n} from '../core';\nimport * as path from 'node:path';\nimport { createRequire } from 'node:module';\nimport { randomUUID } from 'node:crypto';\nimport { stringifyForCodeInjection } from '@sentry/core';\n\ninterface EsbuildOnResolveArgs {\n path: string;\n kind: string;\n importer?: string;\n resolveDir: string;\n pluginData?: unknown;\n}\n\ninterface EsbuildOnResolveResult {\n path: string;\n sideEffects?: boolean;\n pluginName?: string;\n namespace?: string;\n suffix?: string;\n pluginData?: unknown;\n}\n\ninterface EsbuildOnLoadArgs {\n path: string;\n pluginData?: unknown;\n}\n\ninterface EsbuildOnLoadResult {\n loader: string;\n pluginName: string;\n contents: string;\n resolveDir?: string;\n}\n\ninterface EsbuildOnEndArgs {\n metafile?: {\n outputs: Record<string, unknown>;\n };\n}\n\ntype EsbuildSourceMapSetting = boolean | 'inline' | 'external' | 'linked' | 'both' | undefined;\n\ninterface EsbuildInitialOptions {\n bundle?: boolean;\n inject?: string[];\n metafile?: boolean;\n define?: Record<string, string>;\n write?: boolean;\n absWorkingDir?: string;\n logOverride?: Record<string, string>;\n sourcemap?: EsbuildSourceMapSetting;\n}\n\n/** Maps esbuild's `sourcemap` setting onto the plugin's source map kinds. */\nfunction sourceMapKindFromEsbuildSetting(setting: EsbuildSourceMapSetting): SourceMapKind {\n switch (setting) {\n case undefined:\n return 'unset';\n case false:\n return 'off';\n case 'external':\n return 'hidden';\n case 'inline':\n case 'both':\n return 'inline';\n default:\n return 'visible';\n }\n}\n\ninterface EsbuildPluginBuild {\n initialOptions: EsbuildInitialOptions;\n onLoad: (\n options: { filter: RegExp; namespace?: string },\n callback: (args: EsbuildOnLoadArgs) => EsbuildOnLoadResult | null,\n ) => void;\n onResolve: (\n options: { filter: RegExp },\n callback: (args: EsbuildOnResolveArgs) => EsbuildOnResolveResult | undefined,\n ) => void;\n onStart: (callback: () => void) => void;\n onEnd: (callback: (result: EsbuildOnEndArgs) => void | Promise<void>) => void;\n}\n\nfunction getEsbuildMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - esbuild transpiles this for us\n const req = createRequire(import.meta.url);\n const esbuild = req('esbuild') as { version?: string };\n // esbuild hasn't released a v1 yet, so we'll return the minor version as the major version\n return esbuild.version?.split('.')[1];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nconst pluginName = 'sentry-esbuild-plugin';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function sentryEsbuildPlugin(userOptions: InternalOptions = {}): any {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[${pluginName}]`,\n buildTool: 'esbuild',\n buildToolMajorVersion: getEsbuildMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n name: 'sentry-esbuild-noop-plugin',\n setup() {\n // noop plugin\n },\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const sourcemapsEnabled = options.sourcemaps?.disable !== true;\n const staticInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n staticInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n // Component annotation warning\n if (options.reactComponentAnnotation?.enabled) {\n logger.warn(\n 'Component name annotation is not supported in esbuild. Please use a separate transform step or consider using a different bundler.',\n );\n }\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n\n // Track entry points wrapped for debug ID injection\n const debugIdWrappedPaths = new Set<string>();\n\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n\n return {\n name: pluginName,\n setup({ initialOptions, onLoad, onResolve, onStart, onEnd }: EsbuildPluginBuild) {\n // Release and/or metadata injection\n if (!staticInjectionCode.isEmpty()) {\n const virtualInjectionFilePath = path.resolve('_sentry-injection-stub');\n initialOptions.inject = initialOptions.inject || [];\n // esbuild emits injected files after an entry's directive prologue. A banner would precede\n // \"use strict\" and turn it into an ordinary string expression.\n initialOptions.inject.push(virtualInjectionFilePath);\n\n onResolve({ filter: /_sentry-injection-stub/ }, args => {\n return {\n path: args.path,\n sideEffects: true,\n pluginName,\n };\n });\n\n onLoad({ filter: /_sentry-injection-stub/ }, () => {\n return {\n loader: 'js',\n pluginName,\n contents: staticInjectionCode.code(),\n };\n });\n }\n\n // Bundle size optimizations\n if (transformReplace) {\n const replacementStringValues: Record<string, string> = {};\n Object.entries(replacementValues).forEach(([key, value]) => {\n replacementStringValues[key] = JSON.stringify(value);\n });\n\n initialOptions.define = { ...initialOptions.define, ...replacementStringValues };\n }\n\n // Debug ID injection - requires per-entry-point unique IDs\n if (sourcemapsEnabled) {\n // `setup` runs once per context, `onStart` once per build, so a\n // rebuild wraps the entry points again.\n onStart(() => debugIdWrappedPaths.clear());\n\n // The proxy module re-exports `OriginalModule.default` statically so downstream bundlers can tree-shake it,\n // but esbuild warns about that access when the entry point has no default export.\n initialOptions.logOverride = { 'import-is-undefined': 'silent', ...initialOptions.logOverride };\n\n if (!initialOptions.bundle) {\n logger.warn(\n 'The Sentry esbuild plugin only supports esbuild with `bundle: true` being set in the esbuild build options. Esbuild will probably crash now. Sorry about that. If you need to upload sourcemaps without `bundle: true`, it is recommended to use Sentry CLI instead: https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/cli/',\n );\n }\n\n // Wrap entry points to inject debug IDs\n onResolve({ filter: /.*/ }, args => {\n if (args.kind !== 'entry-point') {\n return;\n }\n\n // Skip injecting debug IDs into modules specified in the esbuild `inject` option\n // since they're already part of the entry points\n if (initialOptions.inject?.includes(args.path)) {\n return;\n }\n\n const resolvedPath = path.isAbsolute(args.path) ? args.path : path.join(args.resolveDir, args.path);\n\n // Skip injecting debug IDs into paths that have already been wrapped\n if (debugIdWrappedPaths.has(resolvedPath)) {\n return;\n }\n debugIdWrappedPaths.add(resolvedPath);\n\n return {\n pluginName,\n path: resolvedPath,\n pluginData: {\n isDebugIdProxy: true,\n originalPath: args.path,\n originalResolveDir: args.resolveDir,\n },\n // We need to add a suffix here, otherwise esbuild will mark the entrypoint as resolved and won't traverse\n // the module tree any further down past the proxy module because we're essentially creating a dependency\n // loop back to the proxy module.\n // By setting a suffix we're telling esbuild that the entrypoint and proxy module are two different things,\n // making it re-resolve the entrypoint when it is imported from the proxy module.\n // Super confusing? Yes. Works? Apparently... Let's see.\n suffix: '?sentryDebugIdProxy=true',\n };\n });\n\n onLoad({ filter: /.*/ }, args => {\n if (!(args.pluginData as { isDebugIdProxy?: boolean })?.isDebugIdProxy) {\n return null;\n }\n\n const originalPath = (args.pluginData as { originalPath: string }).originalPath;\n const originalResolveDir = (args.pluginData as { originalResolveDir: string }).originalResolveDir;\n\n return {\n loader: 'js',\n pluginName,\n contents: `\n import \"_sentry-debug-id-injection-stub\";\n import * as OriginalModule from ${stringifyForCodeInjection(originalPath)};\n export default OriginalModule.default;\n export * from ${stringifyForCodeInjection(originalPath)};`,\n resolveDir: originalResolveDir,\n };\n });\n\n onResolve({ filter: /_sentry-debug-id-injection-stub/ }, args => {\n return {\n path: args.path,\n sideEffects: true,\n pluginName,\n namespace: 'sentry-debug-id-stub',\n suffix: `?sentry-module-id=${randomUUID()}`,\n };\n });\n\n onLoad({ filter: /_sentry-debug-id-injection-stub/, namespace: 'sentry-debug-id-stub' }, () => {\n return {\n loader: 'js',\n pluginName,\n contents: getDebugIdSnippet(randomUUID()).code(),\n };\n });\n }\n\n // With `write: false` nothing reaches the disk, so nothing can be uploaded or deleted.\n const sourceMapKind = sourceMapKindFromEsbuildSetting(initialOptions.sourcemap);\n const sourceMapDecision: SourceMapDecision =\n initialOptions.write === false\n ? { enableHidden: false, deleteAfterUpload: false }\n : sentryBuildPluginManager.sourceMaps.decide(sourceMapKind);\n if (sourceMapDecision.enableHidden) {\n initialOptions.sourcemap = 'external';\n }\n\n // Create release and optionally upload\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n\n initialOptions.metafile = true;\n onEnd(async result => {\n try {\n await sentryBuildPluginManager.createRelease();\n\n // The metafile lists outputs relative to `absWorkingDir`, not to the process.\n const outputDir = initialOptions.absWorkingDir ?? process.cwd();\n const buildArtifacts = result.metafile\n ? Object.keys(result.metafile.outputs).map(output => path.resolve(outputDir, output))\n : [];\n\n const { sourceMaps } = sentryBuildPluginManager;\n const allMaps = buildArtifacts.filter(artifact => artifact.endsWith('.map'));\n const deleteWithoutUpload = sourceMapDecision.deleteAfterUpload && !sourceMaps.uploadPossible;\n if (sourcemapsEnabled && options.sourcemaps?.disable === 'disable-upload') {\n if (initialOptions.write === false) {\n logger.debug('Build output is not written to disk. Skipping debug ID injection into build artifacts.');\n } else {\n // The upload routine (which stamps debug IDs into temp copies of the artifacts) is\n // skipped with `disable-upload`. esbuild has no hook to modify outputs before they are\n // written, so the emitted artifacts get stamped on disk instead.\n await Promise.all(\n buildArtifacts\n .filter(isJsFile)\n .map(bundle => addDebugIdToEmittedArtifacts(bundle, logger, options.sourcemaps?.resolveSourceMap)),\n );\n }\n } else if (sourcemapsEnabled) {\n // The upload globs the paths, and glob reads backslashes as escapes.\n // When no upload can run, this logs why.\n const { uploaded, uploadedSourceMapPaths } = await upload(\n buildArtifacts.map(artifact => artifact.split(path.sep).join('/')),\n );\n\n // esbuild writes before `onEnd` runs, so the maps are deleted from disk\n // afterwards instead of being dropped from the output like in other bundlers.\n // A map the plugin turned on never stays in the output. A map the user\n // enabled is only deleted once it was uploaded.\n if (sourceMapDecision.deleteAfterUpload && !deleteWithoutUpload) {\n const mapsToDelete = sourceMapDecision.removeAllSourceMaps ? allMaps : uploadedSourceMapPaths;\n\n if (uploaded) {\n await sourceMaps.deleteFromOutput(mapsToDelete);\n } else if (mapsToDelete.length > 0) {\n logger.error('The source maps were not uploaded, so they stay in the build output.');\n }\n }\n }\n\n if (deleteWithoutUpload) {\n const bundleOf = (map: string): string => map.slice(0, -'.map'.length);\n const isUploaded = (map: string): boolean =>\n isJsFile(bundleOf(map)) && sourceMaps.shouldUpload(bundleOf(map));\n await sourceMaps.deleteFromOutput(\n sourceMapDecision.removeAllSourceMaps ? allMaps : allMaps.filter(isUploaded),\n );\n }\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n });\n },\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport default sentryEsbuildPlugin;\nexport type { Options as SentryEsbuildPluginOptions } from '../core';\n"],"mappings":";;;;;;;;;;;AAkEA,SAAS,gCAAgC,SAAiD;CACxF,QAAQ,SAAR;EACE,KAAK,KAAA,GACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK;EACL,KAAK,QACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAgBA,SAAS,yBAA6C;CACpD,IAAI;EAMF,OAHY,cAAc,YAAY,GACpB,CAAC,CAAC,SAEP,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC;CACrC,QAAQ,CAER;AAGF;AAEA,MAAM,aA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EJ,OAAO,IAAI,mBAAmB;MAG5B,MAAM,EAAE,UAAU,2BAA2B,MAAM,OACjD,eAAe,KAAI,aAAY,SAAS,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CACnE;MAMA,IAAI,kBAAkB,qBAAqB,CAAC,qBAAqB;OAC/D,MAAM,eAAe,kBAAkB,sBAAsB,UAAU;OAEvE,IAAI,UACF,MAAM,WAAW,iBAAiB,YAAY;YACzC,IAAI,aAAa,SAAS,GAC/B,OAAO,MAAM,sEAAsE;MAEvF;KACF;KAEA,IAAI,qBAAqB;MACvB,MAAM,YAAY,QAAwB,IAAI,MAAM,GAAG,EAAc;MACrE,MAAM,cAAc,QAClB,SAAS,SAAS,GAAG,CAAC,KAAK,WAAW,aAAa,SAAS,GAAG,CAAC;MAClE,MAAM,WAAW,iBACf,kBAAkB,sBAAsB,UAAU,QAAQ,OAAO,UAAU,CAC7E;KACF;IACF,UAAU;KACR,qCAAqC;KACrC,MAAM,yBAAyB,gBAAgB;IACjD;GACF,CAAC;EACH;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/esbuild/index.ts"],"sourcesContent":["/* oxlint-disable max-lines */\nimport type { InternalOptions, SourceMapDecision, SourceMapKind } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n CodeInjection,\n addDebugIdToEmittedArtifacts,\n isJsFile,\n getSourceMapFeatures,\n} from '../core';\nimport * as path from 'node:path';\nimport { createRequire } from 'node:module';\nimport { randomUUID } from 'node:crypto';\nimport { stringifyForCodeInjection } from '@sentry/core';\n\ninterface EsbuildOnResolveArgs {\n path: string;\n kind: string;\n importer?: string;\n resolveDir: string;\n pluginData?: unknown;\n}\n\ninterface EsbuildOnResolveResult {\n path: string;\n sideEffects?: boolean;\n pluginName?: string;\n namespace?: string;\n suffix?: string;\n pluginData?: unknown;\n}\n\ninterface EsbuildOnLoadArgs {\n path: string;\n pluginData?: unknown;\n}\n\ninterface EsbuildOnLoadResult {\n loader: string;\n pluginName: string;\n contents: string;\n resolveDir?: string;\n}\n\ninterface EsbuildOnEndArgs {\n metafile?: {\n outputs: Record<string, unknown>;\n };\n}\n\ntype EsbuildSourceMapSetting = boolean | 'inline' | 'external' | 'linked' | 'both' | undefined;\n\ninterface EsbuildInitialOptions {\n bundle?: boolean;\n inject?: string[];\n metafile?: boolean;\n define?: Record<string, string>;\n write?: boolean;\n absWorkingDir?: string;\n logOverride?: Record<string, string>;\n sourcemap?: EsbuildSourceMapSetting;\n}\n\n/** Maps esbuild's `sourcemap` setting onto the plugin's source map kinds. */\nfunction sourceMapKindFromEsbuildSetting(setting: EsbuildSourceMapSetting): SourceMapKind {\n switch (setting) {\n case undefined:\n return 'unset';\n case false:\n return 'off';\n case 'external':\n return 'hidden';\n case 'inline':\n case 'both':\n return 'inline';\n default:\n return 'visible';\n }\n}\n\ninterface EsbuildPluginBuild {\n initialOptions: EsbuildInitialOptions;\n onLoad: (\n options: { filter: RegExp; namespace?: string },\n callback: (args: EsbuildOnLoadArgs) => EsbuildOnLoadResult | null,\n ) => void;\n onResolve: (\n options: { filter: RegExp },\n callback: (args: EsbuildOnResolveArgs) => EsbuildOnResolveResult | undefined,\n ) => void;\n onStart: (callback: () => void) => void;\n onEnd: (callback: (result: EsbuildOnEndArgs) => void | Promise<void>) => void;\n}\n\nfunction getEsbuildMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - esbuild transpiles this for us\n const req = createRequire(import.meta.url);\n const esbuild = req('esbuild') as { version?: string };\n // esbuild hasn't released a v1 yet, so we'll return the minor version as the major version\n return esbuild.version?.split('.')[1];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nconst pluginName = 'sentry-esbuild-plugin';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function sentryEsbuildPlugin(userOptions: InternalOptions = {}): any {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[${pluginName}]`,\n buildTool: 'esbuild',\n buildToolMajorVersion: getEsbuildMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n name: 'sentry-esbuild-noop-plugin',\n setup() {\n // noop plugin\n },\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const { injectDebugIds, upload: uploadEnabled, stampEmittedFiles } = getSourceMapFeatures(options);\n const staticInjectionCode = new CodeInjection();\n\n if (options.release.inject === 'html') {\n logger.warn(\n \"`release.inject: 'html'` is not supported by the esbuild plugin. Injecting the release into the startup chunks instead.\",\n );\n }\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n staticInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n // Component annotation warning\n if (options.reactComponentAnnotation?.enabled) {\n logger.warn(\n 'Component name annotation is not supported in esbuild. Please use a separate transform step or consider using a different bundler.',\n );\n }\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n\n // Track entry points wrapped for debug ID injection\n const debugIdWrappedPaths = new Set<string>();\n\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n\n return {\n name: pluginName,\n setup({ initialOptions, onLoad, onResolve, onStart, onEnd }: EsbuildPluginBuild) {\n // Release and/or metadata injection\n if (!staticInjectionCode.isEmpty()) {\n const virtualInjectionFilePath = path.resolve('_sentry-injection-stub');\n initialOptions.inject = initialOptions.inject || [];\n // esbuild emits injected files after an entry's directive prologue. A banner would precede\n // \"use strict\" and turn it into an ordinary string expression.\n initialOptions.inject.push(virtualInjectionFilePath);\n\n onResolve({ filter: /_sentry-injection-stub/ }, args => {\n return {\n path: args.path,\n sideEffects: true,\n pluginName,\n };\n });\n\n onLoad({ filter: /_sentry-injection-stub/ }, () => {\n return {\n loader: 'js',\n pluginName,\n contents: staticInjectionCode.code(),\n };\n });\n }\n\n // Bundle size optimizations\n if (transformReplace) {\n const replacementStringValues: Record<string, string> = {};\n Object.entries(replacementValues).forEach(([key, value]) => {\n replacementStringValues[key] = JSON.stringify(value);\n });\n\n initialOptions.define = { ...initialOptions.define, ...replacementStringValues };\n }\n\n // Debug ID injection - requires per-entry-point unique IDs\n if (injectDebugIds) {\n // `setup` runs once per context, `onStart` once per build, so a\n // rebuild wraps the entry points again.\n onStart(() => debugIdWrappedPaths.clear());\n\n // The proxy module re-exports `OriginalModule.default` statically so downstream bundlers can tree-shake it,\n // but esbuild warns about that access when the entry point has no default export.\n initialOptions.logOverride = { 'import-is-undefined': 'silent', ...initialOptions.logOverride };\n\n if (!initialOptions.bundle) {\n logger.warn(\n 'The Sentry esbuild plugin only supports esbuild with `bundle: true` being set in the esbuild build options. Esbuild will probably crash now. Sorry about that. If you need to upload sourcemaps without `bundle: true`, it is recommended to use Sentry CLI instead: https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/cli/',\n );\n }\n\n // Wrap entry points to inject debug IDs\n onResolve({ filter: /.*/ }, args => {\n if (args.kind !== 'entry-point') {\n return;\n }\n\n // Skip injecting debug IDs into modules specified in the esbuild `inject` option\n // since they're already part of the entry points\n if (initialOptions.inject?.includes(args.path)) {\n return;\n }\n\n const resolvedPath = path.isAbsolute(args.path) ? args.path : path.join(args.resolveDir, args.path);\n\n // Skip injecting debug IDs into paths that have already been wrapped\n if (debugIdWrappedPaths.has(resolvedPath)) {\n return;\n }\n debugIdWrappedPaths.add(resolvedPath);\n\n return {\n pluginName,\n path: resolvedPath,\n pluginData: {\n isDebugIdProxy: true,\n originalPath: args.path,\n originalResolveDir: args.resolveDir,\n },\n // We need to add a suffix here, otherwise esbuild will mark the entrypoint as resolved and won't traverse\n // the module tree any further down past the proxy module because we're essentially creating a dependency\n // loop back to the proxy module.\n // By setting a suffix we're telling esbuild that the entrypoint and proxy module are two different things,\n // making it re-resolve the entrypoint when it is imported from the proxy module.\n // Super confusing? Yes. Works? Apparently... Let's see.\n suffix: '?sentryDebugIdProxy=true',\n };\n });\n\n onLoad({ filter: /.*/ }, args => {\n if (!(args.pluginData as { isDebugIdProxy?: boolean })?.isDebugIdProxy) {\n return null;\n }\n\n const originalPath = (args.pluginData as { originalPath: string }).originalPath;\n const originalResolveDir = (args.pluginData as { originalResolveDir: string }).originalResolveDir;\n\n return {\n loader: 'js',\n pluginName,\n contents: `\n import \"_sentry-debug-id-injection-stub\";\n import * as OriginalModule from ${stringifyForCodeInjection(originalPath)};\n export default OriginalModule.default;\n export * from ${stringifyForCodeInjection(originalPath)};`,\n resolveDir: originalResolveDir,\n };\n });\n\n onResolve({ filter: /_sentry-debug-id-injection-stub/ }, args => {\n return {\n path: args.path,\n sideEffects: true,\n pluginName,\n namespace: 'sentry-debug-id-stub',\n suffix: `?sentry-module-id=${randomUUID()}`,\n };\n });\n\n onLoad({ filter: /_sentry-debug-id-injection-stub/, namespace: 'sentry-debug-id-stub' }, () => {\n return {\n loader: 'js',\n pluginName,\n contents: getDebugIdSnippet(randomUUID()).code(),\n };\n });\n }\n\n // With `write: false` nothing reaches the disk, so nothing can be uploaded or deleted.\n const sourceMapKind = sourceMapKindFromEsbuildSetting(initialOptions.sourcemap);\n const sourceMapDecision: SourceMapDecision =\n initialOptions.write === false\n ? { enableHidden: false, deleteAfterUpload: false }\n : sentryBuildPluginManager.sourceMaps.decide(sourceMapKind);\n if (sourceMapDecision.enableHidden) {\n initialOptions.sourcemap = 'external';\n }\n\n // Create release and optionally upload\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n\n initialOptions.metafile = true;\n onEnd(async result => {\n // The metafile lists outputs relative to `absWorkingDir`, not to the process.\n const outputDir = initialOptions.absWorkingDir ?? process.cwd();\n const buildArtifacts = result.metafile\n ? Object.keys(result.metafile.outputs).map(output => path.resolve(outputDir, output))\n : [];\n const { sourceMaps } = sentryBuildPluginManager;\n const allMaps = buildArtifacts.filter(artifact => artifact.endsWith('.map'));\n\n try {\n await sentryBuildPluginManager.createRelease();\n\n const deleteWithoutUpload = sourceMapDecision.deleteAfterUpload && !sourceMaps.uploadPossible;\n if (stampEmittedFiles) {\n if (initialOptions.write === false) {\n logger.debug('Build output is not written to disk. Skipping debug ID injection into build artifacts.');\n } else {\n // esbuild has no hook to modify outputs before they are written, so the emitted\n // artifacts get stamped on disk.\n await Promise.all(\n buildArtifacts\n .filter(isJsFile)\n .map(bundle => addDebugIdToEmittedArtifacts(bundle, logger, options.sourcemaps?.resolveSourceMap)),\n );\n }\n } else if (uploadEnabled) {\n // The upload globs the paths, and glob reads backslashes as escapes.\n // When no upload can run, this logs why.\n const { uploaded, uploadedSourceMapPaths } = await upload(\n buildArtifacts.map(artifact => artifact.split(path.sep).join('/')),\n );\n\n // esbuild writes before `onEnd` runs, so the maps are deleted from disk\n // afterwards instead of being dropped from the output like in other bundlers.\n // A map the plugin turned on never stays in the output. A map the user\n // enabled is only deleted once it was uploaded, unless `sourcemaps.delete`\n // asks for it, which does not depend on the upload.\n if (sourceMapDecision.deleteAfterUpload && !deleteWithoutUpload) {\n const mapsToDelete = sourceMapDecision.removeAllSourceMaps ? allMaps : uploadedSourceMapPaths;\n\n if (uploaded || options.sourcemaps?.delete === true) {\n await sourceMaps.deleteFromOutput(mapsToDelete);\n } else if (mapsToDelete.length > 0) {\n logger.error('The source maps were not uploaded, so they stay in the build output.');\n }\n }\n }\n\n if (deleteWithoutUpload) {\n const bundleOf = (map: string): string => map.slice(0, -'.map'.length);\n const isUploaded = (map: string): boolean =>\n isJsFile(bundleOf(map)) && sourceMaps.shouldUpload(bundleOf(map));\n await sourceMaps.deleteFromOutput(\n sourceMapDecision.removeAllSourceMaps ? allMaps : allMaps.filter(isUploaded),\n );\n }\n } catch (error) {\n // esbuild already wrote the maps, and `sourcemaps.delete: true` also\n // applies when the release or upload step fails.\n if (options.sourcemaps?.delete === true && sourceMapDecision.deleteAfterUpload) {\n await sourceMaps.deleteFromOutput(allMaps);\n }\n throw error;\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n });\n },\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport default sentryEsbuildPlugin;\nexport type { Options as SentryEsbuildPluginOptions } from '../core';\n"],"mappings":";;;;;;;;;;;;AAmEA,SAAS,gCAAgC,SAAiD;CACxF,QAAQ,SAAR;EACE,KAAK,KAAA,GACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK;EACL,KAAK,QACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAgBA,SAAS,yBAA6C;CACpD,IAAI;EAMF,OAHY,cAAc,YAAY,GACpB,CAAC,CAAC,SAEP,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC;CACrC,QAAQ,CAER;AAGF;AAEA,MAAM,aAAa;AAGnB,SAAgB,oBAAoB,cAA+B,CAAC,GAAQ;CAC1E,MAAM,2BAA2B,+BAA+B,aAAa;EAC3E,cAAc,YAAY,cAAc,wBAAwB,IAAI,WAAW;EAC/E,WAAW;EACX,uBAAuB,uBAAuB;CAChD,CAAC;CAED,MAAM,EACJ,QACA,mBAAmB,SACnB,yCAAyC,mBACzC,gBACA,qCACE;CAEJ,IA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AAM,eAAe,kBAAkB,sBAAsB,UAAU;OAEvE,IAAI,YAAY,QAAQ,YAAY,WAAW,MAC7C,MAAM,WAAW,iBAAiB,YAAY;YACzC,IAAI,aAAa,SAAS,GAC/B,OAAO,MAAM,sEAAsE;MAEvF;KACF;KAEA,IAAI,qBAAqB;MACvB,MAAM,YAAY,QAAwB,IAAI,MAAM,GAAG,EAAc;MACrE,MAAM,cAAc,QAClB,SAAS,SAAS,GAAG,CAAC,KAAK,WAAW,aAAa,SAAS,GAAG,CAAC;MAClE,MAAM,WAAW,iBACf,kBAAkB,sBAAsB,UAAU,QAAQ,OAAO,UAAU,CAC7E;KACF;IACF,SAAS,OAAO;KAGd,IAAI,QAAQ,YAAY,WAAW,QAAQ,kBAAkB,mBAC3D,MAAM,WAAW,iBAAiB,OAAO;KAE3C,MAAM;IACR,UAAU;KACR,qCAAqC;KACrC,MAAM,yBAAyB,gBAAgB;IACjD;GACF,CAAC;EACH;CACF;AACF"}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"11.
|
|
1
|
+
{"type":"module","version":"11.15.0","sideEffects":["./sentry-release-injection-file.js","./sentry-esbuild-debugid-injection-file.js"]}
|