@@ -4,15 +4,9 @@ import SentryCli from "@sentry/cli";
44import { logger } from "@sentry/utils" ;
55import * as fs from "fs" ;
66import { glob } from "glob" ;
7- import MagicString from "magic-string" ;
7+ import MagicString , { SourceMap } from "magic-string" ;
88import * 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" ;
1610import { createSentryBuildPluginManager } from "./build-plugin-manager" ;
1711import { createDebugIdUploadFunction } from "./debug-id-upload" ;
1812import { Logger } from "./logger" ;
@@ -273,8 +267,23 @@ const COMMENT_USE_STRICT_REGEX =
273267 // Note: CodeQL complains that this regex potentially has n^2 runtime. This likely won't affect realistic files.
274268 / ^ (?: \s * | \/ \* (?: .| \r | \n ) * ?\* \/ | \/ \/ .* [ \n \r ] ) * (?: " [ ^ " ] * " ; | ' [ ^ ' ] * ' ; ) ? / ;
275269
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+
276285export function createRollupDebugIdInjectionHooks ( ) : {
277- renderChunk : RollupPlugin [ "renderChunk" ] ;
286+ renderChunk : RenderChunkHook ;
278287} {
279288 return {
280289 renderChunk ( code : string , chunk : { fileName : string } ) {
@@ -313,7 +322,7 @@ export function createRollupDebugIdInjectionHooks(): {
313322}
314323
315324export function createRollupModuleMetadataInjectionHooks ( injectionCode : string ) : {
316- renderChunk : RollupPlugin [ "renderChunk" ] ;
325+ renderChunk : RenderChunkHook ;
317326} {
318327 return {
319328 renderChunk ( code : string , chunk : { fileName : string } ) {
@@ -353,7 +362,10 @@ export function createRollupDebugIdUploadHooks(
353362 _logger : Logger ,
354363 createDependencyOnBuildArtifacts : ( ) => ( ) => void
355364) : {
356- writeBundle : RollupPlugin [ "writeBundle" ] ;
365+ writeBundle : (
366+ outputOptions : { dir ?: string ; file ?: string } ,
367+ bundle : { [ fileName : string ] : unknown }
368+ ) => Promise < void > ;
357369} {
358370 const freeGlobalDependencyOnDebugIdSourcemapArtifacts = createDependencyOnBuildArtifacts ( ) ;
359371 return {
0 commit comments