diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/resolver/dir_info.zig | 2 | ||||
-rw-r--r-- | src/resolver/resolver.zig | 7 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/resolver/dir_info.zig b/src/resolver/dir_info.zig index c8c54c490..86d165df9 100644 --- a/src/resolver/dir_info.zig +++ b/src/resolver/dir_info.zig @@ -31,6 +31,8 @@ enclosing_tsconfig_json: ?*const TSConfigJSON = null, /// package.json used for bundling /// it's the deepest one in the hierarchy with a "name" field +/// or, if using `bun run`, the name field is optional +/// https://github.com/oven-sh/bun/issues/229 enclosing_package_json: ?*PackageJSON = null, abs_path: string = "", diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index 0a49e68a1..8dbbba50e 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -700,7 +700,7 @@ pub const Resolver = struct { while (iter.next()) |path| { var dir: *DirInfo = (r.readDirInfo(path.name.dir) catch continue) orelse continue; if (result.package_json) |existing| { - if (existing.name.len == 0) result.package_json = null; + if (existing.name.len == 0 or r.care_about_bin_folder) result.package_json = null; } result.package_json = result.package_json orelse dir.enclosing_package_json; @@ -2597,7 +2597,8 @@ pub const Resolver = struct { info.enclosing_tsconfig_json = parent.?.enclosing_tsconfig_json; if (parent.?.package_json) |parent_package_json| { - if (parent_package_json.name.len > 0) { + // https://github.com/oven-sh/bun/issues/229 + if (parent_package_json.name.len > 0 or r.care_about_bin_folder) { info.enclosing_package_json = parent_package_json; } } @@ -2645,7 +2646,7 @@ pub const Resolver = struct { info.package_json_for_browser_field = pkg; } - if (pkg.name.len > 0) + if (pkg.name.len > 0 or r.care_about_bin_folder) info.enclosing_package_json = pkg; if (r.debug_logs) |*logs| { |