This repository was archived by the owner on Sep 4, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,11 @@ import {
16
16
normalizeFilepath ,
17
17
pathExistsSync ,
18
18
isHttpURL ,
19
+ isInDenoDir ,
19
20
} from "./utils" ;
20
21
21
22
import { universalModuleResolver } from "./module_resolver/universal_module_resolver" ;
23
+ import { HashMeta } from "./module_resolver/hash_meta" ;
22
24
23
25
let logger : Logger ;
24
26
let pluginInfo : ts_module . server . PluginCreateInfo ;
@@ -471,10 +473,24 @@ function parseModuleName(
471
473
) : string | undefined {
472
474
if ( parsedImportMap != null ) {
473
475
try {
476
+ let scriptURL : URL ;
477
+ if ( isInDenoDir ( containingFile ) ) {
478
+ const meta = HashMeta . create ( `${ containingFile } .metadata.json` ) ;
479
+ if ( meta && meta . url ) {
480
+ scriptURL = meta . url ;
481
+ } else {
482
+ scriptURL = new URL ( "file:///" + path . dirname ( containingFile ) + "/" )
483
+ }
484
+ } else {
485
+ scriptURL = new URL ( "file:///" + path . dirname ( containingFile ) + "/" )
486
+ }
487
+
488
+ logger && logger . info ( `baseUrl: ${ scriptURL } ` )
489
+
474
490
const moduleUrl = resolve (
475
491
moduleName ,
476
492
parsedImportMap ,
477
- new URL ( "file:///" + path . dirname ( containingFile ) + "/" ) ,
493
+ scriptURL ,
478
494
) ;
479
495
480
496
if ( moduleUrl . protocol === "file:" ) {
Original file line number Diff line number Diff line change @@ -37,6 +37,12 @@ export function getDenoDepsDir(): string {
37
37
return path . join ( getDenoDir ( ) , "deps" ) ;
38
38
}
39
39
40
+ export function isInDenoDir ( filepath : string ) : boolean {
41
+ filepath = normalizeFilepath ( filepath ) ;
42
+ const denoDir = getDenoDir ( ) ;
43
+ return filepath . startsWith ( denoDir ) ;
44
+ }
45
+
40
46
export function getPluginPath (
41
47
tsLsHost : ts . LanguageServiceHost ,
42
48
) : string {
You can’t perform that action at this time.
0 commit comments