mirror of
https://github.com/zenstackhq/zenstack
synced 2026-05-24 10:08:55 +00:00
fix: VSCode extension fails to resolve imports from npm packages in pnpm workspaces (#1779)
This commit is contained in:
parent
f7ccc894ca
commit
d83b7eeed0
1 changed files with 10 additions and 3 deletions
|
|
@ -30,7 +30,7 @@ import {
|
|||
Mutable,
|
||||
Reference,
|
||||
} from 'langium';
|
||||
import { isAbsolute } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import { URI, Utils } from 'vscode-uri';
|
||||
import { findNodeModulesFile } from './pkg-utils';
|
||||
|
||||
|
|
@ -184,9 +184,16 @@ export function resolveImportUri(imp: ModelImport): URI | undefined {
|
|||
|
||||
if (
|
||||
!imp.path.startsWith('.') && // Respect relative paths
|
||||
!isAbsolute(imp.path) // Respect Absolute paths
|
||||
!path.isAbsolute(imp.path) // Respect Absolute paths
|
||||
) {
|
||||
imp.path = findNodeModulesFile(imp.path) ?? imp.path;
|
||||
// use the current model's path as the search context
|
||||
const contextPath = imp.$container.$document
|
||||
? path.dirname(imp.$container.$document.uri.fsPath)
|
||||
: process.cwd();
|
||||
imp.path = findNodeModulesFile(imp.path, contextPath) ?? imp.path;
|
||||
if (imp.path) {
|
||||
console.log('Loaded import from:', imp.path);
|
||||
}
|
||||
}
|
||||
|
||||
const dirUri = Utils.dirname(getDocument(imp).uri);
|
||||
|
|
|
|||
Loading…
Reference in a new issue