From 7aebd993721c9e2989e97203f3e29a3b4f0b4e0d Mon Sep 17 00:00:00 2001 From: ayushcodes10 Date: Wed, 16 Sep 2026 15:05:09 +0530 Subject: [PATCH] Add a unit test for scoped package subpath resolution A scoped package subpath lands on the scope plus package only, never on a different package that happens to share the same scope. Co-Authored-By: Claude Sonnet 5 (cherry picked from commit 02183335e32e844695766dd53e2c85cdd452be20) --- tests/test_phantom_external_import.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_phantom_external_import.py b/tests/test_phantom_external_import.py index 30d1041f1..f250423a3 100644 --- a/tests/test_phantom_external_import.py +++ b/tests/test_phantom_external_import.py @@ -60,6 +60,16 @@ def test_package_subpath_import_resolves_to_the_same_target_as_a_bare_import(): assert subpath_tgt == bare_tgt +def test_scoped_package_subpath_import_resolves_to_the_scope_and_package_only(): + bare_tgt, _ = _resolve_js_import_target("@scope/pkg", "src/bare.ts") + subpath_tgt, resolved_path = _resolve_js_import_target("@scope/pkg/deep/sub", "src/subpath.ts") + assert resolved_path is None + assert subpath_tgt == bare_tgt + # Must not fold onto a DIFFERENT package under the same scope. + other_tgt, _ = _resolve_js_import_target("@scope/other", "src/other.ts") + assert subpath_tgt != other_tgt + + # ── end-to-end: the reporter's exact synthetic monorepo ─────────────────────