aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/resolve.test.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-24 02:21:43 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-24 02:21:43 -0800
commite2f709b2a569bb0eff888ac518757c0b2a0dc3ae (patch)
treee16deec8061bc7605aab5b11ff6f82a60272d6de /test/bun.js/resolve.test.js
parent4ea104f5bd2cef425051571dadf876d51a024d00 (diff)
downloadbun-e2f709b2a569bb0eff888ac518757c0b2a0dc3ae.tar.gz
bun-e2f709b2a569bb0eff888ac518757c0b2a0dc3ae.tar.zst
bun-e2f709b2a569bb0eff888ac518757c0b2a0dc3ae.zip
Always allow importing `${package}/package.json`
Diffstat (limited to 'test/bun.js/resolve.test.js')
-rw-r--r--test/bun.js/resolve.test.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/bun.js/resolve.test.js b/test/bun.js/resolve.test.js
index 80e2bb7ba..b794c7604 100644
--- a/test/bun.js/resolve.test.js
+++ b/test/bun.js/resolve.test.js
@@ -97,6 +97,16 @@ it("import.meta.resolve", async () => {
join(import.meta.path, "../node_modules/package-json-exports/foo/bar.js"),
);
+ // if they never exported /package.json, allow reading from it too
+ expect(await import.meta.resolve("package-json-exports/package.json")).toBe(
+ join(import.meta.path, "../node_modules/package-json-exports/package.json"),
+ );
+
+ // if an unnecessary ".js" extension was added, try against /baz
+ expect(await import.meta.resolve("package-json-exports/baz.js")).toBe(
+ join(import.meta.path, "../node_modules/package-json-exports/foo/bar.js"),
+ );
+
// works with TypeScript compiler edgecases like:
// - If the file ends with .js and it doesn't exist, try again with .ts and .tsx
expect(await import.meta.resolve("./resolve-typescript-file.js")).toBe(