@@ -220,12 +220,14 @@ const warnUnsupportedProtocol = memoize((protocol: string, dependency: string):
220220export const transformSourceDependencies = (
221221 cssDependencies : Set < string > | null ,
222222 jsDependencies : Set < string > | null ,
223+ pngDependencies : Set < string > | null ,
223224 mapDependencyPathFn ?: null | ( ( relativePath : string ) => string | void ) ,
224225) : NormalizedDependencies => {
225226 const nodeModulesLabel = "node_modules/" ;
226227 const cssSet : Set < string > = new Set ( ) ;
227228 const jsSet : Set < string > = new Set ( ) ;
228229 const modulesSet : Set < string > = new Set ( ) ;
230+ const pngSet : Set < string > = new Set ( ) ;
229231
230232 const classifyDependency = ( dependency : string , typedResultSet : Set < string > ) : void => {
231233 dependency = decodeURIComponent ( softFileURLToPath ( dependency ) ) ;
@@ -291,12 +293,19 @@ export const transformSourceDependencies = (
291293 }
292294 }
293295
296+ if ( pngDependencies ) {
297+ for ( const pngDependency of pngDependencies . values ( ) ) {
298+ classifyDependency ( pngDependency , pngSet ) ;
299+ }
300+ }
301+
294302 const cmpStr = ( a : string , b : string ) : number => a . localeCompare ( b ) ;
295303
296304 return {
297305 css : Array . from ( cssSet ) . sort ( cmpStr ) ,
298306 js : Array . from ( jsSet ) . sort ( cmpStr ) ,
299307 modules : Array . from ( modulesSet ) . sort ( cmpStr ) ,
308+ png : Array . from ( pngSet ) . sort ( cmpStr ) ,
300309 } ;
301310} ;
302311
@@ -305,12 +314,26 @@ export const mergeSourceDependencies = (
305314 a : NormalizedDependencies ,
306315 b : NormalizedDependencies ,
307316) : NormalizedDependencies => {
308- const result : NormalizedDependencies = { css : [ ] , js : [ ] , modules : [ ] } ;
317+ const result : NormalizedDependencies = { css : [ ] , js : [ ] , modules : [ ] , png : [ ] } ;
309318
310319 for ( const depType of Object . keys ( result ) as Array < keyof NormalizedDependencies > ) {
311320 let aInd = 0 ,
312321 bInd = 0 ;
313322
323+ if ( ! a [ depType ] ) {
324+ if ( ! b [ depType ] ) {
325+ continue ;
326+ }
327+
328+ result [ depType ] = b [ depType ] ;
329+
330+ continue ;
331+ } else if ( ! b [ depType ] ) {
332+ result [ depType ] = a [ depType ] ;
333+
334+ continue ;
335+ }
336+
314337 while ( aInd < a [ depType ] . length || bInd < b [ depType ] . length ) {
315338 let compareResult ;
316339
@@ -392,13 +415,30 @@ export const getTestDependenciesPath = (selectivityTestsPath: string, test: Test
392415 path . join ( selectivityTestsPath , `${ getTestSelectivityDumpId ( test ) } .json` ) ;
393416
394417/** @returns `Promise<Record<BrowserID, Record<DepType, NormalizedDependencies>>>` */
395- export const readTestDependencies = (
418+ export const readTestDependencies = async (
396419 selectivityTestsPath : string ,
397420 test : Test ,
398421 compression : SelectivityCompressionType ,
399- ) : Promise < TestDependenciesFileContents > =>
400- readJsonWithCompression ( getTestDependenciesPath ( selectivityTestsPath , test ) , compression , {
422+ ) : Promise < TestDependenciesFileContents > => {
423+ const result = ( await readJsonWithCompression ( getTestDependenciesPath ( selectivityTestsPath , test ) , compression , {
401424 defaultValue : { } ,
402- } ) . catch ( ( ) => ( { } ) ) ;
425+ } ) . catch ( ( ) => ( { } ) ) ) as Record <
426+ string ,
427+ Record < string , Partial < NormalizedDependencies > & Pick < NormalizedDependencies , "css" | "js" | "modules" | "png" > >
428+ > ;
429+
430+ for ( const browserId in result ) {
431+ for ( const depType in result [ browserId ] ) {
432+ const currentDeps = result [ browserId ] [ depType ] ;
433+
434+ currentDeps . css ||= [ ] ;
435+ currentDeps . js ||= [ ] ;
436+ currentDeps . modules ||= [ ] ;
437+ currentDeps . png ||= [ ] ;
438+ }
439+ }
440+
441+ return result ;
442+ } ;
403443
404444export const isCachedOnFs = ( value : unknown ) : value is CachedOnFs => value === true ;
0 commit comments