1+ import { TextDecoder } from 'node:util' ;
2+ import { DEFAULT_EXTENSIONS , addDebugIdToSource , addDebugIdToSourcemap , stringToUUID } from '@debugids/common' ;
13import type { OutputAsset , OutputChunk , Plugin } from 'rollup' ;
2- import { addDebugIdToSourcemap , addDebugIdToSource , stringToUUID , DEFAULT_EXTENSIONS } from '@debugids/common' ;
3- import { TextDecoder } from 'util' ;
44
55function getString ( input : string | Uint8Array ) : string {
66 if ( typeof input === 'string' ) {
@@ -13,7 +13,7 @@ function getString(input: string | Uint8Array): string {
1313export default function debugIds ( ) : Plugin {
1414 return {
1515 name : 'rollup-plugin-debug-ids' ,
16- generateBundle : function ( _ , bundle : { [ fileName : string ] : OutputAsset | OutputChunk } ) {
16+ generateBundle : ( _ , bundle : { [ fileName : string ] : OutputAsset | OutputChunk } ) => {
1717 for ( const [ key , value ] of Object . entries ( bundle ) ) {
1818 // We only add debugId where there is a linked sourcemap file
1919 if ( ! ( 'sourcemapFileName' in value ) || ! value . sourcemapFileName ) {
@@ -38,8 +38,9 @@ export default function debugIds(): Plugin {
3838 // vite has a plugin that runs after us which can modify the sourcemap so we
3939 // proxy the sourceMapFile to re-add the debugId if the source gets set again
4040 bundle [ value . sourcemapFileName ] = new Proxy ( bundle [ value . sourcemapFileName ] as OutputAsset , {
41- set : function < K extends keyof OutputAsset > ( target : OutputAsset , prop : K , value : OutputAsset [ K ] ) {
41+ set : < K extends keyof OutputAsset > ( target : OutputAsset , prop : K , value : OutputAsset [ K ] ) => {
4242 if ( prop === 'source' ) {
43+ // biome-ignore lint/suspicious/noExplicitAny: Can't get types to work here
4344 ( target as any ) [ prop ] = addDebugIdToSourcemap ( getString ( value as string | Uint8Array ) , debugId ) ;
4445 } else {
4546 target [ prop ] = value ;
0 commit comments