diff options
author | 2023-01-24 02:21:43 -0800 | |
---|---|---|
committer | 2023-01-24 02:21:43 -0800 | |
commit | e2f709b2a569bb0eff888ac518757c0b2a0dc3ae (patch) | |
tree | e16deec8061bc7605aab5b11ff6f82a60272d6de /src | |
parent | 4ea104f5bd2cef425051571dadf876d51a024d00 (diff) | |
download | bun-e2f709b2a569bb0eff888ac518757c0b2a0dc3ae.tar.gz bun-e2f709b2a569bb0eff888ac518757c0b2a0dc3ae.tar.zst bun-e2f709b2a569bb0eff888ac518757c0b2a0dc3ae.zip |
Always allow importing `${package}/package.json`
Diffstat (limited to 'src')
-rw-r--r-- | src/resolver/resolver.zig | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index 5ba5eb74f..ca96270f7 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -1485,6 +1485,18 @@ pub const Resolver = struct { if (r.handleESMResolution(esm_resolution, abs_package_path, kind, package_json, esm.subpath)) |result| { return .{ .success = result }; + // if they hid "package.json" from "exports", still allow importing it. + if (strings.eqlComptime(esm.subpath, "./package.json")) { + return .{ + .success = .{ + .path_pair = .{ .primary = package_json.source.path }, + .dirname_fd = pkg_dir_info.getFileDescriptor(), + .file_fd = 0, + .is_node_module = package_json.source.path.isNodeModule(), + .package_json = package_json, + .dir_info = dir_info, + }, + }; } return .{ .not_found = {} }; @@ -1704,6 +1716,19 @@ pub const Resolver = struct { var result_copy = result; result_copy.is_node_module = true; return .{ .success = result_copy }; + + // if they hid "package.json" from "exports", still allow importing it. + if (strings.eqlComptime(esm.subpath, "./package.json")) { + return .{ + .success = .{ + .path_pair = .{ .primary = package_json.source.path }, + .dirname_fd = pkg_dir_info.getFileDescriptor(), + .file_fd = 0, + .is_node_module = package_json.source.path.isNodeModule(), + .package_json = package_json, + .dir_info = dir_info, + }, + }; } return .{ .not_found = {} }; |