From 9f8826a3facff69db5159a7ce88f17b17f49543a Mon Sep 17 00:00:00 2001 From: Thijs Louisse Date: Thu, 16 May 2024 18:09:21 +0200 Subject: [PATCH] fix(providence): resolve scoped packages outside node_modules --- .changeset/old-lamps-clean.md | 5 +++++ .../program/utils/from-import-to-export-perspective.js | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changeset/old-lamps-clean.md diff --git a/.changeset/old-lamps-clean.md b/.changeset/old-lamps-clean.md new file mode 100644 index 000000000..d7d6a5b91 --- /dev/null +++ b/.changeset/old-lamps-clean.md @@ -0,0 +1,5 @@ +--- +'providence-analytics': patch +--- + +resolve scoped packages outside node_modules diff --git a/packages-node/providence-analytics/src/program/utils/from-import-to-export-perspective.js b/packages-node/providence-analytics/src/program/utils/from-import-to-export-perspective.js index 9ab8ade90..efc2519d2 100644 --- a/packages-node/providence-analytics/src/program/utils/from-import-to-export-perspective.js +++ b/packages-node/providence-analytics/src/program/utils/from-import-to-export-perspective.js @@ -38,7 +38,13 @@ export async function fromImportToExportPerspective({ importee, importer, import } 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) {