fix(providence): resolve scoped packages outside node_modules

This commit is contained in:
Thijs Louisse 2024-05-16 18:09:21 +02:00 committed by Thijs Louisse
parent 6c5b89c06f
commit 9f8826a3fa
2 changed files with 12 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'providence-analytics': patch
---
resolve scoped packages outside node_modules

View file

@ -38,7 +38,13 @@ export async function fromImportToExportPerspective({ importee, importer, import
} }
const absolutePath = await resolveImportPath(importee, importer, { const absolutePath = await resolveImportPath(importee, importer, {
modulePaths: [path.resolve(importeeProjectPath, '..')], // Usually, we resolve from `{importer}/node_modules`.
// In some contexts, the package we are looking for is not in the importer's node_modules.
// In that case it is either 2 levels (in cases of a scoped package) up or 1 level up.
modulePaths: [
path.resolve(importeeProjectPath, '..'),
path.resolve(importeeProjectPath, '../..'),
],
}); });
if (!absolutePath) { if (!absolutePath) {