@@ -9,7 +9,7 @@ export class CSSProcessor {
9
9
#isProd: boolean
10
10
#options: Required < CSSOptions >
11
11
#postcss: any
12
- #modulesJSON: Record < string , Record < string , string > >
12
+ #modulesJSON: Map < string , Record < string , string > >
13
13
14
14
constructor ( ) {
15
15
this . #isProd = false
@@ -18,7 +18,7 @@ export class CSSProcessor {
18
18
postcss : { plugins : [ 'autoprefixer' ] } ,
19
19
}
20
20
this . #postcss = null
21
- this . #modulesJSON = { }
21
+ this . #modulesJSON = new Map ( )
22
22
}
23
23
24
24
config ( isProd : boolean , options : CSSOptions ) {
@@ -36,21 +36,13 @@ export class CSSProcessor {
36
36
plugins . push ( [ 'postcss-modules' , {
37
37
...options . modules ,
38
38
getJSON : ( url : string , json : Record < string , string > ) => {
39
- this . #modulesJSON = { [ url ] : json }
39
+ this . #modulesJSON. set ( url , json )
40
40
} ,
41
41
} ] )
42
42
this . #options. postcss . plugins = plugins
43
43
}
44
44
}
45
45
46
- private getModulesJSON ( url : string ) {
47
- const json = this . #modulesJSON[ url ] || { }
48
- if ( url in this . #modulesJSON) {
49
- delete this . #modulesJSON[ url ]
50
- }
51
- return json
52
- }
53
-
54
46
async transform ( url : string , content : string ) : Promise < { code : string , map ?: string , classNames ?: Record < string , string > } > {
55
47
if ( util . isLikelyHttpURL ( url ) ) {
56
48
return {
@@ -67,7 +59,6 @@ export class CSSProcessor {
67
59
}
68
60
69
61
const { content : pcss } = await this . #postcss. process ( content , { from : url } ) . async ( )
70
- const modulesJSON = this . getModulesJSON ( url )
71
62
72
63
let css = pcss
73
64
if ( this . #isProd) {
@@ -91,6 +82,9 @@ export class CSSProcessor {
91
82
}
92
83
}
93
84
85
+ const modulesJSON = this . #modulesJSON. get ( url ) || { }
86
+ this . #modulesJSON. delete ( url )
87
+
94
88
return {
95
89
code : [
96
90
`import { applyCSS } from "https://deno.land/x/aleph/framework/core/style.ts"` ,
0 commit comments