@sentry/bundler-plugins 11.0.0-alpha.0 → 11.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/core/build-plugin-manager.js +43 -72
- package/build/cjs/core/build-plugin-manager.js.map +1 -1
- package/build/cjs/core/cli.js +134 -0
- package/build/cjs/core/cli.js.map +1 -0
- package/build/cjs/core/index.js +1 -23
- package/build/cjs/core/index.js.map +1 -1
- package/build/cjs/core/options-mapping.js.map +1 -1
- package/build/cjs/core/sentry/telemetry.js +3 -23
- package/build/cjs/core/sentry/telemetry.js.map +1 -1
- package/build/cjs/core/utils.js +0 -6
- package/build/cjs/core/utils.js.map +1 -1
- package/build/cjs/core/version.js +1 -1
- package/build/cjs/core/version.js.map +1 -1
- package/build/cjs/esbuild/index.js +0 -1
- package/build/cjs/esbuild/index.js.map +1 -1
- package/build/cjs/rollup/index.js +0 -1
- package/build/cjs/rollup/index.js.map +1 -1
- package/build/cjs/vite/index.js +2 -4
- package/build/cjs/vite/index.js.map +1 -1
- package/build/cjs/webpack/index.js +0 -2
- package/build/cjs/webpack/index.js.map +1 -1
- package/build/cjs/webpack/webpack5.js +0 -2
- package/build/cjs/webpack/webpack5.js.map +1 -1
- package/build/esm/core/build-plugin-manager.js +45 -71
- package/build/esm/core/build-plugin-manager.js.map +1 -1
- package/build/esm/core/cli.js +132 -0
- package/build/esm/core/cli.js.map +1 -0
- package/build/esm/core/index.js +2 -6
- package/build/esm/core/index.js.map +1 -1
- package/build/esm/core/options-mapping.js.map +1 -1
- package/build/esm/core/sentry/telemetry.js +3 -19
- package/build/esm/core/sentry/telemetry.js.map +1 -1
- package/build/esm/core/utils.js +1 -6
- 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 +0 -1
- package/build/esm/esbuild/index.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/rollup/index.js +0 -1
- package/build/esm/rollup/index.js.map +1 -1
- package/build/esm/vite/index.js +0 -1
- package/build/esm/vite/index.js.map +1 -1
- package/build/esm/webpack/index.js +0 -1
- package/build/esm/webpack/index.js.map +1 -1
- package/build/esm/webpack/webpack5.js +0 -1
- package/build/esm/webpack/webpack5.js.map +1 -1
- package/build/types/core/build-plugin-manager.d.ts.map +1 -1
- package/build/types/core/cli.d.ts +50 -0
- package/build/types/core/cli.d.ts.map +1 -0
- package/build/types/core/index.d.ts +0 -6
- package/build/types/core/index.d.ts.map +1 -1
- package/build/types/core/options-mapping.d.ts +1 -0
- 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/types.d.ts +17 -12
- package/build/types/core/types.d.ts.map +1 -1
- package/build/types/core/utils.d.ts +0 -6
- 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 +0 -1
- package/build/types/esbuild/index.d.ts.map +1 -1
- package/build/types/rollup/index.d.ts +0 -1
- package/build/types/rollup/index.d.ts.map +1 -1
- package/build/types/vite/index.d.ts +0 -1
- package/build/types/vite/index.d.ts.map +1 -1
- package/build/types/webpack/index.d.ts +0 -1
- package/build/types/webpack/index.d.ts.map +1 -1
- package/build/types/webpack/webpack5.d.ts +0 -1
- package/build/types/webpack/webpack5.d.ts.map +1 -1
- package/package.json +5 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/rollup/index.ts"],"sourcesContent":["import type { Options } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n isJsFile,\n shouldSkipCodeInjection,\n getDebugIdSnippet,\n stringToUUID,\n COMMENT_USE_STRICT_REGEX,\n createDebugIdUploadFunction,\n globFiles,\n createComponentNameAnnotateHooks,\n replaceBooleanFlagsInCode,\n CodeInjection,\n} from '../core';\nimport type {\n ComponentAnnotationTransformMeta,\n ComponentAnnotationTransformResult,\n} from '../core/component-annotation-vite';\nimport type { SourceMap } from 'magic-string';\nimport MagicString from 'magic-string';\nimport * as path from 'node:path';\nimport { createRequire } from 'node:module';\n\n// The subset of Rollup's `TransformResult` that this plugin's `transform`\n// hook actually returns. Defined locally instead of imported from `rollup`\n// because `rollup` is an optional dependency.\ntype TransformResult = { code: string; map?: SourceMap | string | { mappings: string } | null } | null | undefined;\n\ntype ViteModule = {\n parseAstAsync?: (code: string, options: { lang: 'jsx' | 'tsx' }) => Promise<unknown>;\n};\n\ntype ViteParseAstAsync = NonNullable<ViteModule['parseAstAsync']>;\ntype ViteAnnotationHooks = {\n transform(\n code: string,\n id: string,\n meta?: ComponentAnnotationTransformMeta,\n ): Promise<ComponentAnnotationTransformResult>;\n};\n\nlet viteParseAstAsyncPromise: Promise<ViteParseAstAsync | null> | undefined;\n\nconst JS_MODULE_ID_FILTER = /\\.[cm]?[jt]sx?(?:[?#].*)?$/;\n\nfunction hasExistingDebugID(code: string): boolean {\n // Check if a debug ID has already been injected to avoid duplicate injection (e.g. by another plugin or Sentry CLI)\n const chunkStartSnippet = code.slice(0, 6000);\n const chunkEndSnippet = code.slice(-500);\n\n if (chunkStartSnippet.includes('_sentryDebugIdIdentifier') || chunkEndSnippet.includes('//# debugId=')) {\n return true; // Debug ID already present, skip injection\n }\n\n return false;\n}\n\nfunction getRollupMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const rollup = req('rollup') as { VERSION?: string };\n return rollup.VERSION?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nfunction getViteParseAstAsync(): Promise<ViteParseAstAsync | null> {\n if (!viteParseAstAsyncPromise) {\n viteParseAstAsyncPromise = Promise.resolve()\n .then(async () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Vite is an optional runtime peer for this package\n const viteModule = createRequire(import.meta.url)('vite') as ViteModule;\n\n if (typeof viteModule.parseAstAsync !== 'function') {\n return null;\n }\n\n try {\n await viteModule.parseAstAsync('const x = <div />;', { lang: 'tsx' });\n } catch {\n return null;\n }\n\n return viteModule.parseAstAsync;\n })\n .catch(() => null);\n }\n\n return viteParseAstAsyncPromise;\n}\n\n/**\n * @ignore - this is the internal plugin factory function only used for the Vite plugin!\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function _rollupPluginInternal(\n userOptions: Options = {},\n buildTool: 'rollup' | 'vite',\n buildToolMajorVersion?: string,\n) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[sentry-${buildTool}-plugin]`,\n buildTool,\n buildToolMajorVersion: buildToolMajorVersion || getRollupMajorVersion(),\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-noop-plugin',\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 freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\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 const transformAnnotations = options.reactComponentAnnotation?.enabled\n ? createComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n !!options.reactComponentAnnotation?._experimentalInjectIntoHtml,\n )\n : undefined;\n const transformViteAnnotations =\n options.reactComponentAnnotation?.enabled &&\n buildTool === 'vite' &&\n buildToolMajorVersion === '8' &&\n !options.reactComponentAnnotation?._experimentalInjectIntoHtml\n ? (() => {\n let viteAnnotationHooksPromise: Promise<ViteAnnotationHooks> | undefined;\n\n return {\n transform(code: string, id: string, meta?: ComponentAnnotationTransformMeta) {\n if (!viteAnnotationHooksPromise) {\n viteAnnotationHooksPromise = import('../core/component-annotation-vite').then(\n ({ createViteComponentNameAnnotateHooks }) =>\n createViteComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n getViteParseAstAsync,\n ),\n );\n }\n\n return viteAnnotationHooksPromise.then(hooks => hooks.transform(code, id, meta));\n },\n };\n })()\n : undefined;\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n const shouldTransform = transformAnnotations || transformReplace;\n\n function buildStart(): void {\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n }\n\n async function transform(\n code: string,\n id: string,\n meta?: ComponentAnnotationTransformMeta,\n ): Promise<TransformResult> {\n // Component annotations are only in user code and boolean flag replacements are\n // only in Sentry code. If we successfully add annotations, we can return early.\n let shouldRunBabelAnnotations = true;\n\n if (transformViteAnnotations?.transform) {\n const result = await transformViteAnnotations.transform(code, id, meta);\n if (result) {\n return result;\n }\n\n if (result === null) {\n shouldRunBabelAnnotations = false;\n }\n }\n\n if (shouldRunBabelAnnotations && transformAnnotations?.transform) {\n const result = await transformAnnotations.transform(code, id);\n if (result) {\n return result;\n }\n }\n\n if (transformReplace) {\n return replaceBooleanFlagsInCode(code, replacementValues);\n }\n\n return null;\n }\n\n function renderChunk(\n code: string,\n chunk: { fileName: string; facadeModuleId?: string | null },\n _?: unknown,\n meta?: { magicString?: MagicString },\n ): {\n code: string;\n map?: SourceMap;\n } | null {\n if (!isJsFile(chunk.fileName)) {\n return null; // returning null means not modifying the chunk at all\n }\n\n // Skip empty chunks and HTML facade chunks (Vite MPA)\n if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {\n return null;\n }\n\n const injectCode = staticInjectionCode.clone();\n\n if (sourcemapsEnabled && !hasExistingDebugID(code)) {\n const debugId = stringToUUID(code); // generate a deterministic debug ID\n injectCode.append(getDebugIdSnippet(debugId));\n }\n\n if (injectCode.isEmpty()) {\n return null;\n }\n\n const ms = meta?.magicString || new MagicString(code, { filename: chunk.fileName });\n const match = code.match(COMMENT_USE_STRICT_REGEX)?.[0];\n\n if (match) {\n // Add injected code after any comments or \"use strict\" at the beginning of the bundle.\n ms.appendLeft(match.length, injectCode.code());\n } else {\n // ms.replace() doesn't work when there is an empty string match (which happens if\n // there is neither, a comment, nor a \"use strict\" at the top of the chunk) so we\n // need this special case here.\n ms.prepend(injectCode.code());\n }\n\n // Rolldown can pass a native MagicString instance in meta.magicString\n // https://rolldown.rs/in-depth/native-magic-string#usage-examples\n if (ms?.constructor?.name === 'BindingMagicString') {\n // Rolldown docs say to return the magic string instance directly in this case\n return { code: ms as unknown as string };\n }\n\n return {\n code: ms.toString(),\n map: ms.generateMap({ file: chunk.fileName, hires: 'boundary' as unknown as undefined }),\n };\n }\n\n async function writeBundle(\n outputOptions: { dir?: string; file?: string },\n bundle: { [fileName: string]: unknown },\n ): Promise<void> {\n try {\n await sentryBuildPluginManager.createRelease();\n\n if (sourcemapsEnabled && options.sourcemaps?.disable !== 'disable-upload') {\n if (outputOptions.dir) {\n const outputDir = outputOptions.dir;\n const JS_AND_MAP_PATTERNS = [\n '/**/*.js',\n '/**/*.mjs',\n '/**/*.cjs',\n '/**/*.js.map',\n '/**/*.mjs.map',\n '/**/*.cjs.map',\n ].map(q => `${q}?(\\\\?*)?(#*)`); // We want to allow query and hash strings at the end of files\n const buildArtifacts = await globFiles(JS_AND_MAP_PATTERNS, { root: outputDir });\n await upload(buildArtifacts);\n } else if (outputOptions.file) {\n await upload([outputOptions.file]);\n } else {\n const buildArtifacts = Object.keys(bundle).map(asset => path.join(path.resolve(), asset));\n await upload(buildArtifacts);\n }\n }\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n }\n\n const name = `sentry-${buildTool}-plugin`;\n\n if (shouldTransform) {\n const transformHook =\n buildTool === 'vite'\n ? {\n filter: { id: JS_MODULE_ID_FILTER },\n handler: transform,\n }\n : transform;\n\n return {\n name,\n buildStart,\n transform: transformHook,\n renderChunk,\n writeBundle,\n };\n }\n\n return {\n name,\n buildStart,\n renderChunk,\n writeBundle,\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-explicit-any\nexport function sentryRollupPlugin(userOptions: Options = {}): any {\n // We return an array here so we don't break backwards compatibility with what\n // unplugin used to return\n return [_rollupPluginInternal(userOptions, 'rollup')];\n}\n\nexport type { Options as SentryRollupPluginOptions } from '../core';\nexport { sentryCliBinaryExists } from '../core';\n"],"names":["createRequire","createSentryBuildPluginManager","createDebugIdUploadFunction","CodeInjection","generateReleaseInjectorCode","generateModuleMetadataInjectorCode","createComponentNameAnnotateHooks","replaceBooleanFlagsInCode","isJsFile","shouldSkipCodeInjection","stringToUUID","getDebugIdSnippet","MagicString","COMMENT_USE_STRICT_REGEX","globFiles","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,IAAI,wBAAA;AAEJ,MAAM,mBAAA,GAAsB,4BAAA;AAE5B,SAAS,mBAAmB,IAAA,EAAuB;AAEjD,EAAA,MAAM,iBAAA,GAAoB,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,GAAI,CAAA;AAC5C,EAAA,MAAM,eAAA,GAAkB,IAAA,CAAK,KAAA,CAAM,IAAI,CAAA;AAEvC,E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AAEA,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,GACF;AACF;AAGO,SAAS,kBAAA,CAAmB,WAAA,GAAuB,EAAC,EAAQ;AAGjE,EAAA,OAAO,CAAC,qBAAA,CAAsB,WAAA,EAAa,QAAQ,CAAC,CAAA;AACtD;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/rollup/index.ts"],"sourcesContent":["import type { Options } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n isJsFile,\n shouldSkipCodeInjection,\n getDebugIdSnippet,\n stringToUUID,\n COMMENT_USE_STRICT_REGEX,\n createDebugIdUploadFunction,\n globFiles,\n createComponentNameAnnotateHooks,\n replaceBooleanFlagsInCode,\n CodeInjection,\n} from '../core';\nimport type {\n ComponentAnnotationTransformMeta,\n ComponentAnnotationTransformResult,\n} from '../core/component-annotation-vite';\nimport type { SourceMap } from 'magic-string';\nimport MagicString from 'magic-string';\nimport * as path from 'node:path';\nimport { createRequire } from 'node:module';\n\n// The subset of Rollup's `TransformResult` that this plugin's `transform`\n// hook actually returns. Defined locally instead of imported from `rollup`\n// because `rollup` is an optional dependency.\ntype TransformResult = { code: string; map?: SourceMap | string | { mappings: string } | null } | null | undefined;\n\ntype ViteModule = {\n parseAstAsync?: (code: string, options: { lang: 'jsx' | 'tsx' }) => Promise<unknown>;\n};\n\ntype ViteParseAstAsync = NonNullable<ViteModule['parseAstAsync']>;\ntype ViteAnnotationHooks = {\n transform(\n code: string,\n id: string,\n meta?: ComponentAnnotationTransformMeta,\n ): Promise<ComponentAnnotationTransformResult>;\n};\n\nlet viteParseAstAsyncPromise: Promise<ViteParseAstAsync | null> | undefined;\n\nconst JS_MODULE_ID_FILTER = /\\.[cm]?[jt]sx?(?:[?#].*)?$/;\n\nfunction hasExistingDebugID(code: string): boolean {\n // Check if a debug ID has already been injected to avoid duplicate injection (e.g. by another plugin or Sentry CLI)\n const chunkStartSnippet = code.slice(0, 6000);\n const chunkEndSnippet = code.slice(-500);\n\n if (chunkStartSnippet.includes('_sentryDebugIdIdentifier') || chunkEndSnippet.includes('//# debugId=')) {\n return true; // Debug ID already present, skip injection\n }\n\n return false;\n}\n\nfunction getRollupMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const rollup = req('rollup') as { VERSION?: string };\n return rollup.VERSION?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nfunction getViteParseAstAsync(): Promise<ViteParseAstAsync | null> {\n if (!viteParseAstAsyncPromise) {\n viteParseAstAsyncPromise = Promise.resolve()\n .then(async () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Vite is an optional runtime peer for this package\n const viteModule = createRequire(import.meta.url)('vite') as ViteModule;\n\n if (typeof viteModule.parseAstAsync !== 'function') {\n return null;\n }\n\n try {\n await viteModule.parseAstAsync('const x = <div />;', { lang: 'tsx' });\n } catch {\n return null;\n }\n\n return viteModule.parseAstAsync;\n })\n .catch(() => null);\n }\n\n return viteParseAstAsyncPromise;\n}\n\n/**\n * @ignore - this is the internal plugin factory function only used for the Vite plugin!\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function _rollupPluginInternal(\n userOptions: Options = {},\n buildTool: 'rollup' | 'vite',\n buildToolMajorVersion?: string,\n) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[sentry-${buildTool}-plugin]`,\n buildTool,\n buildToolMajorVersion: buildToolMajorVersion || getRollupMajorVersion(),\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-noop-plugin',\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 freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\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 const transformAnnotations = options.reactComponentAnnotation?.enabled\n ? createComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n !!options.reactComponentAnnotation?._experimentalInjectIntoHtml,\n )\n : undefined;\n const transformViteAnnotations =\n options.reactComponentAnnotation?.enabled &&\n buildTool === 'vite' &&\n buildToolMajorVersion === '8' &&\n !options.reactComponentAnnotation?._experimentalInjectIntoHtml\n ? (() => {\n let viteAnnotationHooksPromise: Promise<ViteAnnotationHooks> | undefined;\n\n return {\n transform(code: string, id: string, meta?: ComponentAnnotationTransformMeta) {\n if (!viteAnnotationHooksPromise) {\n viteAnnotationHooksPromise = import('../core/component-annotation-vite').then(\n ({ createViteComponentNameAnnotateHooks }) =>\n createViteComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n getViteParseAstAsync,\n ),\n );\n }\n\n return viteAnnotationHooksPromise.then(hooks => hooks.transform(code, id, meta));\n },\n };\n })()\n : undefined;\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n const shouldTransform = transformAnnotations || transformReplace;\n\n function buildStart(): void {\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n }\n\n async function transform(\n code: string,\n id: string,\n meta?: ComponentAnnotationTransformMeta,\n ): Promise<TransformResult> {\n // Component annotations are only in user code and boolean flag replacements are\n // only in Sentry code. If we successfully add annotations, we can return early.\n let shouldRunBabelAnnotations = true;\n\n if (transformViteAnnotations?.transform) {\n const result = await transformViteAnnotations.transform(code, id, meta);\n if (result) {\n return result;\n }\n\n if (result === null) {\n shouldRunBabelAnnotations = false;\n }\n }\n\n if (shouldRunBabelAnnotations && transformAnnotations?.transform) {\n const result = await transformAnnotations.transform(code, id);\n if (result) {\n return result;\n }\n }\n\n if (transformReplace) {\n return replaceBooleanFlagsInCode(code, replacementValues);\n }\n\n return null;\n }\n\n function renderChunk(\n code: string,\n chunk: { fileName: string; facadeModuleId?: string | null },\n _?: unknown,\n meta?: { magicString?: MagicString },\n ): {\n code: string;\n map?: SourceMap;\n } | null {\n if (!isJsFile(chunk.fileName)) {\n return null; // returning null means not modifying the chunk at all\n }\n\n // Skip empty chunks and HTML facade chunks (Vite MPA)\n if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {\n return null;\n }\n\n const injectCode = staticInjectionCode.clone();\n\n if (sourcemapsEnabled && !hasExistingDebugID(code)) {\n const debugId = stringToUUID(code); // generate a deterministic debug ID\n injectCode.append(getDebugIdSnippet(debugId));\n }\n\n if (injectCode.isEmpty()) {\n return null;\n }\n\n const ms = meta?.magicString || new MagicString(code, { filename: chunk.fileName });\n const match = code.match(COMMENT_USE_STRICT_REGEX)?.[0];\n\n if (match) {\n // Add injected code after any comments or \"use strict\" at the beginning of the bundle.\n ms.appendLeft(match.length, injectCode.code());\n } else {\n // ms.replace() doesn't work when there is an empty string match (which happens if\n // there is neither, a comment, nor a \"use strict\" at the top of the chunk) so we\n // need this special case here.\n ms.prepend(injectCode.code());\n }\n\n // Rolldown can pass a native MagicString instance in meta.magicString\n // https://rolldown.rs/in-depth/native-magic-string#usage-examples\n if (ms?.constructor?.name === 'BindingMagicString') {\n // Rolldown docs say to return the magic string instance directly in this case\n return { code: ms as unknown as string };\n }\n\n return {\n code: ms.toString(),\n map: ms.generateMap({ file: chunk.fileName, hires: 'boundary' as unknown as undefined }),\n };\n }\n\n async function writeBundle(\n outputOptions: { dir?: string; file?: string },\n bundle: { [fileName: string]: unknown },\n ): Promise<void> {\n try {\n await sentryBuildPluginManager.createRelease();\n\n if (sourcemapsEnabled && options.sourcemaps?.disable !== 'disable-upload') {\n if (outputOptions.dir) {\n const outputDir = outputOptions.dir;\n const JS_AND_MAP_PATTERNS = [\n '/**/*.js',\n '/**/*.mjs',\n '/**/*.cjs',\n '/**/*.js.map',\n '/**/*.mjs.map',\n '/**/*.cjs.map',\n ].map(q => `${q}?(\\\\?*)?(#*)`); // We want to allow query and hash strings at the end of files\n const buildArtifacts = await globFiles(JS_AND_MAP_PATTERNS, { root: outputDir });\n await upload(buildArtifacts);\n } else if (outputOptions.file) {\n await upload([outputOptions.file]);\n } else {\n const buildArtifacts = Object.keys(bundle).map(asset => path.join(path.resolve(), asset));\n await upload(buildArtifacts);\n }\n }\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n }\n\n const name = `sentry-${buildTool}-plugin`;\n\n if (shouldTransform) {\n const transformHook =\n buildTool === 'vite'\n ? {\n filter: { id: JS_MODULE_ID_FILTER },\n handler: transform,\n }\n : transform;\n\n return {\n name,\n buildStart,\n transform: transformHook,\n renderChunk,\n writeBundle,\n };\n }\n\n return {\n name,\n buildStart,\n renderChunk,\n writeBundle,\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-explicit-any\nexport function sentryRollupPlugin(userOptions: Options = {}): any {\n // We return an array here so we don't break backwards compatibility with what\n // unplugin used to return\n return [_rollupPluginInternal(userOptions, 'rollup')];\n}\n\nexport type { Options as SentryRollupPluginOptions } from '../core';\n"],"names":["createRequire","createSentryBuildPluginManager","createDebugIdUploadFunction","CodeInjection","generateReleaseInjectorCode","generateModuleMetadataInjectorCode","createComponentNameAnnotateHooks","replaceBooleanFlagsInCode","isJsFile","shouldSkipCodeInjection","stringToUUID","getDebugIdSnippet","MagicString","COMMENT_USE_STRICT_REGEX","globFiles","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,IAAI,wBAAA;AAEJ,MAAM,mBAAA,GAAsB,4BAAA;AAE5B,SAAS,mBAAmB,IAAA,EAAuB;AAEjD,EAAA,MAAM,iBAAA,GAAoB,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,GAAI,CAAA;AAC5C,EAAA,MAAM,eAAA,GAAkB,IAAA,CAAK,KAAA,CAAM,IAAI,CAAA;AAEvC,EAAA,IAAI,kBAAkB,QAAA,CAAS,0BAA0B,KAAK,eAAA,CAAgB,QAAA,CAAS,cAAc,CAAA,EAAG;AACtG,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,KAAA;AACT;AAEA,SAAS,qBAAA,GAA4C;AACnD,EAAA,IAAI;AAGF,IAAA,MAAM,GAAA,GAAMA,yBAAA,CAAc,iQAAe,CAAA;AACzC,IAAA,MAAM,MAAA,GAAS,IAAI,QAAQ,CAAA;AAC3B,IAAA,OAAO,MAAA,CAAO,OAAA,EAAS,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AAAA,EACrC,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,oBAAA,GAA0D;AACjE,EAAA,IAAI,CAAC,wBAAA,EAA0B;AAC7B,IAAA,wBAAA,GAA2B,OAAA,CAAQ,OAAA,EAAQ,CACxC,IAAA,CAAK,YAAY;AAGhB,MAAA,MAAM,UAAA,GAAaA,yBAAA,CAAc,iQAAe,EAAE,MAAM,CAAA;AAExD,MAAA,IAAI,OAAO,UAAA,CAA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AAM,OAAO,cAAc,CAAA;AAAA,QAC7B;AAAA,MACF;AAAA,IACF,CAAA,SAAE;AACA,MAAA,oCAAA,EAAqC;AACrC,MAAA,MAAM,yBAAyB,eAAA,EAAgB;AAAA,IACjD;AAAA,EACF;AAEA,EAAA,MAAM,IAAA,GAAO,UAAU,SAAS,CAAA,OAAA,CAAA;AAEhC,EAAA,IAAI,eAAA,EAAiB;AACnB,IAAA,MAAM,aAAA,GACJ,cAAc,MAAA,GACV;AAAA,MACE,MAAA,EAAQ,EAAE,EAAA,EAAI,mBAAA,EAAoB;AAAA,MAClC,OAAA,EAAS;AAAA,KACX,GACA,SAAA;AAEN,IAAA,OAAO;AAAA,MACL,IAAA;AAAA,MACA,UAAA;AAAA,MACA,SAAA,EAAW,aAAA;AAAA,MACX,WAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,GACF;AACF;AAGO,SAAS,kBAAA,CAAmB,WAAA,GAAuB,EAAC,EAAQ;AAGjE,EAAA,OAAO,CAAC,qBAAA,CAAsB,WAAA,EAAa,QAAQ,CAAC,CAAA;AACtD;;;;;"}
|
package/build/cjs/vite/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
-
const index
|
|
3
|
+
const index = require('../rollup/index.js');
|
|
4
4
|
const node_module = require('node:module');
|
|
5
|
-
const index = require('../core/index.js');
|
|
6
5
|
|
|
7
6
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
8
7
|
function getViteMajorVersion() {
|
|
@@ -18,11 +17,10 @@ const sentryVitePlugin = (options) => {
|
|
|
18
17
|
return [
|
|
19
18
|
{
|
|
20
19
|
enforce: "pre",
|
|
21
|
-
...index
|
|
20
|
+
...index._rollupPluginInternal(options, "vite", getViteMajorVersion())
|
|
22
21
|
}
|
|
23
22
|
];
|
|
24
23
|
};
|
|
25
24
|
|
|
26
|
-
exports.sentryCliBinaryExists = index.sentryCliBinaryExists;
|
|
27
25
|
exports.sentryVitePlugin = sentryVitePlugin;
|
|
28
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/vite/index.ts"],"sourcesContent":["import type { SentryRollupPluginOptions } from '../rollup';\nimport { _rollupPluginInternal } from '../rollup';\nimport { createRequire } from 'node:module';\n\ninterface SentryVitePlugin {\n name: string;\n enforce: 'pre';\n}\n\nfunction getViteMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const vite = req('vite') as { version?: string };\n return vite.version?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nexport const sentryVitePlugin = (options?: SentryRollupPluginOptions): SentryVitePlugin[] => {\n return [\n {\n enforce: 'pre',\n ..._rollupPluginInternal(options, 'vite', getViteMajorVersion()),\n },\n ];\n};\n\nexport type { Options as SentryVitePluginOptions } from '../core';\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/vite/index.ts"],"sourcesContent":["import type { SentryRollupPluginOptions } from '../rollup';\nimport { _rollupPluginInternal } from '../rollup';\nimport { createRequire } from 'node:module';\n\ninterface SentryVitePlugin {\n name: string;\n enforce: 'pre';\n}\n\nfunction getViteMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const vite = req('vite') as { version?: string };\n return vite.version?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nexport const sentryVitePlugin = (options?: SentryRollupPluginOptions): SentryVitePlugin[] => {\n return [\n {\n enforce: 'pre',\n ..._rollupPluginInternal(options, 'vite', getViteMajorVersion()),\n },\n ];\n};\n\nexport type { Options as SentryVitePluginOptions } from '../core';\n"],"names":["createRequire","_rollupPluginInternal"],"mappings":";;;;;;AASA,SAAS,mBAAA,GAA0C;AACjD,EAAA,IAAI;AAGF,IAAA,MAAM,GAAA,GAAMA,yBAAA,CAAc,+PAAe,CAAA;AACzC,IAAA,MAAM,IAAA,GAAO,IAAI,MAAM,CAAA;AACvB,IAAA,OAAO,IAAA,CAAK,OAAA,EAAS,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AAAA,EACnC,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,OAAO,MAAA;AACT;AAEO,MAAM,gBAAA,GAAmB,CAAC,OAAA,KAA4D;AAC3F,EAAA,OAAO;AAAA,IACL;AAAA,MACE,OAAA,EAAS,KAAA;AAAA,MACT,GAAGC,2BAAA,CAAsB,OAAA,EAAS,MAAA,EAAQ,qBAAqB;AAAA;AACjE,GACF;AACF;;;;"}
|
|
@@ -2,7 +2,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
|
|
3
3
|
const webpack4and5 = require('./webpack4and5.js');
|
|
4
4
|
const node_module = require('node:module');
|
|
5
|
-
const index = require('../core/index.js');
|
|
6
5
|
|
|
7
6
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
8
7
|
function loadWebpack() {
|
|
@@ -20,6 +19,5 @@ const sentryWebpackPlugin = webpack4and5.sentryWebpackPluginFactory({
|
|
|
20
19
|
DefinePlugin
|
|
21
20
|
});
|
|
22
21
|
|
|
23
|
-
exports.sentryCliBinaryExists = index.sentryCliBinaryExists;
|
|
24
22
|
exports.sentryWebpackPlugin = sentryWebpackPlugin;
|
|
25
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/webpack/index.ts"],"sourcesContent":["import type { SentryWebpackPluginOptions } from './webpack4and5';\nimport { sentryWebpackPluginFactory } from './webpack4and5';\nimport { createRequire } from 'node:module';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype PluginClass = new (options: any) => unknown;\n\ntype WebpackModule = {\n BannerPlugin?: PluginClass;\n DefinePlugin?: PluginClass;\n default?: WebpackModule;\n};\n\n// `webpack` is an optional peer dependency. We require it lazily so the plugin doesn't\n// crash on load in bundlers that don't ship `webpack` (e.g. rspack) — those provide\n// the plugin classes via `compiler.webpack` at runtime instead.\nfunction loadWebpack(): WebpackModule {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore Rollup transpiles import.meta for CJS\n return createRequire(import.meta.url)('webpack') as WebpackModule;\n } catch {\n return {};\n }\n}\n\nconst webpack = loadWebpack();\nconst BannerPlugin = webpack.BannerPlugin ?? webpack.default?.BannerPlugin;\nconst DefinePlugin = webpack.DefinePlugin ?? webpack.default?.DefinePlugin;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const sentryWebpackPlugin: (options?: SentryWebpackPluginOptions) => any = sentryWebpackPluginFactory({\n BannerPlugin,\n DefinePlugin,\n});\n\nexport
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/webpack/index.ts"],"sourcesContent":["import type { SentryWebpackPluginOptions } from './webpack4and5';\nimport { sentryWebpackPluginFactory } from './webpack4and5';\nimport { createRequire } from 'node:module';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype PluginClass = new (options: any) => unknown;\n\ntype WebpackModule = {\n BannerPlugin?: PluginClass;\n DefinePlugin?: PluginClass;\n default?: WebpackModule;\n};\n\n// `webpack` is an optional peer dependency. We require it lazily so the plugin doesn't\n// crash on load in bundlers that don't ship `webpack` (e.g. rspack) — those provide\n// the plugin classes via `compiler.webpack` at runtime instead.\nfunction loadWebpack(): WebpackModule {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore Rollup transpiles import.meta for CJS\n return createRequire(import.meta.url)('webpack') as WebpackModule;\n } catch {\n return {};\n }\n}\n\nconst webpack = loadWebpack();\nconst BannerPlugin = webpack.BannerPlugin ?? webpack.default?.BannerPlugin;\nconst DefinePlugin = webpack.DefinePlugin ?? webpack.default?.DefinePlugin;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const sentryWebpackPlugin: (options?: SentryWebpackPluginOptions) => any = sentryWebpackPluginFactory({\n BannerPlugin,\n DefinePlugin,\n});\n\nexport type { SentryWebpackPluginOptions };\n"],"names":["createRequire","sentryWebpackPluginFactory"],"mappings":";;;;;;AAgBA,SAAS,WAAA,GAA6B;AACpC,EAAA,IAAI;AAGF,IAAA,OAAOA,yBAAA,CAAc,kQAAe,CAAA,CAAE,SAAS,CAAA;AAAA,EACjD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,EAAC;AAAA,EACV;AACF;AAEA,MAAM,UAAU,WAAA,EAAY;AAC5B,MAAM,YAAA,GAAe,OAAA,CAAQ,YAAA,IAAgB,OAAA,CAAQ,OAAA,EAAS,YAAA;AAC9D,MAAM,YAAA,GAAe,OAAA,CAAQ,YAAA,IAAgB,OAAA,CAAQ,OAAA,EAAS,YAAA;AAGvD,MAAM,sBAAqEC,uCAAA,CAA2B;AAAA,EAC3G,YAAA;AAAA,EACA;AACF,CAAC;;;;"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
3
|
const webpack4and5 = require('./webpack4and5.js');
|
|
4
|
-
const index = require('../core/index.js');
|
|
5
4
|
|
|
6
5
|
const createSentryWebpackPlugin = webpack4and5.sentryWebpackPluginFactory();
|
|
7
6
|
const sentryWebpackPlugin = createSentryWebpackPlugin;
|
|
8
7
|
|
|
9
|
-
exports.sentryCliBinaryExists = index.sentryCliBinaryExists;
|
|
10
8
|
exports.sentryWebpackPlugin = sentryWebpackPlugin;
|
|
11
9
|
//# sourceMappingURL=webpack5.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack5.js","sources":["../../../src/webpack/webpack5.ts"],"sourcesContent":["import type { SentryWebpackPluginOptions } from './webpack4and5';\nimport { sentryWebpackPluginFactory } from './webpack4and5';\n\nconst createSentryWebpackPlugin = sentryWebpackPluginFactory();\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const sentryWebpackPlugin: (options?: SentryWebpackPluginOptions) => any = createSentryWebpackPlugin;\n\nexport
|
|
1
|
+
{"version":3,"file":"webpack5.js","sources":["../../../src/webpack/webpack5.ts"],"sourcesContent":["import type { SentryWebpackPluginOptions } from './webpack4and5';\nimport { sentryWebpackPluginFactory } from './webpack4and5';\n\nconst createSentryWebpackPlugin = sentryWebpackPluginFactory();\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const sentryWebpackPlugin: (options?: SentryWebpackPluginOptions) => any = createSentryWebpackPlugin;\n\nexport type { SentryWebpackPluginOptions };\n"],"names":["sentryWebpackPluginFactory"],"mappings":";;;;AAGA,MAAM,4BAA4BA,uCAAA,EAA2B;AAGtD,MAAM,mBAAA,GAAqE;;;;"}
|
|
@@ -1,33 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { DEFAULT_ENVIRONMENT, makeSession, startSpan, setMeasurement, closeSession, getTraceData } from '@sentry/core';
|
|
1
|
+
import { DEFAULT_ENVIRONMENT, makeSession, startSpan, setMeasurement, closeSession } from '@sentry/core';
|
|
3
2
|
import * as dotenv from 'dotenv';
|
|
4
3
|
import * as fs from 'fs';
|
|
5
4
|
import * as os from 'os';
|
|
6
5
|
import * as path from 'path';
|
|
6
|
+
import { SentryCliAdapter } from './cli.js';
|
|
7
7
|
import { normalizeUserOptions, validateOptions } from './options-mapping.js';
|
|
8
8
|
import { createLogger } from './logger.js';
|
|
9
9
|
import { allowedToSendTelemetry, createSentryInstance, safeFlushTelemetry } from './sentry/telemetry.js';
|
|
10
|
-
import { getProjects, stripQueryAndHashFromPath,
|
|
10
|
+
import { getProjects, stripQueryAndHashFromPath, getTurborepoEnvPassthroughWarning, arrayify } from './utils.js';
|
|
11
11
|
import { prepareBundleForDebugIdUpload, defaultRewriteSourcesHook } from './debug-id-upload.js';
|
|
12
12
|
import { globFiles } from './glob.js';
|
|
13
13
|
import { LIB_VERSION } from './version.js';
|
|
14
14
|
|
|
15
15
|
const _deployedReleases = /* @__PURE__ */ new Set();
|
|
16
|
-
function createCliInstance(options) {
|
|
17
|
-
return new SentryCli(null, {
|
|
18
|
-
authToken: options.authToken,
|
|
19
|
-
org: options.org,
|
|
20
|
-
// Default to the first project if multiple projects are specified
|
|
21
|
-
project: getProjects(options.project)?.[0],
|
|
22
|
-
silent: options.silent,
|
|
23
|
-
url: options.url,
|
|
24
|
-
vcsRemote: options.release.vcsRemote,
|
|
25
|
-
headers: {
|
|
26
|
-
...options.telemetry ? getTraceData() : {},
|
|
27
|
-
...options.headers
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
16
|
function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
32
17
|
const logger = createLogger({
|
|
33
18
|
prefix: bundlerPluginMetaContext.loggerPrefix,
|
|
@@ -159,6 +144,9 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
159
144
|
if (bundleSizeOptimizations.excludeTracing) {
|
|
160
145
|
bundleSizeOptimizationReplacementValues["__SENTRY_TRACING__"] = false;
|
|
161
146
|
}
|
|
147
|
+
if (bundleSizeOptimizations.excludeChannelInjection) {
|
|
148
|
+
bundleSizeOptimizationReplacementValues["__SENTRY_CHANNEL_INJECTION__"] = false;
|
|
149
|
+
}
|
|
162
150
|
if (bundleSizeOptimizations.excludeReplayCanvas) {
|
|
163
151
|
bundleSizeOptimizationReplacementValues["__RRWEB_EXCLUDE_CANVAS__"] = true;
|
|
164
152
|
}
|
|
@@ -261,32 +249,31 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
261
249
|
return;
|
|
262
250
|
}
|
|
263
251
|
const freeWriteBundleInvocationDependencyOnSourcemapFiles = createDependencyOnBuildArtifacts();
|
|
252
|
+
const releaseName = options.release.name;
|
|
264
253
|
try {
|
|
265
|
-
const cliInstance =
|
|
254
|
+
const cliInstance = new SentryCliAdapter(options);
|
|
266
255
|
if (options.release.create) {
|
|
267
|
-
const releaseOutput = await cliInstance.
|
|
256
|
+
const releaseOutput = await cliInstance.createRelease(releaseName);
|
|
268
257
|
logger.debug("Release created:", releaseOutput);
|
|
269
258
|
}
|
|
270
259
|
if (options.release.uploadLegacySourcemaps) {
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
live: "rejectOnError"
|
|
284
|
-
});
|
|
260
|
+
const uploadTargets = arrayify(options.release.uploadLegacySourcemaps).map((includeItem) => typeof includeItem === "string" ? { paths: [includeItem] } : includeItem).flatMap(
|
|
261
|
+
(includeEntry) => includeEntry.paths.map((directory) => ({
|
|
262
|
+
directory,
|
|
263
|
+
dist: options.release.dist,
|
|
264
|
+
ext: includeEntry.ext ? includeEntry.ext.map((extension) => `.${extension.replace(/^\./, "")}`) : [".js", ".map", ".jsbundle", ".bundle"],
|
|
265
|
+
// The old CLI only skipped `node_modules` when neither ignore source was configured.
|
|
266
|
+
ignore: includeEntry.ignore ? arrayify(includeEntry.ignore) : includeEntry.ignoreFile ? void 0 : ["node_modules"],
|
|
267
|
+
ignoreFile: includeEntry.ignoreFile,
|
|
268
|
+
urlPrefix: includeEntry.urlPrefix
|
|
269
|
+
}))
|
|
270
|
+
);
|
|
271
|
+
await cliInstance.uploadSourcemaps(releaseName, uploadTargets);
|
|
285
272
|
}
|
|
286
273
|
if (options.release.setCommits !== false) {
|
|
287
274
|
try {
|
|
288
|
-
await cliInstance.
|
|
289
|
-
|
|
275
|
+
await cliInstance.setCommits(
|
|
276
|
+
releaseName,
|
|
290
277
|
// set commits always exists due to the normalize function
|
|
291
278
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
292
279
|
options.release.setCommits
|
|
@@ -303,11 +290,11 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
303
290
|
}
|
|
304
291
|
}
|
|
305
292
|
if (options.release.finalize) {
|
|
306
|
-
await cliInstance.
|
|
293
|
+
await cliInstance.finalizeRelease(releaseName);
|
|
307
294
|
}
|
|
308
|
-
if (options.release.deploy && !_deployedReleases.has(
|
|
309
|
-
await cliInstance.
|
|
310
|
-
_deployedReleases.add(
|
|
295
|
+
if (options.release.deploy && !_deployedReleases.has(releaseName)) {
|
|
296
|
+
await cliInstance.newDeploy(releaseName, options.release.deploy);
|
|
297
|
+
_deployedReleases.add(releaseName);
|
|
311
298
|
}
|
|
312
299
|
} catch (e) {
|
|
313
300
|
sentryScope.captureException('Error in "releaseManagementPlugin" writeBundle hook');
|
|
@@ -327,11 +314,8 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
327
314
|
async injectDebugIds(buildArtifactPaths) {
|
|
328
315
|
await startSpan({ name: "inject-debug-ids", scope: sentryScope, forceTransaction: true }, async () => {
|
|
329
316
|
try {
|
|
330
|
-
const cliInstance =
|
|
331
|
-
await cliInstance.
|
|
332
|
-
["sourcemaps", "inject", ...serializeIgnoreOptions(options.sourcemaps?.ignore), ...buildArtifactPaths],
|
|
333
|
-
options.debug ? "rejectOnError" : false
|
|
334
|
-
);
|
|
317
|
+
const cliInstance = new SentryCliAdapter(options);
|
|
318
|
+
await cliInstance.injectDebugIds(buildArtifactPaths, options.sourcemaps?.ignore);
|
|
335
319
|
} catch (e) {
|
|
336
320
|
sentryScope.captureException('Error in "debugIdInjectionPlugin" writeBundle hook');
|
|
337
321
|
handleRecoverableError(e, false);
|
|
@@ -377,21 +361,16 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
377
361
|
} else {
|
|
378
362
|
pathsToUpload = buildArtifactPaths;
|
|
379
363
|
}
|
|
380
|
-
const ignorePaths = options.sourcemaps?.ignore ? Array.isArray(options.sourcemaps?.ignore) ? options.sourcemaps?.ignore : [options.sourcemaps?.ignore] : [];
|
|
381
364
|
await startSpan({ name: "upload", scope: sentryScope }, async () => {
|
|
382
|
-
const cliInstance =
|
|
383
|
-
await cliInstance.
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
ignore: ignorePaths,
|
|
392
|
-
projects: getProjects(options.project),
|
|
393
|
-
live: "rejectOnError"
|
|
394
|
-
});
|
|
365
|
+
const cliInstance = new SentryCliAdapter(options);
|
|
366
|
+
await cliInstance.uploadSourcemaps(
|
|
367
|
+
options.release.name ?? "undefined",
|
|
368
|
+
pathsToUpload.map((directory) => ({
|
|
369
|
+
directory,
|
|
370
|
+
dist: options.release.dist,
|
|
371
|
+
ignore: options.sourcemaps?.ignore
|
|
372
|
+
}))
|
|
373
|
+
);
|
|
395
374
|
});
|
|
396
375
|
logger.info("Successfully uploaded source maps to Sentry");
|
|
397
376
|
} else {
|
|
@@ -460,18 +439,13 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
460
439
|
return;
|
|
461
440
|
}
|
|
462
441
|
await startSpan({ name: "upload", scope: sentryScope }, async () => {
|
|
463
|
-
const cliInstance =
|
|
464
|
-
await cliInstance.
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
}
|
|
471
|
-
],
|
|
472
|
-
projects: getProjects(options.project),
|
|
473
|
-
live: "rejectOnError"
|
|
474
|
-
});
|
|
442
|
+
const cliInstance = new SentryCliAdapter(options);
|
|
443
|
+
await cliInstance.uploadSourcemaps(options.release.name ?? "undefined", [
|
|
444
|
+
{
|
|
445
|
+
directory: tmpUploadFolder,
|
|
446
|
+
dist: options.release.dist
|
|
447
|
+
}
|
|
448
|
+
]);
|
|
475
449
|
});
|
|
476
450
|
logger.info("Successfully uploaded source maps to Sentry");
|
|
477
451
|
});
|