@@ -86,25 +86,23 @@ async function compileString(
86
86
environment : Less . Environment ,
87
87
) : Promise < Less . FileLoadResult > {
88
88
// Attempt direct loading as a relative path to avoid resolution overhead
89
- const directResult = this . loadFileSync ( filename , currentDirectory , options , environment ) ;
90
- if ( 'contents' in directResult ) {
91
- return directResult ;
89
+ try {
90
+ return await super . loadFile ( filename , currentDirectory , options , environment ) ;
91
+ } catch ( error ) {
92
+ // Attempt a full resolution if not found
93
+ const fullResult = await resolver ( filename , {
94
+ kind : 'import-rule' ,
95
+ resolveDir : currentDirectory ,
96
+ } ) ;
97
+ if ( fullResult . path ) {
98
+ return {
99
+ filename : fullResult . path ,
100
+ contents : await readFile ( fullResult . path , 'utf-8' ) ,
101
+ } ;
102
+ }
103
+ // Otherwise error by throwing the failing direct result
104
+ throw error ;
92
105
}
93
-
94
- // Attempt a full resolution if not found
95
- const fullResult = await resolver ( filename , {
96
- kind : 'import-rule' ,
97
- resolveDir : currentDirectory ,
98
- } ) ;
99
- if ( fullResult . path ) {
100
- return {
101
- filename : fullResult . path ,
102
- contents : await readFile ( fullResult . path , 'utf-8' ) ,
103
- } ;
104
- }
105
-
106
- // Otherwise error by throwing the failing direct result
107
- throw directResult . error ;
108
106
}
109
107
} ) ( ) ;
110
108
0 commit comments