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 {
1616 normalizeFilepath ,
1717 pathExistsSync ,
1818 isHttpURL ,
19+ isInDenoDir ,
1920} from "./utils" ;
2021
2122import { universalModuleResolver } from "./module_resolver/universal_module_resolver" ;
23+ import { HashMeta } from "./module_resolver/hash_meta" ;
2224
2325let logger : Logger ;
2426let pluginInfo : ts_module . server . PluginCreateInfo ;
@@ -471,10 +473,24 @@ function parseModuleName(
471473) : string | undefined {
472474 if ( parsedImportMap != null ) {
473475 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+
474490 const moduleUrl = resolve (
475491 moduleName ,
476492 parsedImportMap ,
477- new URL ( "file:///" + path . dirname ( containingFile ) + "/" ) ,
493+ scriptURL ,
478494 ) ;
479495
480496 if ( moduleUrl . protocol === "file:" ) {
Original file line number Diff line number Diff line change @@ -37,6 +37,12 @@ export function getDenoDepsDir(): string {
3737 return path . join ( getDenoDir ( ) , "deps" ) ;
3838}
3939
40+ export function isInDenoDir ( filepath : string ) : boolean {
41+ filepath = normalizeFilepath ( filepath ) ;
42+ const denoDir = getDenoDir ( ) ;
43+ return filepath . startsWith ( denoDir ) ;
44+ }
45+
4046export function getPluginPath (
4147 tsLsHost : ts . LanguageServiceHost ,
4248) : string {
You can’t perform that action at this time.
0 commit comments