@@ -6,17 +6,21 @@ import * as fs from "fs";
66import { glob } from "glob" ;
77import MagicString from "magic-string" ;
88import * as path from "path" ;
9- import { createUnplugin , TransformResult , UnpluginOptions } from "unplugin" ;
9+ import {
10+ createUnplugin ,
11+ RollupPlugin ,
12+ TransformResult ,
13+ UnpluginInstance ,
14+ UnpluginOptions ,
15+ } from "unplugin" ;
1016import { createSentryBuildPluginManager } from "./build-plugin-manager" ;
1117import { createDebugIdUploadFunction } from "./debug-id-upload" ;
1218import { Logger } from "./logger" ;
1319import { Options , SentrySDKBuildFlags } from "./types" ;
1420import {
1521 generateGlobalInjectorCode ,
1622 generateModuleMetadataInjectorCode ,
17- getDependencies ,
18- getPackageJson ,
19- parseMajorVersion ,
23+ getBuildInformation as actualGetBuildInformation ,
2024 replaceBooleanFlagsInCode ,
2125 stringToUUID ,
2226 stripQueryAndHashFromPath ,
@@ -46,7 +50,7 @@ export function sentryUnpluginFactory({
4650 debugIdInjectionPlugin,
4751 debugIdUploadPlugin,
4852 bundleSizeOptimizationsPlugin,
49- } : SentryUnpluginFactoryOptions ) {
53+ } : SentryUnpluginFactoryOptions ) : UnpluginInstance < Options | undefined , true > {
5054 return createUnplugin < Options | undefined , true > ( ( userOptions = { } , unpluginMetaContext ) => {
5155 const sentryBuildPluginManager = createSentryBuildPluginManager ( userOptions , {
5256 loggerPrefix :
@@ -177,22 +181,11 @@ export function sentryUnpluginFactory({
177181}
178182
179183/**
180- * @deprecated
184+ * @deprecated This will be removed in v4
181185 */
182- // TODO(v4): Don't export this from the package
183- export function getBuildInformation ( ) {
184- const packageJson = getPackageJson ( ) ;
185-
186- const { deps, depsVersions } = packageJson
187- ? getDependencies ( packageJson )
188- : { deps : [ ] , depsVersions : { } } ;
189-
190- return {
191- deps,
192- depsVersions,
193- nodeVersion : parseMajorVersion ( process . version ) ,
194- } ;
195- }
186+ // TODO(v4): Don't export this from the package but keep the utils version
187+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
188+ export const getBuildInformation = actualGetBuildInformation ;
196189
197190/**
198191 * Determines whether the Sentry CLI binary is in its expected location.
@@ -203,7 +196,11 @@ export function sentryCliBinaryExists(): boolean {
203196 return fs . existsSync ( SentryCli . getPath ( ) ) ;
204197}
205198
206- export function createRollupReleaseInjectionHooks ( injectionCode : string ) {
199+ export function createRollupReleaseInjectionHooks ( injectionCode : string ) : {
200+ resolveId : UnpluginOptions [ "resolveId" ] ;
201+ load : UnpluginOptions [ "load" ] ;
202+ transform : UnpluginOptions [ "transform" ] ;
203+ } {
207204 const virtualReleaseInjectionFileId = "\0sentry-release-injection-file" ;
208205 return {
209206 resolveId ( id : string ) {
@@ -260,7 +257,9 @@ export function createRollupReleaseInjectionHooks(injectionCode: string) {
260257 } ;
261258}
262259
263- export function createRollupBundleSizeOptimizationHooks ( replacementValues : SentrySDKBuildFlags ) {
260+ export function createRollupBundleSizeOptimizationHooks ( replacementValues : SentrySDKBuildFlags ) : {
261+ transform : UnpluginOptions [ "transform" ] ;
262+ } {
264263 return {
265264 transform ( code : string ) {
266265 return replaceBooleanFlagsInCode ( code , replacementValues ) ;
@@ -274,7 +273,9 @@ const COMMENT_USE_STRICT_REGEX =
274273 // Note: CodeQL complains that this regex potentially has n^2 runtime. This likely won't affect realistic files.
275274 / ^ (?: \s * | \/ \* (?: .| \r | \n ) * ?\* \/ | \/ \/ .* [ \n \r ] ) * (?: " [ ^ " ] * " ; | ' [ ^ ' ] * ' ; ) ? / ;
276275
277- export function createRollupDebugIdInjectionHooks ( ) {
276+ export function createRollupDebugIdInjectionHooks ( ) : {
277+ renderChunk : RollupPlugin [ "renderChunk" ] ;
278+ } {
278279 return {
279280 renderChunk ( code : string , chunk : { fileName : string } ) {
280281 if (
@@ -311,7 +312,9 @@ export function createRollupDebugIdInjectionHooks() {
311312 } ;
312313}
313314
314- export function createRollupModuleMetadataInjectionHooks ( injectionCode : string ) {
315+ export function createRollupModuleMetadataInjectionHooks ( injectionCode : string ) : {
316+ renderChunk : RollupPlugin [ "renderChunk" ] ;
317+ } {
315318 return {
316319 renderChunk ( code : string , chunk : { fileName : string } ) {
317320 if (
@@ -349,7 +352,9 @@ export function createRollupDebugIdUploadHooks(
349352 upload : ( buildArtifacts : string [ ] ) => Promise < void > ,
350353 _logger : Logger ,
351354 createDependencyOnBuildArtifacts : ( ) => ( ) => void
352- ) {
355+ ) : {
356+ writeBundle : RollupPlugin [ "writeBundle" ] ;
357+ } {
353358 const freeGlobalDependencyOnDebugIdSourcemapArtifacts = createDependencyOnBuildArtifacts ( ) ;
354359 return {
355360 async writeBundle (
@@ -390,7 +395,9 @@ export function createRollupDebugIdUploadHooks(
390395 } ;
391396}
392397
393- export function createComponentNameAnnotateHooks ( ignoredComponents ?: string [ ] ) {
398+ export function createComponentNameAnnotateHooks ( ignoredComponents ?: string [ ] ) : {
399+ transform : UnpluginOptions [ "transform" ] ;
400+ } {
394401 type ParserPlugins = NonNullable <
395402 NonNullable < Parameters < typeof transformAsync > [ 1 ] > [ "parserOpts" ]
396403 > [ "plugins" ] ;
0 commit comments