File tree 1 file changed +12
-23
lines changed
packages/vite/src/node/plugins
1 file changed +12
-23
lines changed Original file line number Diff line number Diff line change @@ -1054,32 +1054,21 @@ async function compileCSS(
1054
1054
}
1055
1055
}
1056
1056
1057
- const lazyImportCache = new Map ( )
1058
- function createCachedImport < T > (
1059
- name : string ,
1060
- imp : ( ) => Promise < T > ,
1061
- ) : ( ) => T | Promise < T > {
1057
+ function createCachedImport < T > ( imp : ( ) => Promise < T > ) : ( ) => T | Promise < T > {
1058
+ let cached : T | Promise < T >
1062
1059
return ( ) => {
1063
- const cached = lazyImportCache . get ( name )
1064
- if ( cached ) return cached
1065
-
1066
- const promise = imp ( ) . then ( ( module ) => {
1067
- lazyImportCache . set ( name , module )
1068
- return module
1069
- } )
1070
- lazyImportCache . set ( name , promise )
1071
- return promise
1060
+ if ( ! cached ) {
1061
+ cached = imp ( ) . then ( ( module ) => {
1062
+ cached = module
1063
+ return module
1064
+ } )
1065
+ }
1066
+ return cached
1072
1067
}
1073
1068
}
1074
- const importPostcssImport = createCachedImport (
1075
- 'postcss-import' ,
1076
- ( ) => import ( 'postcss-import' ) ,
1077
- )
1078
- const importPostcssModules = createCachedImport (
1079
- 'postcss-modules' ,
1080
- ( ) => import ( 'postcss-modules' ) ,
1081
- )
1082
- const importPostcss = createCachedImport ( 'postcss' , ( ) => import ( 'postcss' ) )
1069
+ const importPostcssImport = createCachedImport ( ( ) => import ( 'postcss-import' ) )
1070
+ const importPostcssModules = createCachedImport ( ( ) => import ( 'postcss-modules' ) )
1071
+ const importPostcss = createCachedImport ( ( ) => import ( 'postcss' ) )
1083
1072
1084
1073
export interface PreprocessCSSResult {
1085
1074
code : string
You can’t perform that action at this time.
0 commit comments