From b703d3126eeae9e4cd3be291d4f28588daae9c2b Mon Sep 17 00:00:00 2001 From: ayushcodes10 Date: Wed, 16 Sep 2026 15:04:59 +0530 Subject: [PATCH] Add a unit test for plain package subpath resolution A plain package subpath now lands on the same resolver target as its bare import. Co-Authored-By: Claude Sonnet 5 --- tests/test_phantom_external_import.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_phantom_external_import.py b/tests/test_phantom_external_import.py index c30f334ab..30d1041f1 100644 --- a/tests/test_phantom_external_import.py +++ b/tests/test_phantom_external_import.py @@ -48,6 +48,18 @@ def test_scoped_package_import_is_ref_namespaced(): assert tgt.startswith("ref") +# ── #3595: a package subpath import must resolve to the package root, not the ─ +# whole specifier, so it lands on the same node as a bare import of that +# package (and the package.json dependency node itself) instead of dangling. + + +def test_package_subpath_import_resolves_to_the_same_target_as_a_bare_import(): + bare_tgt, _ = _resolve_js_import_target("next", "src/bare.ts") + subpath_tgt, resolved_path = _resolve_js_import_target("next/image", "src/subpath.ts") + assert resolved_path is None + assert subpath_tgt == bare_tgt + + # ── end-to-end: the reporter's exact synthetic monorepo ─────────────────────