1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-28 16:20:57 -05:00

fix(node): conditional exports edge case (#19082)

Fixes https://github.com/denoland/deno/issues/18743
This commit is contained in:
Bartek Iwańczuk 2023-05-10 23:55:48 +02:00 committed by David Sherret
parent 72512c95c1
commit 610936f5b2
5 changed files with 8 additions and 1 deletions

View file

@ -3,6 +3,7 @@ import foo from "npm:@denotest/conditional-exports/foo.js";
import client from "npm:@denotest/conditional-exports/client";
import clientFoo from "npm:@denotest/conditional-exports/client/foo";
import clientBar from "npm:@denotest/conditional-exports/client/bar";
import clientM from "npm:@denotest/conditional-exports/client/m";
import supportsESM from "npm:supports-esm";
console.log(mod);
@ -10,4 +11,5 @@ console.log(foo);
console.log(client);
console.log(clientFoo);
console.log(clientBar);
console.log(clientM);
console.log(supportsESM);

View file

@ -11,4 +11,5 @@ Download http://localhost:4545/npm/registry/supports-esm/supports-esm-1.0.0.tgz
{ hello: "from esm client" }
{ hello: "from esm client foo" }
{ hello: "from esm client bar" }
{ hello: "from esm client m" }
true

View file

@ -15,4 +15,5 @@ Initialize supports-esm@1.0.0
{ hello: "from esm client" }
{ hello: "from esm client foo" }
{ hello: "from esm client bar" }
{ hello: "from esm client m" }
true

View file

@ -0,0 +1,3 @@
export default {
hello: "from esm client m",
}

View file

@ -922,7 +922,7 @@ impl NodeResolver {
// emitTrailingSlashPatternDeprecation();
}
let pattern_trailer = &key[pattern_index + 1..];
if package_subpath.len() > key.len()
if package_subpath.len() >= key.len()
&& package_subpath.ends_with(&pattern_trailer)
&& pattern_key_compare(best_match, key) == 1
&& key.rfind('*') == Some(pattern_index)