aboutsummaryrefslogtreecommitdiff
path: root/src/resolver/resolver.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/resolver/resolver.zig')
-rw-r--r--src/resolver/resolver.zig21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig
index 7f95dffae..06b486bb0 100644
--- a/src/resolver/resolver.zig
+++ b/src/resolver/resolver.zig
@@ -18,7 +18,7 @@ const HTTPWatcher = if (isTest) void else @import("../http.zig").Watcher;
const Wyhash = std.hash.Wyhash;
const ResolvePath = @import("./resolve_path.zig");
const NodeFallbackModules = @import("../node_fallbacks.zig");
-
+const Workspace = @import("./workspace.zig").Workspace;
const Mutex = @import("../lock.zig").Lock;
const StringBoolMap = std.StringHashMap(bool);
@@ -2561,6 +2561,7 @@ pub const Resolver = struct {
info.package_json_for_browser_field = parent.?.package_json_for_browser_field;
info.enclosing_tsconfig_json = parent.?.enclosing_tsconfig_json;
info.enclosing_package_json = parent.?.package_json orelse parent.?.enclosing_package_json;
+ info.enclosing_workspace = parent.enclosing_workspace;
// Make sure "absRealPath" is the real path of the directory (resolving any symlinks)
if (!r.opts.preserve_symlinks) {
@@ -2604,6 +2605,24 @@ pub const Resolver = struct {
}
info.enclosing_package_json = pkg;
+ const is_root = pkg.workspace_root or entries.hasComptimeQuery(".pnpm-workspace.yaml");
+
+ pkg.workspace_root = is_root;
+
+ if (is_root) {
+ var workspace = r.allocator.create(Workspace) catch unreachable;
+ workspace.* = Workspace{
+ .import_base_path = info.abs_path,
+ .package_json = pkg,
+ };
+
+ if (info.abs_real_path.len > 0) {
+ workspace.import_base_path = info.abs_real_path;
+ }
+
+ info.enclosing_workspace = workspace;
+ }
+
if (r.debug_logs) |*logs| {
logs.addNoteFmt("Resolved package.json in \"{s}\"", .{
path,