Skip to content

Commit aeec360

Browse files
committed
Fix: Register workspace self-reference symlinks in package map for loose maps
When nodePackageMapType is 'loose' and workspace self-reference symlinks are created by register_workspace_symlinks_at, these entries must be registered with NodeModulesPackageMapBuilder so they appear in package_locations_by_node_modules_path. Without this registration, loose maps miss these workspace locations even though the symlinks exist, causing resolution failures that wouldn't occur without package maps.
1 parent 13aa7ed commit aeec360

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

  • packages/zpm/src/linker/nm

packages/zpm/src/linker/nm/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ fn register_workspace_symlinks_at(
8989
host_node: &hoist::WorkNode,
9090
host_abs_path: &Path,
9191
candidate_workspaces: impl IntoIterator<Item = (Ident, Path)>,
92+
mut package_map_builder: Option<&mut NodeModulesPackageMapBuilder>,
9293
) -> Result<(), Error> {
9394
let global_default = project.config.settings.nm_self_references.value;
9495
let host_children = host_node.children.as_ref();
@@ -147,9 +148,20 @@ fn register_workspace_symlinks_at(
147148
= workspace_dir
148149
.relative_to(&host_abs_path.with_join(&symlink_path).dirname().unwrap_or_default());
149150

151+
let abs_path
152+
= host_abs_path.with_join(&symlink_path);
153+
150154
workspace_nm_tree.register_entry(symlink_path, SyncItem::Symlink {
151155
target_path,
152156
})?;
157+
158+
if let Some(package_map_builder) = package_map_builder.as_deref_mut() {
159+
package_map_builder.register_package(
160+
abs_path,
161+
workspace_dir.clone(),
162+
&target_locator,
163+
);
164+
}
153165
}
154166

155167
Ok(())
@@ -270,6 +282,7 @@ fn generate_workspace_node_modules(
270282
&work_tree.nodes[workspace_node_idx],
271283
&workspace_abs_path,
272284
candidate_workspaces,
285+
package_map_builder.as_deref_mut(),
273286
)?;
274287
}
275288

0 commit comments

Comments
 (0)