@sentry/bundler-plugins 10.76.1 → 10.77.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/build/cjs/core/build-plugin-manager.js +1 -1
  2. package/build/cjs/core/component-annotation-vite.js +1 -1
  3. package/build/cjs/core/debug-id-upload.js +1 -1
  4. package/build/cjs/core/index.js +32 -2
  5. package/build/cjs/core/index.js.map +1 -1
  6. package/build/cjs/core/sentry/telemetry.js +1 -1
  7. package/build/cjs/core/utils.js +8 -5
  8. package/build/cjs/core/utils.js.map +1 -1
  9. package/build/cjs/core/version.js +1 -1
  10. package/build/cjs/core/version.js.map +1 -1
  11. package/build/cjs/rollup/index.js +11 -6
  12. package/build/cjs/rollup/index.js.map +1 -1
  13. package/build/cjs/webpack/webpack4and5.js +10 -5
  14. package/build/cjs/webpack/webpack4and5.js.map +1 -1
  15. package/build/esm/core/index.js +30 -1
  16. package/build/esm/core/index.js.map +1 -1
  17. package/build/esm/core/utils.js +7 -4
  18. package/build/esm/core/utils.js.map +1 -1
  19. package/build/esm/core/version.js +1 -1
  20. package/build/esm/core/version.js.map +1 -1
  21. package/build/esm/package.json +1 -1
  22. package/build/esm/rollup/index.js +10 -5
  23. package/build/esm/rollup/index.js.map +1 -1
  24. package/build/esm/webpack/webpack4and5.js +10 -5
  25. package/build/esm/webpack/webpack4and5.js.map +1 -1
  26. package/build/types/core/index.d.ts +13 -0
  27. package/build/types/core/index.d.ts.map +1 -1
  28. package/build/types/core/utils.d.ts.map +1 -1
  29. package/build/types/core/version.d.ts +1 -1
  30. package/build/types/rollup/index.d.ts +3 -1
  31. package/build/types/rollup/index.d.ts.map +1 -1
  32. package/build/types/webpack/webpack4and5.d.ts.map +1 -1
  33. package/build/types-ts3.8/core/index.d.ts +13 -0
  34. package/build/types-ts3.8/core/version.d.ts +1 -1
  35. package/build/types-ts3.8/rollup/index.d.ts +3 -1
  36. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"webpack4and5.js","sources":["../../../src/webpack/webpack4and5.ts"],"sourcesContent":["import type { Options } from '../core/index';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n stringToUUID,\n createComponentNameAnnotateHooks,\n CodeInjection,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n isJsFile,\n stampDebugId,\n} from '../core/index';\nimport * as path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { createRequire } from 'node:module';\nimport { randomUUID } from 'node:crypto';\n\nconst _req = createRequire(import.meta.url);\n\n// Resolve the loader path via the package's own exports.\n// webpack4and5.ts may end up in a shared chunk (_chunks/) whose import.meta.url\n// does not point to the webpack/ directory where the transform file lives, so\n// a path-relative lookup would fail. Using require.resolve on the package export\n// always finds the correct installed file regardless of chunk placement.\nlet COMPONENT_ANNOTATION_LOADER: string;\ntry {\n COMPONENT_ANNOTATION_LOADER = _req.resolve('@sentry/bundler-plugins/webpack-loader');\n} catch {\n // Fallback for non-packaged environments (e.g., monorepo source runs without dist)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore Rollup transpiles import.meta for us for CJS\n const dirname = path.dirname(fileURLToPath(import.meta.url));\n // The Rollup build emits `.js` for both CJS and ESM, so the extension is the same in both.\n COMPONENT_ANNOTATION_LOADER = path.resolve(dirname, 'component-annotation-transform.js');\n}\n\n// since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version\n// https://github.com/webpack/webpack/commit/65eca2e529ce1d79b79200d4bdb1ce1b81141459\n\ninterface BannerPluginCallbackArg {\n chunk?: {\n hash?: string;\n contentHash?: {\n javascript?: string;\n };\n };\n}\n\ntype UnsafeBannerPlugin = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (options: any): unknown;\n};\n\ntype UnsafeDefinePlugin = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (options: any): unknown;\n};\n\ntype WebpackSource = {\n source: () => string | Buffer;\n};\n\ntype WebpackRawSource = {\n new (source: string): WebpackSource;\n};\n\ntype WebpackAsset = {\n name: string;\n source: WebpackSource;\n info: {\n related?: {\n sourceMap?: string | string[];\n };\n };\n};\n\ntype WebpackCompiler = {\n options: {\n plugins?: unknown[];\n mode?: string;\n module?: {\n rules?: unknown[];\n };\n };\n hooks: {\n thisCompilation: {\n tap: (name: string, callback: (compilation: WebpackCompilation) => void) => void;\n };\n afterEmit: {\n tapAsync: (name: string, callback: (compilation: WebpackCompilation, cb: () => void) => void) => void;\n };\n done: {\n tap: (name: string, callback: () => void) => void;\n };\n };\n webpack?: {\n BannerPlugin?: UnsafeBannerPlugin;\n DefinePlugin?: UnsafeDefinePlugin;\n Compilation?: {\n PROCESS_ASSETS_STAGE_DEV_TOOLING?: number;\n };\n sources?: {\n RawSource?: WebpackRawSource;\n };\n };\n};\n\ntype WebpackCompilation = {\n outputOptions: {\n path?: string;\n };\n assets: Record<string, unknown>;\n getAssets: () => WebpackAsset[];\n getAsset: (name: string) => WebpackAsset | undefined;\n updateAsset: (name: string, source: WebpackSource) => void;\n hooks: {\n processAssets: {\n tap: (options: { name: string; stage: number }, callback: () => void) => void;\n };\n };\n};\n\n// Detect webpack major version for telemetry (helps differentiate webpack 4 vs 5 usage)\nfunction getWebpackMajorVersion(): 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 webpack = req('webpack') as { version?: string; default?: { version?: string } };\n const version = webpack?.version ?? webpack?.default?.version;\n const webpackMajorVersion = version?.split('.')[0]; // \"4\" or \"5\"\n return webpackMajorVersion;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Stamps each JS asset's debug ID into the asset itself and its source map asset.\n *\n * Runs after source maps have been generated, so the JS asset no longer needs to carry\n * source map information and can be replaced with a plain `RawSource`.\n */\nfunction addDebugIdsToAssets(compilation: WebpackCompilation, RawSource: WebpackRawSource): void {\n for (const asset of compilation.getAssets()) {\n if (!isJsFile(asset.name)) {\n continue;\n }\n\n const bundleSource = asset.source.source().toString();\n const relatedSourceMap = asset.info.related?.sourceMap;\n const sourceMapName = typeof relatedSourceMap === 'string' ? relatedSourceMap : `${asset.name}.map`;\n const sourceMapAsset = compilation.getAsset(sourceMapName);\n\n const stamped = stampDebugId(bundleSource, sourceMapAsset?.source.source().toString());\n if (!stamped) {\n continue;\n }\n\n compilation.updateAsset(asset.name, new RawSource(stamped.bundleSource));\n if (stamped.sourceMapSource !== undefined) {\n compilation.updateAsset(sourceMapName, new RawSource(stamped.sourceMapSource));\n }\n }\n}\n\n/**\n * The factory function accepts BannerPlugin and DefinePlugin classes in\n * order to avoid direct dependencies on webpack.\n *\n * This allow us to export version of the plugin for webpack 5.1+ and compatible environments.\n *\n * Since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version.\n */\nexport function sentryWebpackPluginFactory({\n BannerPlugin: UnsafeBannerPlugin,\n DefinePlugin: UnsafeDefinePlugin,\n}: {\n BannerPlugin?: UnsafeBannerPlugin;\n DefinePlugin?: UnsafeDefinePlugin;\n} = {}) {\n return function sentryWebpackPlugin(userOptions: SentryWebpackPluginOptions = {}) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? '[sentry-webpack-plugin]',\n buildTool: 'webpack',\n buildToolMajorVersion: getWebpackMajorVersion(),\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 apply() {\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 const transformAnnotations = options.reactComponentAnnotation?.enabled\n ? createComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n !!options.reactComponentAnnotation?._experimentalInjectIntoHtml,\n )\n : undefined;\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n\n return {\n apply(compiler: WebpackCompiler) {\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n\n // Get the correct plugin classes (webpack 5.1+ vs older versions)\n const BannerPlugin = compiler?.webpack?.BannerPlugin || UnsafeBannerPlugin;\n const DefinePlugin = compiler?.webpack?.DefinePlugin || UnsafeDefinePlugin;\n\n // Add BannerPlugin for code injection (release, metadata, debug IDs)\n if (!staticInjectionCode.isEmpty() || sourcemapsEnabled) {\n if (!BannerPlugin) {\n logger.warn(\n 'BannerPlugin is not available. Skipping code injection. This usually means webpack is not properly configured.',\n );\n } else {\n compiler.options.plugins = compiler.options.plugins || [];\n compiler.options.plugins.push(\n new BannerPlugin({\n raw: true,\n include: /\\.(js|ts|jsx|tsx|mjs|cjs)(\\?[^?]*)?(#[^#]*)?$/,\n banner: (arg?: BannerPluginCallbackArg) => {\n const codeToInject = staticInjectionCode.clone();\n if (sourcemapsEnabled) {\n const hash = arg?.chunk?.contentHash?.javascript ?? arg?.chunk?.hash;\n const debugId = hash ? stringToUUID(hash) : randomUUID();\n codeToInject.append(getDebugIdSnippet(debugId));\n }\n return codeToInject.code();\n },\n }),\n );\n }\n }\n\n // The upload routine (which stamps debug IDs into temp copies of the artifacts) is skipped\n // with `disable-upload`, so the emitted artifacts get stamped in the asset pipeline instead.\n if (sourcemapsEnabled && options.sourcemaps?.disable === 'disable-upload') {\n const RawSource = compiler.webpack?.sources?.RawSource;\n // Right after source map generation (and thus after minification, which would strip the comment),\n // so later stages (real content hashing, subresource integrity) see the final assets.\n const stage = (compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_DEV_TOOLING ?? 500) + 1;\n\n if (!RawSource) {\n logger.warn(\n 'Webpack sources are not available. Skipping debug ID injection into emitted source maps. This usually means webpack is not properly configured.',\n );\n } else {\n compiler.hooks.thisCompilation.tap('sentry-webpack-plugin', compilation => {\n compilation.hooks.processAssets.tap({ name: 'sentry-webpack-plugin', stage }, () => {\n addDebugIdsToAssets(compilation, RawSource);\n });\n });\n }\n }\n\n // Add DefinePlugin for bundle size optimizations\n if (transformReplace && DefinePlugin) {\n compiler.options.plugins = compiler.options.plugins || [];\n compiler.options.plugins.push(new DefinePlugin(replacementValues));\n }\n\n // Add component name annotation transform\n if (transformAnnotations?.transform) {\n compiler.options.module = compiler.options.module || {};\n compiler.options.module.rules = compiler.options.module.rules || [];\n compiler.options.module.rules.unshift({\n test: /\\.[jt]sx$/,\n exclude: /node_modules/,\n enforce: 'pre',\n use: [\n {\n loader: COMPONENT_ANNOTATION_LOADER,\n options: {\n transform: transformAnnotations.transform,\n },\n },\n ],\n });\n }\n\n compiler.hooks.afterEmit.tapAsync(\n 'sentry-webpack-plugin',\n (compilation: WebpackCompilation, callback: (err?: Error) => void) => {\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n\n const run = async (): Promise<void> => {\n try {\n await sentryBuildPluginManager.createRelease();\n if (sourcemapsEnabled && options.sourcemaps?.disable !== 'disable-upload') {\n const outputPath = compilation.outputOptions.path ?? path.resolve();\n const buildArtifacts = Object.keys(compilation.assets).map(asset => path.join(outputPath, asset));\n await upload(buildArtifacts);\n }\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n };\n\n run().then(\n () => callback(),\n (err: Error) => callback(err),\n );\n },\n );\n\n if (userOptions._experiments?.forceExitOnBuildCompletion && compiler.options.mode === 'production') {\n compiler.hooks.done.tap('sentry-webpack-plugin', () => {\n setTimeout(() => {\n logger.debug('Exiting process after debug file upload');\n process.exit(0);\n });\n });\n }\n },\n };\n };\n}\n\nexport type SentryWebpackPluginOptions = Options & {\n _experiments?: Options['_experiments'] & {\n /**\n * If enabled, the webpack plugin will exit the build process after the build completes.\n * Use this with caution, as it will terminate the process.\n *\n * More information: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/345\n *\n * @default false\n */\n forceExitOnBuildCompletion?: boolean;\n };\n};\n"],"names":["createRequire","path","fileURLToPath","isJsFile","stampDebugId","createSentryBuildPluginManager","CodeInjection","generateReleaseInjectorCode","generateModuleMetadataInjectorCode","createComponentNameAnnotateHooks","stringToUUID","randomUUID","getDebugIdSnippet","createDebugIdUploadFunction"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,IAAA,GAAOA,yBAAA,CAAc,yQAAe,CAAA;AAO1C,IAAI,2BAAA;AACJ,IAAI;AACF,EAAA,2BAAA,GAA8B,IAAA,CAAK,QAAQ,wCAAwC,CAAA;AACrF,CAAA,CAAA,MAAQ;AAIN,EAAA,MAAM,UAAUC,eAAA,CAAK,OAAA,CAAQC,sBAAA,CAAc,yQAAe,CAAC,CAAA;AAE3D,EAAA,2BAAA,GAA8BD,eAAA,CAAK,OAAA,CAAQ,OAAA,EAAS,mCAAmC,CAAA;AACzF;AAyFA,SAAS,sBAAA,GAA6C;AACpD,EAAA,IAAI;AAGF,IAAA,MAAM,GAAA,GAAMD,yBAAA,CAAc,yQAAe,CAAA;AACzC,IAAA,MAAM,OAAA,GAAU,IAAI,SAAS,CAAA;AAC7B,IAAA,MAAM,OAAA,GAAU,OAAA,EAAS,OAAA,IAAW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AK,OAAA,EAAQ;AAClE,kBAAA,MAAM,cAAA,GAAiB,MAAA,CAAO,IAAA,CAAK,WAAA,CAAY,MAAM,CAAA,CAAE,GAAA,CAAI,CAAA,KAAA,KAASA,eAAA,CAAK,IAAA,CAAK,UAAA,EAAY,KAAK,CAAC,CAAA;AAChG,kBAAA,MAAM,OAAO,cAAc,CAAA;AAAA,gBAC7B;AAAA,cACF,CAAA,SAAE;AACA,gBAAA,oCAAA,EAAqC;AACrC,gBAAA,MAAM,yBAAyB,eAAA,EAAgB;AAAA,cACjD;AAAA,YACF,CAAA;AAEA,YAAA,GAAA,EAAI,CAAE,IAAA;AAAA,cACJ,MAAM,QAAA,EAAS;AAAA,cACf,CAAC,GAAA,KAAe,QAAA,CAAS,GAAG;AAAA,aAC9B;AAAA,UACF;AAAA,SACF;AAEA,QAAA,IAAI,YAAY,YAAA,EAAc,0BAAA,IAA8B,QAAA,CAAS,OAAA,CAAQ,SAAS,YAAA,EAAc;AAClG,UAAA,QAAA,CAAS,KAAA,CAAM,IAAA,CAAK,GAAA,CAAI,uBAAA,EAAyB,MAAM;AACrD,YAAA,UAAA,CAAW,MAAM;AACf,cAAA,MAAA,CAAO,MAAM,yCAAyC,CAAA;AACtD,cAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,YAChB,CAAC,CAAA;AAAA,UACH,CAAC,CAAA;AAAA,QACH;AAAA,MACF;AAAA,KACF;AAAA,EACF,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"webpack4and5.js","sources":["../../../src/webpack/webpack4and5.ts"],"sourcesContent":["import type { Options } from '../core/index';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n stringToUUID,\n createComponentNameAnnotateHooks,\n CodeInjection,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n isJsFile,\n stampDebugId,\n} from '../core/index';\nimport * as path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { createRequire } from 'node:module';\nimport { randomUUID } from 'node:crypto';\n\nconst _req = createRequire(import.meta.url);\n\n// Resolve the loader path via the package's own exports.\n// webpack4and5.ts may end up in a shared chunk (_chunks/) whose import.meta.url\n// does not point to the webpack/ directory where the transform file lives, so\n// a path-relative lookup would fail. Using require.resolve on the package export\n// always finds the correct installed file regardless of chunk placement.\nlet COMPONENT_ANNOTATION_LOADER: string;\ntry {\n COMPONENT_ANNOTATION_LOADER = _req.resolve('@sentry/bundler-plugins/webpack-loader');\n} catch {\n // Fallback for non-packaged environments (e.g., monorepo source runs without dist)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore Rollup transpiles import.meta for us for CJS\n const dirname = path.dirname(fileURLToPath(import.meta.url));\n // The Rollup build emits `.js` for both CJS and ESM, so the extension is the same in both.\n COMPONENT_ANNOTATION_LOADER = path.resolve(dirname, 'component-annotation-transform.js');\n}\n\n// since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version\n// https://github.com/webpack/webpack/commit/65eca2e529ce1d79b79200d4bdb1ce1b81141459\n\ninterface BannerPluginCallbackArg {\n chunk?: {\n hash?: string;\n canBeInitial?: () => boolean;\n contentHash?: {\n javascript?: string;\n };\n };\n}\n\ntype UnsafeBannerPlugin = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (options: any): unknown;\n};\n\ntype UnsafeDefinePlugin = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (options: any): unknown;\n};\n\ntype WebpackSource = {\n source: () => string | Buffer;\n};\n\ntype WebpackRawSource = {\n new (source: string): WebpackSource;\n};\n\ntype WebpackAsset = {\n name: string;\n source: WebpackSource;\n info: {\n related?: {\n sourceMap?: string | string[];\n };\n };\n};\n\ntype WebpackCompiler = {\n options: {\n plugins?: unknown[];\n mode?: string;\n module?: {\n rules?: unknown[];\n };\n };\n hooks: {\n thisCompilation: {\n tap: (name: string, callback: (compilation: WebpackCompilation) => void) => void;\n };\n afterEmit: {\n tapAsync: (name: string, callback: (compilation: WebpackCompilation, cb: () => void) => void) => void;\n };\n done: {\n tap: (name: string, callback: () => void) => void;\n };\n };\n webpack?: {\n BannerPlugin?: UnsafeBannerPlugin;\n DefinePlugin?: UnsafeDefinePlugin;\n Compilation?: {\n PROCESS_ASSETS_STAGE_DEV_TOOLING?: number;\n };\n sources?: {\n RawSource?: WebpackRawSource;\n };\n };\n};\n\ntype WebpackCompilation = {\n outputOptions: {\n path?: string;\n };\n assets: Record<string, unknown>;\n getAssets: () => WebpackAsset[];\n getAsset: (name: string) => WebpackAsset | undefined;\n updateAsset: (name: string, source: WebpackSource) => void;\n hooks: {\n processAssets: {\n tap: (options: { name: string; stage: number }, callback: () => void) => void;\n };\n };\n};\n\n// Detect webpack major version for telemetry (helps differentiate webpack 4 vs 5 usage)\nfunction getWebpackMajorVersion(): 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 webpack = req('webpack') as { version?: string; default?: { version?: string } };\n const version = webpack?.version ?? webpack?.default?.version;\n const webpackMajorVersion = version?.split('.')[0]; // \"4\" or \"5\"\n return webpackMajorVersion;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Stamps each JS asset's debug ID into the asset itself and its source map asset.\n *\n * Runs after source maps have been generated, so the JS asset no longer needs to carry\n * source map information and can be replaced with a plain `RawSource`.\n */\nfunction addDebugIdsToAssets(compilation: WebpackCompilation, RawSource: WebpackRawSource): void {\n for (const asset of compilation.getAssets()) {\n if (!isJsFile(asset.name)) {\n continue;\n }\n\n const bundleSource = asset.source.source().toString();\n const relatedSourceMap = asset.info.related?.sourceMap;\n const sourceMapName = typeof relatedSourceMap === 'string' ? relatedSourceMap : `${asset.name}.map`;\n const sourceMapAsset = compilation.getAsset(sourceMapName);\n\n const stamped = stampDebugId(bundleSource, sourceMapAsset?.source.source().toString());\n if (!stamped) {\n continue;\n }\n\n compilation.updateAsset(asset.name, new RawSource(stamped.bundleSource));\n if (stamped.sourceMapSource !== undefined) {\n compilation.updateAsset(sourceMapName, new RawSource(stamped.sourceMapSource));\n }\n }\n}\n\n/**\n * The factory function accepts BannerPlugin and DefinePlugin classes in\n * order to avoid direct dependencies on webpack.\n *\n * This allow us to export version of the plugin for webpack 5.1+ and compatible environments.\n *\n * Since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version.\n */\nexport function sentryWebpackPluginFactory({\n BannerPlugin: UnsafeBannerPlugin,\n DefinePlugin: UnsafeDefinePlugin,\n}: {\n BannerPlugin?: UnsafeBannerPlugin;\n DefinePlugin?: UnsafeDefinePlugin;\n} = {}) {\n return function sentryWebpackPlugin(userOptions: SentryWebpackPluginOptions = {}) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? '[sentry-webpack-plugin]',\n buildTool: 'webpack',\n buildToolMajorVersion: getWebpackMajorVersion(),\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 apply() {\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 releaseInjectionCode = new CodeInjection();\n const chunkInjectionCode = 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 releaseInjectionCode.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 chunkInjectionCode.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\n const transformReplace = Object.keys(replacementValues).length > 0;\n\n return {\n apply(compiler: WebpackCompiler) {\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n\n // Get the correct plugin classes (webpack 5.1+ vs older versions)\n const BannerPlugin = compiler?.webpack?.BannerPlugin || UnsafeBannerPlugin;\n const DefinePlugin = compiler?.webpack?.DefinePlugin || UnsafeDefinePlugin;\n\n // Add BannerPlugin for code injection (release, metadata, debug IDs)\n if (!releaseInjectionCode.isEmpty() || !chunkInjectionCode.isEmpty() || sourcemapsEnabled) {\n if (!BannerPlugin) {\n logger.warn(\n 'BannerPlugin is not available. Skipping code injection. This usually means webpack is not properly configured.',\n );\n } else {\n compiler.options.plugins = compiler.options.plugins || [];\n compiler.options.plugins.push(\n new BannerPlugin({\n raw: true,\n include: /\\.(js|ts|jsx|tsx|mjs|cjs)(\\?[^?]*)?(#[^#]*)?$/,\n banner: (arg?: BannerPluginCallbackArg) => {\n const codeToInject = new CodeInjection();\n if (arg?.chunk?.canBeInitial?.() ?? true) {\n codeToInject.append(releaseInjectionCode);\n }\n codeToInject.append(chunkInjectionCode);\n if (sourcemapsEnabled) {\n const hash = arg?.chunk?.contentHash?.javascript ?? arg?.chunk?.hash;\n const debugId = hash ? stringToUUID(hash) : randomUUID();\n codeToInject.append(getDebugIdSnippet(debugId));\n }\n return codeToInject.code();\n },\n }),\n );\n }\n }\n\n // The upload routine (which stamps debug IDs into temp copies of the artifacts) is skipped\n // with `disable-upload`, so the emitted artifacts get stamped in the asset pipeline instead.\n if (sourcemapsEnabled && options.sourcemaps?.disable === 'disable-upload') {\n const RawSource = compiler.webpack?.sources?.RawSource;\n // Right after source map generation (and thus after minification, which would strip the comment),\n // so later stages (real content hashing, subresource integrity) see the final assets.\n const stage = (compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_DEV_TOOLING ?? 500) + 1;\n\n if (!RawSource) {\n logger.warn(\n 'Webpack sources are not available. Skipping debug ID injection into emitted source maps. This usually means webpack is not properly configured.',\n );\n } else {\n compiler.hooks.thisCompilation.tap('sentry-webpack-plugin', compilation => {\n compilation.hooks.processAssets.tap({ name: 'sentry-webpack-plugin', stage }, () => {\n addDebugIdsToAssets(compilation, RawSource);\n });\n });\n }\n }\n\n // Add DefinePlugin for bundle size optimizations\n if (transformReplace && DefinePlugin) {\n compiler.options.plugins = compiler.options.plugins || [];\n compiler.options.plugins.push(new DefinePlugin(replacementValues));\n }\n\n // Add component name annotation transform\n if (transformAnnotations?.transform) {\n compiler.options.module = compiler.options.module || {};\n compiler.options.module.rules = compiler.options.module.rules || [];\n compiler.options.module.rules.unshift({\n test: /\\.[jt]sx$/,\n exclude: /node_modules/,\n enforce: 'pre',\n use: [\n {\n loader: COMPONENT_ANNOTATION_LOADER,\n options: {\n transform: transformAnnotations.transform,\n },\n },\n ],\n });\n }\n\n compiler.hooks.afterEmit.tapAsync(\n 'sentry-webpack-plugin',\n (compilation: WebpackCompilation, callback: (err?: Error) => void) => {\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n\n const run = async (): Promise<void> => {\n try {\n await sentryBuildPluginManager.createRelease();\n if (sourcemapsEnabled && options.sourcemaps?.disable !== 'disable-upload') {\n const outputPath = compilation.outputOptions.path ?? path.resolve();\n const buildArtifacts = Object.keys(compilation.assets).map(asset => path.join(outputPath, asset));\n await upload(buildArtifacts);\n }\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n };\n\n run().then(\n () => callback(),\n (err: Error) => callback(err),\n );\n },\n );\n\n if (userOptions._experiments?.forceExitOnBuildCompletion && compiler.options.mode === 'production') {\n compiler.hooks.done.tap('sentry-webpack-plugin', () => {\n setTimeout(() => {\n logger.debug('Exiting process after debug file upload');\n process.exit(0);\n });\n });\n }\n },\n };\n };\n}\n\nexport type SentryWebpackPluginOptions = Options & {\n _experiments?: Options['_experiments'] & {\n /**\n * If enabled, the webpack plugin will exit the build process after the build completes.\n * Use this with caution, as it will terminate the process.\n *\n * More information: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/345\n *\n * @default false\n */\n forceExitOnBuildCompletion?: boolean;\n };\n};\n"],"names":["createRequire","path","fileURLToPath","isJsFile","stampDebugId","createSentryBuildPluginManager","CodeInjection","generateReleaseInjectorCode","generateModuleMetadataInjectorCode","createComponentNameAnnotateHooks","stringToUUID","randomUUID","getDebugIdSnippet","createDebugIdUploadFunction"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,IAAA,GAAOA,yBAAA,CAAc,yQAAe,CAAA;AAO1C,IAAI,2BAAA;AACJ,IAAI;AACF,EAAA,2BAAA,GAA8B,IAAA,CAAK,QAAQ,wCAAwC,CAAA;AACrF,CAAA,CAAA,MAAQ;AAIN,EAAA,MAAM,UAAUC,eAAA,CAAK,OAAA,CAAQC,sBAAA,CAAc,yQAAe,CAAC,CAAA;AAE3D,EAAA,2BAAA,GAA8BD,eAAA,CAAK,OAAA,CAAQ,OAAA,EAAS,mCAAmC,CAAA;AACzF;AA0FA,SAAS,sBAAA,GAA6C;AACpD,EAAA,IAAI;AAGF,IAAA,MAAM,GAAA,GAAMD,yBAAA,CAAc,yQAAe,CAAA;AACzC,IAAA,MAAM,OAAA,GAAU,IAAI,SAAS,CAAA;AAC7B,IAAA,MAAM,OAAA,GAAU,OAAA,EAAS,OAAA,IAAW,OAAA,EAAS,OAAA,EAAS,OAAA;AACtD,IAAA,MAAM,mBAAA,GAAsB,OAAA,EAAS,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AACjD,IAAA,OAAO,mBAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA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EAAkB;AACzE,kBAAA,MAAM,UAAA,GAAa,WAAA,CAAY,aAAA,CAAc,IAAA,IAAQZ,gBAAK,OAAA,EAAQ;AAClE,kBAAA,MAAM,cAAA,GAAiB,MAAA,CAAO,IAAA,CAAK,WAAA,CAAY,MAAM,CAAA,CAAE,GAAA,CAAI,CAAA,KAAA,KAASA,eAAA,CAAK,IAAA,CAAK,UAAA,EAAY,KAAK,CAAC,CAAA;AAChG,kBAAA,MAAM,OAAO,cAAc,CAAA;AAAA,gBAC7B;AAAA,cACF,CAAA,SAAE;AACA,gBAAA,oCAAA,EAAqC;AACrC,gBAAA,MAAM,yBAAyB,eAAA,EAAgB;AAAA,cACjD;AAAA,YACF,CAAA;AAEA,YAAA,GAAA,EAAI,CAAE,IAAA;AAAA,cACJ,MAAM,QAAA,EAAS;AAAA,cACf,CAAC,GAAA,KAAe,QAAA,CAAS,GAAG;AAAA,aAC9B;AAAA,UACF;AAAA,SACF;AAEA,QAAA,IAAI,YAAY,YAAA,EAAc,0BAAA,IAA8B,QAAA,CAAS,OAAA,CAAQ,SAAS,YAAA,EAAc;AAClG,UAAA,QAAA,CAAS,KAAA,CAAM,IAAA,CAAK,GAAA,CAAI,uBAAA,EAAyB,MAAM;AACrD,YAAA,UAAA,CAAW,MAAM;AACf,cAAA,MAAA,CAAO,MAAM,yCAAyC,CAAA;AACtD,cAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,YAChB,CAAC,CAAA;AAAA,UACH,CAAC,CAAA;AAAA,QACH;AAAA,MACF;AAAA,KACF;AAAA,EACF,CAAA;AACF;;;;"}
@@ -42,6 +42,35 @@ function shouldSkipCodeInjection(code, facadeModuleId) {
42
42
  }
43
43
  return false;
44
44
  }
45
+ const initialChunksCache = /* @__PURE__ */ new WeakMap();
46
+ function getInitialChunks(chunks) {
47
+ const cached = initialChunksCache.get(chunks);
48
+ if (cached) {
49
+ return cached;
50
+ }
51
+ const initial = /* @__PURE__ */ new Set();
52
+ const queue = Object.values(chunks).filter((chunk) => chunk.isEntry);
53
+ for (let chunk = queue.shift(); chunk; chunk = queue.shift()) {
54
+ if (initial.has(chunk.fileName)) {
55
+ continue;
56
+ }
57
+ initial.add(chunk.fileName);
58
+ for (const imported of chunk.imports ?? []) {
59
+ const importedChunk = chunks[imported];
60
+ if (importedChunk) {
61
+ queue.push(importedChunk);
62
+ }
63
+ }
64
+ }
65
+ initialChunksCache.set(chunks, initial);
66
+ return initial;
67
+ }
68
+ function isInitialChunk(chunk, chunks) {
69
+ if (chunk.isEntry || !chunks) {
70
+ return true;
71
+ }
72
+ return getInitialChunks(chunks).has(chunk.fileName);
73
+ }
45
74
  function createComponentNameAnnotateHooks(ignoredComponents, injectIntoHtml) {
46
75
  return {
47
76
  async transform(code, id) {
@@ -92,5 +121,5 @@ function getDebugIdSnippet(debugId) {
92
121
  );
93
122
  }
94
123
 
95
- export { COMMENT_USE_STRICT_REGEX, CodeInjection, createComponentNameAnnotateHooks, getDebugIdSnippet, isJsFile, sentryCliBinaryExists, shouldSkipCodeInjection };
124
+ export { COMMENT_USE_STRICT_REGEX, CodeInjection, createComponentNameAnnotateHooks, getDebugIdSnippet, isInitialChunk, isJsFile, sentryCliBinaryExists, shouldSkipCodeInjection };
96
125
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/core/index.ts"],"sourcesContent":["import SentryCli from '@sentry/cli';\nimport { debug } from '@sentry/core';\nimport * as fs from 'fs';\nimport { CodeInjection, containsOnlyImports, stripQueryAndHashFromPath } from './utils';\nimport type { transformAsync as babelTransformAsync } from '@babel/core';\nimport type componentNameAnnotatePlugin from '../babel-plugin';\nimport type { experimentalComponentNameAnnotatePlugin } from '../babel-plugin';\n\ntype BabelTransformAsync = typeof babelTransformAsync;\ntype BabelParserPlugins = NonNullable<NonNullable<Parameters<BabelTransformAsync>[1]>['parserOpts']>['plugins'];\ntype BabelAnnotationRuntime = {\n transformAsync: BabelTransformAsync;\n componentNameAnnotatePlugin: typeof componentNameAnnotatePlugin;\n experimentalComponentNameAnnotatePlugin: typeof experimentalComponentNameAnnotatePlugin;\n};\n\nlet babelAnnotationRuntimePromise: Promise<BabelAnnotationRuntime> | undefined;\n\nfunction loadBabelAnnotationRuntime(): Promise<BabelAnnotationRuntime> {\n if (!babelAnnotationRuntimePromise) {\n babelAnnotationRuntimePromise = Promise.all([import('@babel/core'), import('../babel-plugin')]).then(\n ([babel, babelPlugin]) => {\n return {\n transformAsync: babel.transformAsync,\n componentNameAnnotatePlugin: babelPlugin.default,\n experimentalComponentNameAnnotatePlugin: babelPlugin.experimentalComponentNameAnnotatePlugin,\n };\n },\n );\n }\n\n return babelAnnotationRuntimePromise;\n}\n\n/**\n * Determines whether the Sentry CLI binary is in its expected location.\n * This function is useful since `@sentry/cli` installs the binary via a post-install\n * script and post-install scripts may not always run. E.g. with `npm i --ignore-scripts`.\n */\nexport function sentryCliBinaryExists(): boolean {\n return fs.existsSync(SentryCli.getPath());\n}\n\n// We need to be careful not to inject the snippet before any `\"use strict\";`s.\n// As an additional complication `\"use strict\";`s may come after any number of comments.\nexport const COMMENT_USE_STRICT_REGEX =\n // Note: CodeQL complains that this regex potentially has n^2 runtime. This likely won't affect realistic files.\n /^(?:\\s*|\\/\\*(?:.|\\r|\\n)*?\\*\\/|\\/\\/.*[\\n\\r])*(?:\"[^\"]*\";|'[^']*';)?/;\n\n/**\n * Checks if a file is a JavaScript file based on its extension.\n * Handles query strings and hashes in the filename.\n */\nexport function isJsFile(fileName: string): boolean {\n const cleanFileName = stripQueryAndHashFromPath(fileName);\n return ['.js', '.mjs', '.cjs'].some(ext => cleanFileName.endsWith(ext));\n}\n\n/**\n * Checks if a chunk should be skipped for code injection\n *\n * This is necessary to handle Vite's MPA (multi-page application) mode where\n * HTML entry points create \"facade\" chunks that should not contain injected code.\n * See: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/829\n *\n * However, in SPA mode, the main bundle also has an HTML facade but contains\n * substantial application code. We should NOT skip injection for these bundles.\n *\n * @param code - The chunk's code content\n * @param facadeModuleId - The facade module ID (if any) - HTML files create facade chunks\n * @returns true if the chunk should be skipped\n */\nexport function shouldSkipCodeInjection(code: string, facadeModuleId: string | null | undefined): boolean {\n // Skip empty chunks - these are placeholder chunks that should be optimized away\n if (code.trim().length === 0) {\n return true;\n }\n\n // For HTML facade chunks, only skip if they contain only import statements\n if (facadeModuleId && stripQueryAndHashFromPath(facadeModuleId).endsWith('.html')) {\n return containsOnlyImports(code);\n }\n\n return false;\n}\n\nexport { globFiles } from './glob';\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function createComponentNameAnnotateHooks(ignoredComponents: string[], injectIntoHtml: boolean) {\n return {\n async transform(this: void, code: string, id: string) {\n // id may contain query and hash which will trip up our file extension logic below\n const idWithoutQueryAndHash = stripQueryAndHashFromPath(id);\n\n if (idWithoutQueryAndHash.match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n return null;\n }\n\n // We will only apply this plugin on jsx and tsx files\n if (!['.jsx', '.tsx'].some(ending => idWithoutQueryAndHash.endsWith(ending))) {\n return null;\n }\n\n const parserPlugins: BabelParserPlugins = [];\n if (idWithoutQueryAndHash.endsWith('.jsx')) {\n parserPlugins.push('jsx');\n } else if (idWithoutQueryAndHash.endsWith('.tsx')) {\n parserPlugins.push('jsx', 'typescript');\n }\n\n const { transformAsync, componentNameAnnotatePlugin, experimentalComponentNameAnnotatePlugin } =\n await loadBabelAnnotationRuntime();\n const plugin = injectIntoHtml ? experimentalComponentNameAnnotatePlugin : componentNameAnnotatePlugin;\n\n try {\n const result = await transformAsync(code, {\n plugins: [[plugin, { ignoredComponents }]],\n filename: id,\n sourceFileName: idWithoutQueryAndHash,\n parserOpts: {\n sourceType: 'module',\n allowAwaitOutsideFunction: true,\n plugins: parserPlugins,\n },\n generatorOpts: {\n decoratorsBeforeExport: true,\n },\n sourceMaps: true,\n });\n\n return {\n code: result?.code ?? code,\n map: result?.map,\n };\n } catch (e) {\n debug.error(`Failed to apply react annotate plugin`, e);\n }\n\n return { code };\n },\n };\n}\n\nexport function getDebugIdSnippet(debugId: string): CodeInjection {\n return new CodeInjection(\n `var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=\"${debugId}\",e._sentryDebugIdIdentifier=\"sentry-dbid-${debugId}\");`,\n );\n}\n\nexport type { Logger } from './logger';\nexport type { Options, SentrySDKBuildFlags } from './types';\nexport {\n CodeInjection,\n replaceBooleanFlagsInCode,\n stringToUUID,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n} from './utils';\nexport { createSentryBuildPluginManager } from './build-plugin-manager';\nexport { createDebugIdUploadFunction, addDebugIdToEmittedArtifacts, stampDebugId } from './debug-id-upload';\n"],"names":[],"mappings":";;;;;;;;;AAgBA,IAAI,6BAAA;AAEJ,SAAS,0BAAA,GAA8D;AACrE,EAAA,IAAI,CAAC,6BAAA,EAA+B;AAClC,IAAA,6BAAA,GAAgC,OAAA,CAAQ,GAAA,CAAI,CAAC,OAAO,aAAa,GAAG,OAAO,0BAAiB,CAAC,CAAC,CAAA,CAAE,IAAA;AAAA,MAC9F,CAAC,CAAC,KAAA,EAAO,WAAW,CAAA,KAAM;AACxB,QAAA,OAAO;AAAA,UACL,gBAAgB,KAAA,CAAM,cAAA;AAAA,UACtB,6BAA6B,WAAA,CAAY,OAAA;AAAA,UACzC,yCAAyC,WAAA,CAAY;AAAA,SACvD;AAAA,MACF;AAAA,KACF;AAAA,EACF;AAEA,EAAA,OAAO,6BAAA;AACT;AAOO,SAAS,qBAAA,GAAiC;AAC/C,EAAA,OAAO,EAAA,CAAG,UAAA,CAAW,SAAA,CAAU,OAAA,EAAS,CAAA;AAC1C;AAIO,MAAM,wBAAA;AAAA;AAAA,EAEX;AAAA;AAMK,SAAS,SAAS,QAAA,EAA2B;AAClD,EAAA,MAAM,aAAA,GAAgB,0BAA0B,QAAQ,CAAA;AACxD,EAAA,OAAO,CAAC,KAAA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wC,GAC3F,MAAM,0BAAA,EAA2B;AACnC,MAAA,MAAM,MAAA,GAAS,iBAAiB,uCAAA,GAA0C,2BAAA;AAE1E,MAAA,IAAI;AACF,QAAA,MAAM,MAAA,GAAS,MAAM,cAAA,CAAe,IAAA,EAAM;AAAA,UACxC,SAAS,CAAC,CAAC,QAAQ,EAAE,iBAAA,EAAmB,CAAC,CAAA;AAAA,UACzC,QAAA,EAAU,EAAA;AAAA,UACV,cAAA,EAAgB,qBAAA;AAAA,UAChB,UAAA,EAAY;AAAA,YACV,UAAA,EAAY,QAAA;AAAA,YACZ,yBAAA,EAA2B,IAAA;AAAA,YAC3B,OAAA,EAAS;AAAA,WACX;AAAA,UACA,aAAA,EAAe;AAAA,YACb,sBAAA,EAAwB;AAAA,WAC1B;AAAA,UACA,UAAA,EAAY;AAAA,SACb,CAAA;AAED,QAAA,OAAO;AAAA,UACL,IAAA,EAAM,QAAQ,IAAA,IAAQ,IAAA;AAAA,UACtB,KAAK,MAAA,EAAQ;AAAA,SACf;AAAA,MACF,SAAS,CAAA,EAAG;AACV,QAAA,KAAA,CAAM,KAAA,CAAM,yCAAyC,CAAC,CAAA;AAAA,MACxD;AAEA,MAAA,OAAO,EAAE,IAAA,EAAK;AAAA,IAChB;AAAA,GACF;AACF;AAEO,SAAS,kBAAkB,OAAA,EAAgC;AAChE,EAAA,OAAO,IAAI,aAAA;AAAA,IACT,CAAA,4FAAA,EAA+F,OAAO,CAAA,0CAAA,EAA6C,OAAO,CAAA,GAAA;AAAA,GAC5J;AACF;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/core/index.ts"],"sourcesContent":["import SentryCli from '@sentry/cli';\nimport { debug } from '@sentry/core';\nimport * as fs from 'fs';\nimport { CodeInjection, containsOnlyImports, stripQueryAndHashFromPath } from './utils';\nimport type { transformAsync as babelTransformAsync } from '@babel/core';\nimport type componentNameAnnotatePlugin from '../babel-plugin';\nimport type { experimentalComponentNameAnnotatePlugin } from '../babel-plugin';\n\ntype BabelTransformAsync = typeof babelTransformAsync;\ntype BabelParserPlugins = NonNullable<NonNullable<Parameters<BabelTransformAsync>[1]>['parserOpts']>['plugins'];\ntype BabelAnnotationRuntime = {\n transformAsync: BabelTransformAsync;\n componentNameAnnotatePlugin: typeof componentNameAnnotatePlugin;\n experimentalComponentNameAnnotatePlugin: typeof experimentalComponentNameAnnotatePlugin;\n};\n\nlet babelAnnotationRuntimePromise: Promise<BabelAnnotationRuntime> | undefined;\n\nfunction loadBabelAnnotationRuntime(): Promise<BabelAnnotationRuntime> {\n if (!babelAnnotationRuntimePromise) {\n babelAnnotationRuntimePromise = Promise.all([import('@babel/core'), import('../babel-plugin')]).then(\n ([babel, babelPlugin]) => {\n return {\n transformAsync: babel.transformAsync,\n componentNameAnnotatePlugin: babelPlugin.default,\n experimentalComponentNameAnnotatePlugin: babelPlugin.experimentalComponentNameAnnotatePlugin,\n };\n },\n );\n }\n\n return babelAnnotationRuntimePromise;\n}\n\n/**\n * Determines whether the Sentry CLI binary is in its expected location.\n * This function is useful since `@sentry/cli` installs the binary via a post-install\n * script and post-install scripts may not always run. E.g. with `npm i --ignore-scripts`.\n */\nexport function sentryCliBinaryExists(): boolean {\n return fs.existsSync(SentryCli.getPath());\n}\n\n// We need to be careful not to inject the snippet before any `\"use strict\";`s.\n// As an additional complication `\"use strict\";`s may come after any number of comments.\nexport const COMMENT_USE_STRICT_REGEX =\n // Note: CodeQL complains that this regex potentially has n^2 runtime. This likely won't affect realistic files.\n /^(?:\\s*|\\/\\*(?:.|\\r|\\n)*?\\*\\/|\\/\\/.*[\\n\\r])*(?:\"[^\"]*\";|'[^']*';)?/;\n\n/**\n * Checks if a file is a JavaScript file based on its extension.\n * Handles query strings and hashes in the filename.\n */\nexport function isJsFile(fileName: string): boolean {\n const cleanFileName = stripQueryAndHashFromPath(fileName);\n return ['.js', '.mjs', '.cjs'].some(ext => cleanFileName.endsWith(ext));\n}\n\n/**\n * Checks if a chunk should be skipped for code injection\n *\n * This is necessary to handle Vite's MPA (multi-page application) mode where\n * HTML entry points create \"facade\" chunks that should not contain injected code.\n * See: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/829\n *\n * However, in SPA mode, the main bundle also has an HTML facade but contains\n * substantial application code. We should NOT skip injection for these bundles.\n *\n * @param code - The chunk's code content\n * @param facadeModuleId - The facade module ID (if any) - HTML files create facade chunks\n * @returns true if the chunk should be skipped\n */\nexport function shouldSkipCodeInjection(code: string, facadeModuleId: string | null | undefined): boolean {\n // Skip empty chunks - these are placeholder chunks that should be optimized away\n if (code.trim().length === 0) {\n return true;\n }\n\n // For HTML facade chunks, only skip if they contain only import statements\n if (facadeModuleId && stripQueryAndHashFromPath(facadeModuleId).endsWith('.html')) {\n return containsOnlyImports(code);\n }\n\n return false;\n}\n\nexport interface ChunkGraphNode {\n fileName: string;\n isEntry?: boolean;\n imports?: string[];\n}\n\nconst initialChunksCache = new WeakMap<Record<string, ChunkGraphNode>, Set<string>>();\n\nfunction getInitialChunks(chunks: Record<string, ChunkGraphNode>): Set<string> {\n const cached = initialChunksCache.get(chunks);\n if (cached) {\n return cached;\n }\n\n const initial = new Set<string>();\n const queue = Object.values(chunks).filter(chunk => chunk.isEntry);\n\n for (let chunk = queue.shift(); chunk; chunk = queue.shift()) {\n if (initial.has(chunk.fileName)) {\n continue;\n }\n initial.add(chunk.fileName);\n for (const imported of chunk.imports ?? []) {\n const importedChunk = chunks[imported];\n if (importedChunk) {\n queue.push(importedChunk);\n }\n }\n }\n\n initialChunksCache.set(chunks, initial);\n return initial;\n}\n\n/**\n * Whether a chunk loads at startup: it is an entry chunk, or an entry chunk\n * reaches it through static imports. Chunks that only dynamic imports reach\n * load later, after startup code already ran.\n *\n * Without the chunk graph every chunk counts as initial.\n */\nexport function isInitialChunk(\n chunk: Pick<ChunkGraphNode, 'fileName' | 'isEntry'>,\n chunks: Record<string, ChunkGraphNode> | undefined,\n): boolean {\n if (chunk.isEntry || !chunks) {\n return true;\n }\n\n return getInitialChunks(chunks).has(chunk.fileName);\n}\n\nexport { globFiles } from './glob';\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function createComponentNameAnnotateHooks(ignoredComponents: string[], injectIntoHtml: boolean) {\n return {\n async transform(this: void, code: string, id: string) {\n // id may contain query and hash which will trip up our file extension logic below\n const idWithoutQueryAndHash = stripQueryAndHashFromPath(id);\n\n if (idWithoutQueryAndHash.match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n return null;\n }\n\n // We will only apply this plugin on jsx and tsx files\n if (!['.jsx', '.tsx'].some(ending => idWithoutQueryAndHash.endsWith(ending))) {\n return null;\n }\n\n const parserPlugins: BabelParserPlugins = [];\n if (idWithoutQueryAndHash.endsWith('.jsx')) {\n parserPlugins.push('jsx');\n } else if (idWithoutQueryAndHash.endsWith('.tsx')) {\n parserPlugins.push('jsx', 'typescript');\n }\n\n const { transformAsync, componentNameAnnotatePlugin, experimentalComponentNameAnnotatePlugin } =\n await loadBabelAnnotationRuntime();\n const plugin = injectIntoHtml ? experimentalComponentNameAnnotatePlugin : componentNameAnnotatePlugin;\n\n try {\n const result = await transformAsync(code, {\n plugins: [[plugin, { ignoredComponents }]],\n filename: id,\n sourceFileName: idWithoutQueryAndHash,\n parserOpts: {\n sourceType: 'module',\n allowAwaitOutsideFunction: true,\n plugins: parserPlugins,\n },\n generatorOpts: {\n decoratorsBeforeExport: true,\n },\n sourceMaps: true,\n });\n\n return {\n code: result?.code ?? code,\n map: result?.map,\n };\n } catch (e) {\n debug.error(`Failed to apply react annotate plugin`, e);\n }\n\n return { code };\n },\n };\n}\n\nexport function getDebugIdSnippet(debugId: string): CodeInjection {\n return new CodeInjection(\n `var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=\"${debugId}\",e._sentryDebugIdIdentifier=\"sentry-dbid-${debugId}\");`,\n );\n}\n\nexport type { Logger } from './logger';\nexport type { Options, SentrySDKBuildFlags } from './types';\nexport {\n CodeInjection,\n replaceBooleanFlagsInCode,\n stringToUUID,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n} from './utils';\nexport { createSentryBuildPluginManager } from './build-plugin-manager';\nexport { createDebugIdUploadFunction, addDebugIdToEmittedArtifacts, stampDebugId } from './debug-id-upload';\n"],"names":[],"mappings":";;;;;;;;;AAgBA,IAAI,6BAAA;AAEJ,SAAS,0BAAA,GAA8D;AACrE,EAAA,IAAI,CAAC,6BAAA,EAA+B;AAClC,IAAA,6BAAA,GAAgC,OAAA,CAAQ,GAAA,CAAI,CAAC,OAAO,aAAa,GAAG,OAAO,0BAAiB,CAAC,CAAC,CAAA,CAAE,IAAA;AAAA,MAC9F,CAAC,CAAC,KAAA,EAAO,WAAW,CAAA,KAAM;AACxB,QAAA,OAAO;AAAA,UACL,gBAAgB,KAAA,CAAM,cAAA;AAAA,UACtB,6BAA6B,WAAA,CAAY,OAAA;AAAA,UACzC,yCAAyC,WAAA,CAAY;AAAA,SACvD;AAAA,MACF;AAAA,KACF;AAAA,EACF;AAEA,EAAA,OAAO,6BAAA;AACT;AAOO,SAAS,qBAAA,GAAiC;AAC/C,EAAA,OAAO,EAAA,CAAG,UAAA,CAAW,SAAA,CAAU,OAAA,EAAS,CAAA;AAC1C;AAIO,MAAM,wBAAA;AAAA;AAAA,EAEX;AAAA;AAMK,SAAS,SAAS,QAAA,EAA2B;AAClD,EAAA,MAAM,aAAA,GAAgB,0BAA0B,QAAQ,CAAA;AACxD,EAAA,OAAO,CAAC,KAAA,EAAO,MAAA,EAAQ,MAAM,CAAA,CAAE,KAAK,CAAA,GAAA,KAAO,aAAA,CAAc,QAAA,CAAS,GAAG,CAAC,CAAA;AACxE;AAgBO,SAAS,uBAAA,CAAwB,MAAc,cAAA,EAAoD;AAExG,EAAA,IAAI,IAAA,CAAK,IAAA,EAAK,CAAE,MAAA,KAAW,CAAA,EAAG;AAC5B,IAAA,OAAO,IAAA;AAAA,EACT;AAGA,EAAA,IAAI,kBAAkB,yBAAA,CAA0B,cAA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2B,IAAA;AAAA,YAC3B,OAAA,EAAS;AAAA,WACX;AAAA,UACA,aAAA,EAAe;AAAA,YACb,sBAAA,EAAwB;AAAA,WAC1B;AAAA,UACA,UAAA,EAAY;AAAA,SACb,CAAA;AAED,QAAA,OAAO;AAAA,UACL,IAAA,EAAM,QAAQ,IAAA,IAAQ,IAAA;AAAA,UACtB,KAAK,MAAA,EAAQ;AAAA,SACf;AAAA,MACF,SAAS,CAAA,EAAG;AACV,QAAA,KAAA,CAAM,KAAA,CAAM,yCAAyC,CAAC,CAAA;AAAA,MACxD;AAEA,MAAA,OAAO,EAAE,IAAA,EAAK;AAAA,IAChB;AAAA,GACF;AACF;AAEO,SAAS,kBAAkB,OAAA,EAAgC;AAChE,EAAA,OAAO,IAAI,aAAA;AAAA,IACT,CAAA,4FAAA,EAA+F,OAAO,CAAA,0CAAA,EAA6C,OAAO,CAAA,GAAA;AAAA,GAC5J;AACF;;;;"}
@@ -169,20 +169,23 @@ function determineReleaseName() {
169
169
  );
170
170
  return possibleReleaseNameOfGitProvider || possibleReleaseNameOfCiProvidersWithSpecificEnvVar || possibleReleaseNameOfCiProvidersWithGenericEnvVar || gitRevision();
171
171
  }
172
+ function stringifyForCodeInjection(value) {
173
+ return JSON.stringify(value)?.replace(/</g, "\\u003c");
174
+ }
172
175
  function generateReleaseInjectorCode({
173
176
  release,
174
177
  injectBuildInformation
175
178
  }) {
176
- let code = `e.SENTRY_RELEASE={id:${JSON.stringify(release)}};`;
179
+ let code = `e.SENTRY_RELEASE={id:${stringifyForCodeInjection(release)}};`;
177
180
  if (injectBuildInformation) {
178
181
  const buildInfo = getBuildInformation();
179
- code += `e.SENTRY_BUILD_INFO=${JSON.stringify(buildInfo)};`;
182
+ code += `e.SENTRY_BUILD_INFO=${stringifyForCodeInjection(buildInfo)};`;
180
183
  }
181
184
  return new CodeInjection(code);
182
185
  }
183
186
  function generateModuleMetadataInjectorCode(metadata) {
184
187
  return new CodeInjection(
185
- `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],${JSON.stringify(
188
+ `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(
186
189
  metadata
187
190
  )});`
188
191
  );
@@ -240,7 +243,7 @@ function containsOnlyImports(code) {
240
243
  class CodeInjection {
241
244
  constructor(body = "") {
242
245
  this.body = body;
243
- this.header = `!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};`;
246
+ this.header = `!function(){try{var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};`;
244
247
  this.footer = "}catch(e){}}();";
245
248
  }
246
249
  code() {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../src/core/utils.ts"],"sourcesContent":["/* oxlint-disable max-lines */\nimport findUp from 'find-up';\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';\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 lookupPackageJson(cwd: string, stopAt: string): PackageJson | undefined {\n const jsonPath = findUp.sync(\n dirName => {\n // Stop if we reach this dir\n if (path.normalize(dirName) === stopAt) {\n return findUp.stop;\n }\n\n return findUp.sync.exists(`${dirName}/package.json`) ? 'package.json' : undefined;\n },\n { cwd },\n );\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/**\n * Tries to guess a release name based on environmental data.\n */\n// oxlint-disable-next-line complexity\nexport function determineReleaseName(): string | undefined {\n // This list is in approximate alpha order, separated into 3 categories:\n // 1. Git providers\n // 2. CI providers with specific environment variables (has the provider name in the variable name)\n // 3. CI providers with generic environment variables (checked for last to prevent possible false positives)\n\n const possibleReleaseNameOfGitProvider =\n // GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables\n process.env['GITHUB_SHA'] ||\n // GitLab CI - https://docs.gitlab.com/ee/ci/variables/predefined_variables.html\n process.env['CI_MERGE_REQUEST_SOURCE_BRANCH_SHA'] ||\n process.env['CI_BUILD_REF'] ||\n process.env['CI_COMMIT_SHA'] ||\n // Bitbucket - https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/\n process.env['BITBUCKET_COMMIT'];\n\n const possibleReleaseNameOfCiProvidersWithSpecificEnvVar =\n // AppVeyor - https://www.appveyor.com/docs/environment-variables/\n process.env['APPVEYOR_PULL_REQUEST_HEAD_COMMIT'] ||\n process.env['APPVEYOR_REPO_COMMIT'] ||\n // AWS CodeBuild - https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html\n process.env['CODEBUILD_RESOLVED_SOURCE_VERSION'] ||\n // AWS Amplify - https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html\n process.env['AWS_COMMIT_ID'] ||\n // Azure Pipelines - https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml\n process.env['BUILD_SOURCEVERSION'] ||\n // Bitrise - https://devcenter.bitrise.io/builds/available-environment-variables/\n process.env['GIT_CLONE_COMMIT_HASH'] ||\n // Buddy CI - https://buddy.works/docs/pipelines/environment-variables#default-environment-variables\n process.env['BUDDY_EXECUTION_REVISION'] ||\n // Builtkite - https://buildkite.com/docs/pipelines/environment-variables\n process.env['BUILDKITE_COMMIT'] ||\n // CircleCI - https://circleci.com/docs/variables/\n process.env['CIRCLE_SHA1'] ||\n // Cirrus CI - https://cirrus-ci.org/guide/writing-tasks/#environment-variables\n process.env['CIRRUS_CHANGE_IN_REPO'] ||\n // Codefresh - https://codefresh.io/docs/docs/codefresh-yaml/variables/\n process.env['CF_REVISION'] ||\n // Codemagic - https://docs.codemagic.io/yaml-basic-configuration/environment-variables/\n process.env['CM_COMMIT'] ||\n // Cloudflare Pages - https://developers.cloudflare.com/pages/platform/build-configuration/#environment-variables\n process.env['CF_PAGES_COMMIT_SHA'] ||\n // Drone - https://docs.drone.io/pipeline/environment/reference/\n process.env['DRONE_COMMIT_SHA'] ||\n // Flightcontrol - https://www.flightcontrol.dev/docs/guides/flightcontrol/environment-variables#built-in-environment-variables\n process.env['FC_GIT_COMMIT_SHA'] ||\n // Heroku #1 https://devcenter.heroku.com/articles/heroku-ci\n process.env['HEROKU_TEST_RUN_COMMIT_VERSION'] ||\n // Heroku #2 https://docs.sentry.io/product/integrations/deployment/heroku/#configure-releases\n process.env['HEROKU_SLUG_COMMIT'] ||\n // Railway - https://docs.railway.app/reference/variables#git-variables\n process.env['RAILWAY_GIT_COMMIT_SHA'] ||\n // Render - https://render.com/docs/environment-variables\n process.env['RENDER_GIT_COMMIT'] ||\n // Semaphore CI - https://docs.semaphoreci.com/ci-cd-environment/environment-variables\n process.env['SEMAPHORE_GIT_SHA'] ||\n // TravisCI - https://docs.travis-ci.com/user/environment-variables/#default-environment-variables\n process.env['TRAVIS_PULL_REQUEST_SHA'] ||\n // Vercel - https://vercel.com/docs/v2/build-step#system-environment-variables\n process.env['VERCEL_GIT_COMMIT_SHA'] ||\n process.env['VERCEL_GITHUB_COMMIT_SHA'] ||\n process.env['VERCEL_GITLAB_COMMIT_SHA'] ||\n process.env['VERCEL_BITBUCKET_COMMIT_SHA'] ||\n // Zeit (now known as Vercel)\n process.env['ZEIT_GITHUB_COMMIT_SHA'] ||\n process.env['ZEIT_GITLAB_COMMIT_SHA'] ||\n process.env['ZEIT_BITBUCKET_COMMIT_SHA'];\n\n const possibleReleaseNameOfCiProvidersWithGenericEnvVar =\n // CloudBees CodeShip - https://docs.cloudbees.com/docs/cloudbees-codeship/latest/pro-builds-and-configuration/environment-variables\n process.env['CI_COMMIT_ID'] ||\n // Coolify - https://coolify.io/docs/knowledge-base/environment-variables\n process.env['SOURCE_COMMIT'] ||\n // Heroku #3 https://devcenter.heroku.com/changelog-items/630\n process.env['SOURCE_VERSION'] ||\n // Jenkins - https://plugins.jenkins.io/git/#environment-variables\n process.env['GIT_COMMIT'] ||\n // Netlify - https://docs.netlify.com/configure-builds/environment-variables/#build-metadata\n process.env['COMMIT_REF'] ||\n // TeamCity - https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html\n process.env['BUILD_VCS_NUMBER'] ||\n // Woodpecker CI - https://woodpecker-ci.org/docs/usage/environment\n process.env['CI_COMMIT_SHA'];\n\n return (\n possibleReleaseNameOfGitProvider ||\n possibleReleaseNameOfCiProvidersWithSpecificEnvVar ||\n possibleReleaseNameOfCiProvidersWithGenericEnvVar ||\n gitRevision()\n );\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:${JSON.stringify(release)}};`;\n\n if (injectBuildInformation) {\n const buildInfo = getBuildInformation();\n\n code += `e.SENTRY_BUILD_INFO=${JSON.stringify(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],${JSON.stringify(\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 * Inlined functionality from @sentry/cli helper code to add `--ignore` options.\n *\n * Temporary workaround until we expose a function for injecting debug IDs. Currently, we directly call `execute` with CLI args to inject them.\n */\nexport function serializeIgnoreOptions(ignoreValue: string | string[] | undefined): string[] {\n const DEFAULT_IGNORE = ['node_modules'];\n\n const ignoreOptions: string[] = Array.isArray(ignoreValue)\n ? ignoreValue\n : typeof ignoreValue === 'string'\n ? [ignoreValue]\n : DEFAULT_IGNORE;\n\n return ignoreOptions.reduce((acc, value) => acc.concat(['--ignore', String(value)]), [] as string[]);\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 this.header = `!function(){try{var e=\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof globalThis?globalThis:\"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"],"names":["path","os","depsVersions","fs","gitRevision"],"mappings":";;;;;;;;AAgBO,SAAS,SAAsB,UAAA,EAA0B;AAC9D,EAAA,OAAO,MAAM,OAAA,CAAQ,UAAU,CAAA,GAAI,UAAA,GAAa,CAAC,UAAU,CAAA;AAC7D;AAUO,SAAS,eAAe,EAAE,GAAA,EAAK,MAAA,EAAO,GAAuC,EAAC,EAA4B;AAC/G,EAAA,OAAO,iBAAA,CAAkB,GAAA,IAAO,OAAA,CAAQ,GAAA,EAAI,EAAGA,aAAA,CAAK,SAAA,CAAU,MAAA,IAAUC,WAAA,CAAG,OAAA,EAAS,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,EAAG;AAClB,MAAA,OAAO,EAAA;AAAA,IACT;AAEA,IAAA,OAAO,IAAA,CAAK,MAAA,GAAS,IAAA,CAAK,IAAA,GAAO,IAAA,CAAK,MAAA;AAAA,EACxC;AAAA,EAEO,OAAA,GAAmB;AACxB,IAAA,OAAO,IAAA,CAAK,KAAK,MAAA,KAAW,CAAA;AAAA,EAC9B;AAAA,EAEO,OAAO,IAAA,EAAoC;AAChD,IAAA,IAAI,gBAAgB,aAAA,EAAe;AACjC,MAAA,IAAA,CAAK,QAAQ,IAAA,CAAK,IAAA;AAAA,IACpB,CAAA,MAAO;AACL,MAAA,IAAA,CAAK,IAAA,IAAQ,IAAA;AAAA,IACf;AAAA,EACF;AAAA,EAEO,KAAA,GAAc;AACnB,IAAA,IAAA,CAAK,IAAA,GAAO,EAAA;AAAA,EACd;AAAA,EAEO,KAAA,GAAuB;AAC5B,IAAA,OAAO,IAAI,aAAA,CAAc,IAAA,CAAK,IAAI,CAAA;AAAA,EACpC;AACF;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../src/core/utils.ts"],"sourcesContent":["/* oxlint-disable max-lines */\nimport findUp from 'find-up';\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';\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 lookupPackageJson(cwd: string, stopAt: string): PackageJson | undefined {\n const jsonPath = findUp.sync(\n dirName => {\n // Stop if we reach this dir\n if (path.normalize(dirName) === stopAt) {\n return findUp.stop;\n }\n\n return findUp.sync.exists(`${dirName}/package.json`) ? 'package.json' : undefined;\n },\n { cwd },\n );\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/**\n * Tries to guess a release name based on environmental data.\n */\n// oxlint-disable-next-line complexity\nexport function determineReleaseName(): string | undefined {\n // This list is in approximate alpha order, separated into 3 categories:\n // 1. Git providers\n // 2. CI providers with specific environment variables (has the provider name in the variable name)\n // 3. CI providers with generic environment variables (checked for last to prevent possible false positives)\n\n const possibleReleaseNameOfGitProvider =\n // GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables\n process.env['GITHUB_SHA'] ||\n // GitLab CI - https://docs.gitlab.com/ee/ci/variables/predefined_variables.html\n process.env['CI_MERGE_REQUEST_SOURCE_BRANCH_SHA'] ||\n process.env['CI_BUILD_REF'] ||\n process.env['CI_COMMIT_SHA'] ||\n // Bitbucket - https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/\n process.env['BITBUCKET_COMMIT'];\n\n const possibleReleaseNameOfCiProvidersWithSpecificEnvVar =\n // AppVeyor - https://www.appveyor.com/docs/environment-variables/\n process.env['APPVEYOR_PULL_REQUEST_HEAD_COMMIT'] ||\n process.env['APPVEYOR_REPO_COMMIT'] ||\n // AWS CodeBuild - https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html\n process.env['CODEBUILD_RESOLVED_SOURCE_VERSION'] ||\n // AWS Amplify - https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html\n process.env['AWS_COMMIT_ID'] ||\n // Azure Pipelines - https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml\n process.env['BUILD_SOURCEVERSION'] ||\n // Bitrise - https://devcenter.bitrise.io/builds/available-environment-variables/\n process.env['GIT_CLONE_COMMIT_HASH'] ||\n // Buddy CI - https://buddy.works/docs/pipelines/environment-variables#default-environment-variables\n process.env['BUDDY_EXECUTION_REVISION'] ||\n // Builtkite - https://buildkite.com/docs/pipelines/environment-variables\n process.env['BUILDKITE_COMMIT'] ||\n // CircleCI - https://circleci.com/docs/variables/\n process.env['CIRCLE_SHA1'] ||\n // Cirrus CI - https://cirrus-ci.org/guide/writing-tasks/#environment-variables\n process.env['CIRRUS_CHANGE_IN_REPO'] ||\n // Codefresh - https://codefresh.io/docs/docs/codefresh-yaml/variables/\n process.env['CF_REVISION'] ||\n // Codemagic - https://docs.codemagic.io/yaml-basic-configuration/environment-variables/\n process.env['CM_COMMIT'] ||\n // Cloudflare Pages - https://developers.cloudflare.com/pages/platform/build-configuration/#environment-variables\n process.env['CF_PAGES_COMMIT_SHA'] ||\n // Drone - https://docs.drone.io/pipeline/environment/reference/\n process.env['DRONE_COMMIT_SHA'] ||\n // Flightcontrol - https://www.flightcontrol.dev/docs/guides/flightcontrol/environment-variables#built-in-environment-variables\n process.env['FC_GIT_COMMIT_SHA'] ||\n // Heroku #1 https://devcenter.heroku.com/articles/heroku-ci\n process.env['HEROKU_TEST_RUN_COMMIT_VERSION'] ||\n // Heroku #2 https://docs.sentry.io/product/integrations/deployment/heroku/#configure-releases\n process.env['HEROKU_SLUG_COMMIT'] ||\n // Railway - https://docs.railway.app/reference/variables#git-variables\n process.env['RAILWAY_GIT_COMMIT_SHA'] ||\n // Render - https://render.com/docs/environment-variables\n process.env['RENDER_GIT_COMMIT'] ||\n // Semaphore CI - https://docs.semaphoreci.com/ci-cd-environment/environment-variables\n process.env['SEMAPHORE_GIT_SHA'] ||\n // TravisCI - https://docs.travis-ci.com/user/environment-variables/#default-environment-variables\n process.env['TRAVIS_PULL_REQUEST_SHA'] ||\n // Vercel - https://vercel.com/docs/v2/build-step#system-environment-variables\n process.env['VERCEL_GIT_COMMIT_SHA'] ||\n process.env['VERCEL_GITHUB_COMMIT_SHA'] ||\n process.env['VERCEL_GITLAB_COMMIT_SHA'] ||\n process.env['VERCEL_BITBUCKET_COMMIT_SHA'] ||\n // Zeit (now known as Vercel)\n process.env['ZEIT_GITHUB_COMMIT_SHA'] ||\n process.env['ZEIT_GITLAB_COMMIT_SHA'] ||\n process.env['ZEIT_BITBUCKET_COMMIT_SHA'];\n\n const possibleReleaseNameOfCiProvidersWithGenericEnvVar =\n // CloudBees CodeShip - https://docs.cloudbees.com/docs/cloudbees-codeship/latest/pro-builds-and-configuration/environment-variables\n process.env['CI_COMMIT_ID'] ||\n // Coolify - https://coolify.io/docs/knowledge-base/environment-variables\n process.env['SOURCE_COMMIT'] ||\n // Heroku #3 https://devcenter.heroku.com/changelog-items/630\n process.env['SOURCE_VERSION'] ||\n // Jenkins - https://plugins.jenkins.io/git/#environment-variables\n process.env['GIT_COMMIT'] ||\n // Netlify - https://docs.netlify.com/configure-builds/environment-variables/#build-metadata\n process.env['COMMIT_REF'] ||\n // TeamCity - https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html\n process.env['BUILD_VCS_NUMBER'] ||\n // Woodpecker CI - https://woodpecker-ci.org/docs/usage/environment\n process.env['CI_COMMIT_SHA'];\n\n return (\n possibleReleaseNameOfGitProvider ||\n possibleReleaseNameOfCiProvidersWithSpecificEnvVar ||\n possibleReleaseNameOfCiProvidersWithGenericEnvVar ||\n gitRevision()\n );\n}\n\nfunction stringifyForCodeInjection(value: unknown): string | undefined {\n // Bundles may be inlined in HTML, where JSON quoting does not escape script tags or HTML comments.\n return JSON.stringify(value)?.replace(/</g, '\\\\u003c');\n}\n\n/**\n * Generates code for the global injector which is responsible for setting the global\n * `SENTRY_RELEASE` & `SENTRY_BUILD_INFO` variables.\n */\nexport function generateReleaseInjectorCode({\n release,\n injectBuildInformation,\n}: {\n release: string;\n injectBuildInformation: boolean;\n}): CodeInjection {\n let code = `e.SENTRY_RELEASE={id:${stringifyForCodeInjection(release)}};`;\n\n if (injectBuildInformation) {\n const buildInfo = getBuildInformation();\n\n code += `e.SENTRY_BUILD_INFO=${stringifyForCodeInjection(buildInfo)};`;\n }\n\n return new CodeInjection(code);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function generateModuleMetadataInjectorCode(metadata: any): CodeInjection {\n // We are merging the metadata objects in case modules are bundled twice with the plugin\n // Use try-catch to avoid issues when bundlers rename global variables like 'window' to 'k'\n return new CodeInjection(\n `e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])}return e}({},e._sentryModuleMetadata[(new e.Error).stack],${stringifyForCodeInjection(\n metadata,\n )});`,\n );\n}\n\nexport function getBuildInformation(): {\n deps: string[];\n depsVersions: Record<string, number>;\n nodeVersion: number | undefined;\n} {\n const packageJson = getPackageJson();\n\n const { deps, depsVersions } = packageJson ? getDependencies(packageJson) : { deps: [], depsVersions: {} };\n\n return {\n deps,\n depsVersions,\n nodeVersion: parseMajorVersion(process.version),\n };\n}\n\nexport function stripQueryAndHashFromPath(path: string): string {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return path.split('?')[0]!.split('#')[0]!;\n}\n\nexport function replaceBooleanFlagsInCode(\n code: string,\n replacementValues: Record<string, boolean | undefined>,\n): { code: string; map: SourceMap } | null {\n const ms = new MagicString(code);\n\n Object.keys(replacementValues).forEach(key => {\n const value = replacementValues[key];\n\n if (typeof value === 'boolean') {\n ms.replaceAll(key, JSON.stringify(value));\n }\n });\n\n if (ms.hasChanged()) {\n return {\n code: ms.toString(),\n map: ms.generateMap({ hires: 'boundary' }),\n };\n }\n\n return null;\n}\n\n// https://turbo.build/repo/docs/reference/system-environment-variables#environment-variables-in-tasks\nexport function getTurborepoEnvPassthroughWarning(envVarName: string): string {\n return process.env['TURBO_HASH']\n ? `\\nYou seem to be using Turborepo, did you forget to put ${envVarName} in \\`passThroughEnv\\`? https://turbo.build/repo/docs/reference/configuration#passthroughenv`\n : '';\n}\n\n/**\n * Gets the projects from the project option. This might be a single project or an array of projects.\n */\nexport function getProjects(project: string | string[] | undefined): string[] | undefined {\n if (Array.isArray(project)) {\n return project;\n }\n\n if (project) {\n return [project];\n }\n\n return undefined;\n}\n\n/**\n * Inlined functionality from @sentry/cli helper code to add `--ignore` options.\n *\n * Temporary workaround until we expose a function for injecting debug IDs. Currently, we directly call `execute` with CLI args to inject them.\n */\nexport function serializeIgnoreOptions(ignoreValue: string | string[] | undefined): string[] {\n const DEFAULT_IGNORE = ['node_modules'];\n\n const ignoreOptions: string[] = Array.isArray(ignoreValue)\n ? ignoreValue\n : typeof ignoreValue === 'string'\n ? [ignoreValue]\n : DEFAULT_IGNORE;\n\n return ignoreOptions.reduce((acc, value) => acc.concat(['--ignore', String(value)]), [] as string[]);\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"],"names":["path","os","depsVersions","fs","gitRevision"],"mappings":";;;;;;;;AAgBO,SAAS,SAAsB,UAAA,EAA0B;AAC9D,EAAA,OAAO,MAAM,OAAA,CAAQ,UAAU,CAAA,GAAI,UAAA,GAAa,CAAC,UAAU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ER,EAAA,OAAO,mBAAmB,MAAA,KAAW,CAAA;AACvC;AAEO,MAAM,aAAA,CAAc;AAAA,EAMzB,WAAA,CAAoB,OAAe,EAAA,EAAI;AAAnB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAQlB,IAAA,IAAA,CAAK,MAAA,GAAS,CAAA,qKAAA,CAAA;AACd,IAAA,IAAA,CAAK,MAAA,GAAS,iBAAA;AAAA,EAChB;AAAA,EAEO,IAAA,GAAe;AACpB,IAAA,IAAI,IAAA,CAAK,SAAQ,EAAG;AAClB,MAAA,OAAO,EAAA;AAAA,IACT;AAEA,IAAA,OAAO,IAAA,CAAK,MAAA,GAAS,IAAA,CAAK,IAAA,GAAO,IAAA,CAAK,MAAA;AAAA,EACxC;AAAA,EAEO,OAAA,GAAmB;AACxB,IAAA,OAAO,IAAA,CAAK,KAAK,MAAA,KAAW,CAAA;AAAA,EAC9B;AAAA,EAEO,OAAO,IAAA,EAAoC;AAChD,IAAA,IAAI,gBAAgB,aAAA,EAAe;AACjC,MAAA,IAAA,CAAK,QAAQ,IAAA,CAAK,IAAA;AAAA,IACpB,CAAA,MAAO;AACL,MAAA,IAAA,CAAK,IAAA,IAAQ,IAAA;AAAA,IACf;AAAA,EACF;AAAA,EAEO,KAAA,GAAc;AACnB,IAAA,IAAA,CAAK,IAAA,GAAO,EAAA;AAAA,EACd;AAAA,EAEO,KAAA,GAAuB;AAC5B,IAAA,OAAO,IAAI,aAAA,CAAc,IAAA,CAAK,IAAI,CAAA;AAAA,EACpC;AACF;;;;"}
@@ -1,4 +1,4 @@
1
- const LIB_VERSION = "10.76.1";
1
+ const LIB_VERSION = "10.77.1";
2
2
 
3
3
  export { LIB_VERSION };
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"10.76.1\";\n"],"names":[],"mappings":"AAAO,MAAM,WAAA,GAAc;;;;"}
1
+ {"version":3,"file":"version.js","sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"10.77.1\";\n"],"names":[],"mappings":"AAAO,MAAM,WAAA,GAAc;;;;"}
@@ -1 +1 @@
1
- {"type":"module","version":"10.76.1","sideEffects":["./sentry-release-injection-file.js","./sentry-esbuild-debugid-injection-file.js"]}
1
+ {"type":"module","version":"10.77.1","sideEffects":["./sentry-release-injection-file.js","./sentry-esbuild-debugid-injection-file.js"]}
@@ -1,4 +1,4 @@
1
- import { createComponentNameAnnotateHooks, isJsFile, shouldSkipCodeInjection, getDebugIdSnippet, COMMENT_USE_STRICT_REGEX } from '../core/index.js';
1
+ import { createComponentNameAnnotateHooks, isJsFile, shouldSkipCodeInjection, isInitialChunk, getDebugIdSnippet, COMMENT_USE_STRICT_REGEX } from '../core/index.js';
2
2
  export { sentryCliBinaryExists } from '../core/index.js';
3
3
  import MagicString from 'magic-string';
4
4
  import * as path from 'node:path';
@@ -68,7 +68,8 @@ function _rollupPluginInternal(userOptions = {}, buildTool, buildToolMajorVersio
68
68
  const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
69
69
  const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });
70
70
  const sourcemapsEnabled = options.sourcemaps?.disable !== true;
71
- const staticInjectionCode = new CodeInjection();
71
+ const releaseInjectionCode = new CodeInjection();
72
+ const chunkInjectionCode = new CodeInjection();
72
73
  if (!options.release.inject) {
73
74
  logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
74
75
  } else if (!options.release.name) {
@@ -76,7 +77,7 @@ function _rollupPluginInternal(userOptions = {}, buildTool, buildToolMajorVersio
76
77
  "No release name provided. Will not inject release. Please set the `release.name` option to identify your release."
77
78
  );
78
79
  } else {
79
- staticInjectionCode.append(
80
+ releaseInjectionCode.append(
80
81
  generateReleaseInjectorCode({
81
82
  release: options.release.name,
82
83
  injectBuildInformation: options._experiments.injectBuildInformation || false
@@ -84,7 +85,7 @@ function _rollupPluginInternal(userOptions = {}, buildTool, buildToolMajorVersio
84
85
  );
85
86
  }
86
87
  if (Object.keys(bundleMetadata).length > 0) {
87
- staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));
88
+ chunkInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));
88
89
  }
89
90
  const transformAnnotations = options.reactComponentAnnotation?.enabled ? createComponentNameAnnotateHooks(
90
91
  options.reactComponentAnnotation?.ignoredComponents || [],
@@ -141,7 +142,11 @@ function _rollupPluginInternal(userOptions = {}, buildTool, buildToolMajorVersio
141
142
  if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {
142
143
  return null;
143
144
  }
144
- const injectCode = staticInjectionCode.clone();
145
+ const injectCode = new CodeInjection();
146
+ if (isInitialChunk(chunk, meta?.chunks)) {
147
+ injectCode.append(releaseInjectionCode);
148
+ }
149
+ injectCode.append(chunkInjectionCode);
145
150
  if (sourcemapsEnabled && !hasExistingDebugID(code)) {
146
151
  const debugId = stringToUUID(code);
147
152
  injectCode.append(getDebugIdSnippet(debugId));
@@ -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 stampDebugId,\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\n// The subset of Rollup's `OutputBundle` the stamping hook reads.\ntype OutputBundle = Record<\n string,\n | { type: 'chunk'; fileName: string; code: string; sourcemapFileName?: string | null }\n | { type: 'asset'; fileName: string; source: string | Uint8Array }\n>;\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 /**\n * Stamps debug IDs into the emitted chunks and source maps.\n *\n * `disable-upload` skips the upload routine (which stamps debug IDs into temp copies), so the emitted\n * artifacts get stamped here instead. Not in `renderChunk`: minifiers running after it would strip the\n * comment. Rollup computes `[hash]` file names before this hook, so only plugins that hash the final\n * assets afterwards (e.g. subresource integrity) see the stamped content.\n */\n function generateBundle(_outputOptions: unknown, bundle: OutputBundle): void {\n for (const output of Object.values(bundle)) {\n if (output.type !== 'chunk' || !isJsFile(output.fileName)) {\n continue;\n }\n\n const sourceMapAsset = bundle[output.sourcemapFileName ?? `${output.fileName}.map`];\n const sourceMapSource =\n sourceMapAsset?.type === 'asset' && typeof sourceMapAsset.source === 'string'\n ? sourceMapAsset.source\n : undefined;\n\n const stamped = stampDebugId(output.code, sourceMapSource);\n if (!stamped) {\n continue;\n }\n\n output.code = stamped.bundleSource;\n if (stamped.sourceMapSource !== undefined && sourceMapAsset?.type === 'asset') {\n sourceMapAsset.source = stamped.sourceMapSource;\n }\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 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 ...(shouldTransform ? { transform: transformHook } : {}),\n renderChunk,\n ...(options.sourcemaps?.disable === 'disable-upload'\n ? { generateBundle: { order: 'pre' as const, handler: generateBundle } }\n : {}),\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 Sentry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BAChC,EAAE,cAAA,EAAgB,EAAE,KAAA,EAAO,KAAA,EAAgB,OAAA,EAAS,cAAA,EAAe,KACnE,EAAC;AAAA,IACL;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":["/* oxlint-disable max-lines */\n\nimport type { ChunkGraphNode, Options } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n isJsFile,\n isInitialChunk,\n shouldSkipCodeInjection,\n getDebugIdSnippet,\n stringToUUID,\n COMMENT_USE_STRICT_REGEX,\n createDebugIdUploadFunction,\n globFiles,\n createComponentNameAnnotateHooks,\n replaceBooleanFlagsInCode,\n CodeInjection,\n stampDebugId,\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\n// The subset of Rollup's `OutputBundle` the stamping hook reads.\ntype OutputBundle = Record<\n string,\n | { type: 'chunk'; fileName: string; code: string; sourcemapFileName?: string | null }\n | { type: 'asset'; fileName: string; source: string | Uint8Array }\n>;\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 releaseInjectionCode = new CodeInjection();\n const chunkInjectionCode = 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 releaseInjectionCode.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 chunkInjectionCode.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; isEntry?: boolean },\n _?: unknown,\n meta?: { magicString?: MagicString; chunks?: Record<string, ChunkGraphNode> },\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 = new CodeInjection();\n\n if (isInitialChunk(chunk, meta?.chunks)) {\n injectCode.append(releaseInjectionCode);\n }\n\n injectCode.append(chunkInjectionCode);\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 /**\n * Stamps debug IDs into the emitted chunks and source maps.\n *\n * `disable-upload` skips the upload routine (which stamps debug IDs into temp copies), so the emitted\n * artifacts get stamped here instead. Not in `renderChunk`: minifiers running after it would strip the\n * comment. Rollup computes `[hash]` file names before this hook, so only plugins that hash the final\n * assets afterwards (e.g. subresource integrity) see the stamped content.\n */\n function generateBundle(_outputOptions: unknown, bundle: OutputBundle): void {\n for (const output of Object.values(bundle)) {\n if (output.type !== 'chunk' || !isJsFile(output.fileName)) {\n continue;\n }\n\n const sourceMapAsset = bundle[output.sourcemapFileName ?? `${output.fileName}.map`];\n const sourceMapSource =\n sourceMapAsset?.type === 'asset' && typeof sourceMapAsset.source === 'string'\n ? sourceMapAsset.source\n : undefined;\n\n const stamped = stampDebugId(output.code, sourceMapSource);\n if (!stamped) {\n continue;\n }\n\n output.code = stamped.bundleSource;\n if (stamped.sourceMapSource !== undefined && sourceMapAsset?.type === 'asset') {\n sourceMapAsset.source = stamped.sourceMapSource;\n }\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 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 ...(shouldTransform ? { transform: transformHook } : {}),\n renderChunk,\n ...(options.sourcemaps?.disable === 'disable-upload'\n ? { generateBundle: { order: 'pre' as const, handler: generateBundle } }\n : {}),\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":[],"mappings":";;;;;;;;;;AAsDA,IAAI,wBAAA;AAEJ,MAAM,mBAAA,GAAsB,4BAAA;AAE5B,SAAS,mBAAmB,IAAA,EAAuB;AAEjD,EAAA,MAAM,iBAAA,GAAoB,IAAA,CA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AY,OAAA,KAAY,mBAChC,EAAE,cAAA,EAAgB,EAAE,KAAA,EAAO,KAAA,EAAgB,OAAA,EAAS,cAAA,EAAe,KACnE,EAAC;AAAA,IACL;AAAA,GACF;AACF;AAGO,SAAS,kBAAA,CAAmB,WAAA,GAAuB,EAAC,EAAQ;AAGjE,EAAA,OAAO,CAAC,qBAAA,CAAsB,WAAA,EAAa,QAAQ,CAAC,CAAA;AACtD;;;;"}
@@ -72,7 +72,8 @@ function sentryWebpackPluginFactory({
72
72
  logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
73
73
  }
74
74
  const sourcemapsEnabled = options.sourcemaps?.disable !== true;
75
- const staticInjectionCode = new CodeInjection();
75
+ const releaseInjectionCode = new CodeInjection();
76
+ const chunkInjectionCode = new CodeInjection();
76
77
  if (!options.release.inject) {
77
78
  logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
78
79
  } else if (!options.release.name) {
@@ -80,7 +81,7 @@ function sentryWebpackPluginFactory({
80
81
  "No release name provided. Will not inject release. Please set the `release.name` option to identify your release."
81
82
  );
82
83
  } else {
83
- staticInjectionCode.append(
84
+ releaseInjectionCode.append(
84
85
  generateReleaseInjectorCode({
85
86
  release: options.release.name,
86
87
  injectBuildInformation: options._experiments.injectBuildInformation || false
@@ -88,7 +89,7 @@ function sentryWebpackPluginFactory({
88
89
  );
89
90
  }
90
91
  if (Object.keys(bundleMetadata).length > 0) {
91
- staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));
92
+ chunkInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));
92
93
  }
93
94
  const transformAnnotations = options.reactComponentAnnotation?.enabled ? createComponentNameAnnotateHooks(
94
95
  options.reactComponentAnnotation?.ignoredComponents || [],
@@ -101,7 +102,7 @@ function sentryWebpackPluginFactory({
101
102
  });
102
103
  const BannerPlugin = compiler?.webpack?.BannerPlugin || UnsafeBannerPlugin;
103
104
  const DefinePlugin = compiler?.webpack?.DefinePlugin || UnsafeDefinePlugin;
104
- if (!staticInjectionCode.isEmpty() || sourcemapsEnabled) {
105
+ if (!releaseInjectionCode.isEmpty() || !chunkInjectionCode.isEmpty() || sourcemapsEnabled) {
105
106
  if (!BannerPlugin) {
106
107
  logger.warn(
107
108
  "BannerPlugin is not available. Skipping code injection. This usually means webpack is not properly configured."
@@ -113,7 +114,11 @@ function sentryWebpackPluginFactory({
113
114
  raw: true,
114
115
  include: /\.(js|ts|jsx|tsx|mjs|cjs)(\?[^?]*)?(#[^#]*)?$/,
115
116
  banner: (arg) => {
116
- const codeToInject = staticInjectionCode.clone();
117
+ const codeToInject = new CodeInjection();
118
+ if (arg?.chunk?.canBeInitial?.() ?? true) {
119
+ codeToInject.append(releaseInjectionCode);
120
+ }
121
+ codeToInject.append(chunkInjectionCode);
117
122
  if (sourcemapsEnabled) {
118
123
  const hash = arg?.chunk?.contentHash?.javascript ?? arg?.chunk?.hash;
119
124
  const debugId = hash ? stringToUUID(hash) : randomUUID();