1
1
import { basename , dirname , globToRegExp , join } from "https://deno.land/[email protected] /path/mod.ts" ;
2
2
import { JSONC } from "https://deno.land/x/[email protected] /src/jsonc.ts" ;
3
- import { findFile } from "../lib/fs.ts" ;
4
3
import { createGenerator } from "https://esm.sh/@unocss/[email protected] " ;
4
+ import { findFile } from "../lib/fs.ts" ;
5
5
import log from "../lib/log.ts" ;
6
6
import util from "../lib/util.ts" ;
7
7
import { isCanary , VERSION } from "../version.ts" ;
@@ -28,7 +28,7 @@ export function getAlephPkgUri() {
28
28
export function getUnoGenerator ( ) {
29
29
return globalIt ( "__UNO_GENERATOR" , ( ) => {
30
30
const config : AlephConfig | undefined = Reflect . get ( globalThis , "__ALEPH_CONFIG" ) ;
31
- if ( config ?. unocss ?. presets ?. length ) {
31
+ if ( config ?. unocss ?. presets ) {
32
32
return createGenerator ( config . unocss ) ;
33
33
}
34
34
return null ;
@@ -271,6 +271,19 @@ export async function parseImportMap(importMapFile: string): Promise<ImportMap>
271
271
return importMap ;
272
272
}
273
273
274
+ export function applyImportMap ( specifier : string , importMap : ImportMap ) : string {
275
+ if ( specifier in importMap . imports ) {
276
+ return importMap . imports [ specifier ] ;
277
+ }
278
+ for ( const key in importMap . imports ) {
279
+ if ( key . endsWith ( "/" ) && specifier . startsWith ( key ) ) {
280
+ return importMap . imports [ key ] + specifier . slice ( key . length ) ;
281
+ }
282
+ }
283
+ // todo: support scopes
284
+ return specifier ;
285
+ }
286
+
274
287
function toStringMap ( v : unknown ) : Record < string , string > {
275
288
const m : Record < string , string > = { } ;
276
289
if ( util . isPlainObject ( v ) ) {
0 commit comments