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 <noreply@anthropic.com>
(cherry picked from commit 02183335e3)
This commit is contained in:
ayushcodes10 authored and safishamsi committed 2026-09-17 11:01:38 +01:00
1 parent 3e9d22faf5
commit 7aebd99372
1 file changed
+10
+10
View File
@@ -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 ─────────────────────