@@ -4,15 +4,9 @@ import SentryCli from "@sentry/cli";
4
4
import { logger } from "@sentry/utils" ;
5
5
import * as fs from "fs" ;
6
6
import { glob } from "glob" ;
7
- import MagicString from "magic-string" ;
7
+ import MagicString , { SourceMap } from "magic-string" ;
8
8
import * as path from "path" ;
9
- import {
10
- createUnplugin ,
11
- RollupPlugin ,
12
- TransformResult ,
13
- UnpluginInstance ,
14
- UnpluginOptions ,
15
- } from "unplugin" ;
9
+ import { createUnplugin , TransformResult , UnpluginInstance , UnpluginOptions } from "unplugin" ;
16
10
import { createSentryBuildPluginManager } from "./build-plugin-manager" ;
17
11
import { createDebugIdUploadFunction } from "./debug-id-upload" ;
18
12
import { Logger } from "./logger" ;
@@ -273,8 +267,23 @@ const COMMENT_USE_STRICT_REGEX =
273
267
// Note: CodeQL complains that this regex potentially has n^2 runtime. This likely won't affect realistic files.
274
268
/ ^ (?: \s * | \/ \* (?: .| \r | \n ) * ?\* \/ | \/ \/ .* [ \n \r ] ) * (?: " [ ^ " ] * " ; | ' [ ^ ' ] * ' ; ) ? / ;
275
269
270
+ /**
271
+ * Simplified `renderChunk` hook type from Rollup.
272
+ * We can't reference the type directly because the Vite plugin complains
273
+ * about type mismatches
274
+ */
275
+ type RenderChunkHook = (
276
+ code : string ,
277
+ chunk : {
278
+ fileName : string ;
279
+ }
280
+ ) => {
281
+ code : string ;
282
+ map : SourceMap ;
283
+ } | null ;
284
+
276
285
export function createRollupDebugIdInjectionHooks ( ) : {
277
- renderChunk : RollupPlugin [ "renderChunk" ] ;
286
+ renderChunk : RenderChunkHook ;
278
287
} {
279
288
return {
280
289
renderChunk ( code : string , chunk : { fileName : string } ) {
@@ -313,7 +322,7 @@ export function createRollupDebugIdInjectionHooks(): {
313
322
}
314
323
315
324
export function createRollupModuleMetadataInjectionHooks ( injectionCode : string ) : {
316
- renderChunk : RollupPlugin [ "renderChunk" ] ;
325
+ renderChunk : RenderChunkHook ;
317
326
} {
318
327
return {
319
328
renderChunk ( code : string , chunk : { fileName : string } ) {
@@ -353,7 +362,10 @@ export function createRollupDebugIdUploadHooks(
353
362
_logger : Logger ,
354
363
createDependencyOnBuildArtifacts : ( ) => ( ) => void
355
364
) : {
356
- writeBundle : RollupPlugin [ "writeBundle" ] ;
365
+ writeBundle : (
366
+ outputOptions : { dir ?: string ; file ?: string } ,
367
+ bundle : { [ fileName : string ] : unknown }
368
+ ) => Promise < void > ;
357
369
} {
358
370
const freeGlobalDependencyOnDebugIdSourcemapArtifacts = createDependencyOnBuildArtifacts ( ) ;
359
371
return {
0 commit comments