Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

fix(ts): allow Node.js package exports wildcard to cross directory boundaries (#1256)

Jyotirmya Sharma73d6882547cb
diff --git a/packages/core/src/repowise/core/ingestion/resolvers/ts_workspace.py b/packages/core/src/repowise/core/ingestion/resolvers/ts_workspace.py
index 80f5f567a..783d64b1f 100644
--- a/packages/core/src/repowise/core/ingestion/resolvers/ts_workspace.py
+++ b/packages/core/src/repowise/core/ingestion/resolvers/ts_workspace.py
@@ -452,12 +452,9 @@ def _expand_exports_wildcard(
continue
if suffix and not candidate.endswith(suffix):
continue
- # Reject paths whose captured segment crosses a directory boundary
- # unless the pattern itself spans dirs (``**`` is not part of the
- # spec; ``*`` matches a single segment).
- captured = candidate[len(base_prefix) : len(candidate) - len(suffix) if suffix else len(candidate)]
- if "/" in captured and exports_pattern.endswith("/*"):
- continue
+ # Node.js package exports spec explicitly allows the `*` wildcard
+ # to match any string including `/` (directory boundaries).
+ # We previously incorrectly rejected paths spanning directories.
matches.add(candidate)
return matches
diff --git a/tests/unit/ingestion/test_ts_workspace_index.py b/tests/unit/ingestion/test_ts_workspace_index.py
index af5fcd3b2..87b2a7673 100644
--- a/tests/unit/ingestion/test_ts_workspace_index.py
+++ b/tests/unit/ingestion/test_ts_workspace_index.py
@@ -61,6 +61,18 @@ class TestExportsWildcardEntries:
for p in paths:
assert p in index.exports_entry_paths, p
+ def test_wildcard_export_crosses_directory_boundaries(self, tmp_path: Path) -> None:
+ _write(tmp_path, "package.json", '{"workspaces":["packages/*"]}')
+ _write(
+ tmp_path,
+ "packages/zod/package.json",
+ '{"name":"@org/zod","exports":{"./*":"./src/*"}}',
+ )
+ _write(tmp_path, "packages/zod/src/a/b/c.ts", "export {};\n")
+ ctx = _ctx(tmp_path, ["packages/zod/src/a/b/c.ts"])
+ index = build_ts_workspace_index(ctx)
+ assert "packages/zod/src/a/b/c.ts" in index.exports_entry_paths
+
def test_main_field_marked_as_entry(self, tmp_path: Path) -> None:
_write(tmp_path, "package.json", '{"workspaces":["packages/*"]}')
_write(