@@ -291,7 +291,11 @@ func (p *Project) GetSourceFile(opts ast.SourceFileParseOptions) *ast.SourceFile
291291
292292// GetResolvedProjectReference implements compiler.CompilerHost.
293293func (p * Project ) GetResolvedProjectReference (fileName string , path tspath.Path ) * tsoptions.ParsedCommandLine {
294- // TODO, we might need to add the code below for pnp (converted to go)
294+ config := p .host .ConfigFileRegistry ().acquireConfig (fileName , path , p , nil )
295+ if config == nil {
296+ return nil
297+ }
298+ // TODO fix this and identify cases where we do need this
295299
296300 // With Plug'n'Play, dependencies that list peer dependencies
297301 // are "virtualized": they are resolved to a unique (virtual)
@@ -308,34 +312,43 @@ func (p *Project) GetResolvedProjectReference(fileName string, path tspath.Path)
308312 // user-provided references in our references by directly querying
309313 // the PnP API. This way users don't have to know the virtual paths,
310314 // but we still support them just fine even through references.
311-
312315 // pnpApi := pnp.GetPnpApi(fileName)
313316 // if pnpApi != nil {
314- // pnpApi.GetPackage(fileName)
317+ // basePath := p.GetCurrentDirectory()
318+
319+ // getPnpPath := func(path string) string {
320+ // targetLocator, err := pnpApi.FindLocator(path + "/")
321+ // if err != nil {
322+ // return path
323+ // }
324+
325+ // packageLocation := tspath.ResolvePath(basePath, pnpApi.GetPackage(targetLocator).PackageLocation)
326+
327+ // compareOptions := tspath.ComparePathsOptions{
328+ // UseCaseSensitiveFileNames: p.host.FS().UseCaseSensitiveFileNames(),
329+ // CurrentDirectory: basePath,
330+ // }
331+
332+ // request := tspath.CombinePaths(targetLocator.Name, tspath.GetRelativePathFromDirectory(packageLocation, path, compareOptions))
333+ // unqualified, err := pnpApi.ResolveToUnqualified(request, basePath+"/")
334+ // if err != nil {
335+ // return path
336+ // }
337+
338+ // return unqualified
339+ // }
340+
341+ // for _, ref := range config.ProjectReferences() {
342+ // ref.Path = getPnpPath(ref.Path)
343+ // }
344+
345+ // fmt.Println("Project refs after")
346+ // for _, ref := range config.ProjectReferences() {
347+ // fmt.Println("Project ref", ref.Path)
348+ // }
315349 // }
316350
317- // const basePath = this.getCurrentDirectory();
318-
319- // const getPnpPath = (path: string) => {
320- // try {
321- // const pnpApi = getPnpApi(`${path}/`);
322- // if (!pnpApi) {
323- // return path;
324- // }
325- // const targetLocator = pnpApi.findPackageLocator(`${path}/`);
326- // const { packageLocation } = pnpApi.getPackageInformation(targetLocator);
327- // const request = combinePaths(targetLocator.name, getRelativePathFromDirectory(packageLocation, path, /*ignoreCase*/ false));
328- // return pnpApi.resolveToUnqualified(request, `${basePath}/`);
329- // }
330- // catch {
331- // // something went wrong with the resolution, try not to fail
332- // return path;
333- // }
334- // };
335-
336- // Then run getPnpPath on all resolvedReferences from acquireConfig()
337-
338- return p .host .ConfigFileRegistry ().acquireConfig (fileName , path , p , nil )
351+ return config
339352}
340353
341354// Updates the program if needed.
0 commit comments