@@ -207,7 +207,7 @@ export class Engine {
207
207
fontFace : fontFaceCache ,
208
208
static : staticCache ,
209
209
rule : ruleCache
210
- } = usedIds ?? this . getUsedCacheIds ( filePaths ?? Object . keys ( this . usedIds ) ) ;
210
+ } = usedIds ?? this . getCacheIds ( filePaths ?? Object . keys ( this . usedIds ) ) ;
211
211
212
212
const { atRules, lowPrioRules, rules } = splitStyleBlocks ( this . caches . rule . items ( ruleCache ) ) ;
213
213
@@ -258,8 +258,16 @@ export class Engine {
258
258
}
259
259
260
260
serialize ( ) {
261
- const { caches, usedIds, identifierCount, sourceMapReferences } = this ;
262
- return JSON . stringify ( { caches, usedIds, identifierCount, sourceMapReferences } ) ;
261
+ const { caches, usedIds, identifierCount, sourceMapReferences : sourceMapReferencesData } = this ;
262
+
263
+ const sourceMapReferences = this . options . enableSourceMaps ? sourceMapReferencesData : undefined ;
264
+
265
+ return JSON . stringify ( {
266
+ caches,
267
+ usedIds,
268
+ identifierCount,
269
+ sourceMapReferences,
270
+ } ) ;
263
271
}
264
272
265
273
async deserialize ( buffer : Buffer | string ) {
@@ -284,6 +292,17 @@ export class Engine {
284
292
this . filePath = filePath ;
285
293
}
286
294
295
+ getUsedFilePaths ( ) {
296
+ return Object . keys ( this . usedIds ) ;
297
+ }
298
+
299
+ getItems ( caches : UsedIdCache ) {
300
+ return Object . keys ( caches ) . reduce ( ( acc , key ) => ( {
301
+ ...acc ,
302
+ [ key ] : this . caches [ key as CacheKeys ] . items ( caches [ key as CacheKeys ] ) ,
303
+ } ) , { } ) ;
304
+ }
305
+
287
306
clearUsedIds ( filePath : string ) {
288
307
if ( filePath === undefined ) {
289
308
return ;
@@ -318,7 +337,7 @@ export class Engine {
318
337
] ;
319
338
}
320
339
321
- getUsedCacheIds ( filePaths : string [ ] = [ ] ) {
340
+ getCacheIds ( filePaths : string [ ] = [ ] ) {
322
341
return filePaths . reduce ( ( acc , filePath ) => ( {
323
342
...acc ,
324
343
...Object . keys ( this . usedIds [ filePath ] || [ ] ) . reduce ( ( cache , key ) => ( {
0 commit comments