mirror of
https://github.com/denoland/deno.git
synced 2025-01-15 02:20:15 -05:00
fix(npm): use original node regex in npm resolution (#17404)
Fixes regex for matching conditional exports in a package. Updated to the same regex Node.js uses.
This commit is contained in:
parent
8e0c2f34fa
commit
c7bff76c41
5 changed files with 9 additions and 2 deletions
|
@ -1,10 +1,12 @@
|
||||||
import mod from "npm:@denotest/conditional-exports";
|
import mod from "npm:@denotest/conditional-exports";
|
||||||
|
import foo from "npm:@denotest/conditional-exports/foo.js";
|
||||||
import client from "npm:@denotest/conditional-exports/client";
|
import client from "npm:@denotest/conditional-exports/client";
|
||||||
import clientFoo from "npm:@denotest/conditional-exports/client/foo";
|
import clientFoo from "npm:@denotest/conditional-exports/client/foo";
|
||||||
import clientBar from "npm:@denotest/conditional-exports/client/bar";
|
import clientBar from "npm:@denotest/conditional-exports/client/bar";
|
||||||
import supportsESM from "npm:supports-esm";
|
import supportsESM from "npm:supports-esm";
|
||||||
|
|
||||||
console.log(mod);
|
console.log(mod);
|
||||||
|
console.log(foo);
|
||||||
console.log(client);
|
console.log(client);
|
||||||
console.log(clientFoo);
|
console.log(clientFoo);
|
||||||
console.log(clientBar);
|
console.log(clientBar);
|
||||||
|
|
|
@ -7,6 +7,7 @@ Download http://localhost:4545/npm/registry/@ljharb/has-package-exports-patterns
|
||||||
Download http://localhost:4545/npm/registry/has-package-exports/has-package-exports-1.3.0.tgz
|
Download http://localhost:4545/npm/registry/has-package-exports/has-package-exports-1.3.0.tgz
|
||||||
Download http://localhost:4545/npm/registry/supports-esm/supports-esm-1.0.0.tgz
|
Download http://localhost:4545/npm/registry/supports-esm/supports-esm-1.0.0.tgz
|
||||||
{ hello: "from esm" }
|
{ hello: "from esm" }
|
||||||
|
{ hello: "from foo" }
|
||||||
{ hello: "from esm client" }
|
{ hello: "from esm client" }
|
||||||
{ hello: "from esm client foo" }
|
{ hello: "from esm client foo" }
|
||||||
{ hello: "from esm client bar" }
|
{ hello: "from esm client bar" }
|
||||||
|
|
3
cli/tests/testdata/npm/registry/@denotest/conditional-exports/1.0.0/foo.js
vendored
Normal file
3
cli/tests/testdata/npm/registry/@denotest/conditional-exports/1.0.0/foo.js
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export default {
|
||||||
|
hello: "from foo",
|
||||||
|
}
|
|
@ -15,6 +15,7 @@
|
||||||
"./client/*": {
|
"./client/*": {
|
||||||
"types": "./types/src/client/*.d.ts",
|
"types": "./types/src/client/*.d.ts",
|
||||||
"import": "./esm/client/*.js"
|
"import": "./esm/client/*.js"
|
||||||
}
|
},
|
||||||
|
"./*": "./*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -339,7 +339,7 @@ fn resolve_package_target_string(
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let invalid_segment_re =
|
let invalid_segment_re =
|
||||||
Regex::new(r"(^|\|/)(..?|node_modules)(\|/|$)").expect("bad regex");
|
Regex::new(r"(^|\\|/)(\.\.?|node_modules)(\\|/|$)").expect("bad regex");
|
||||||
let pattern_re = Regex::new(r"\*").expect("bad regex");
|
let pattern_re = Regex::new(r"\*").expect("bad regex");
|
||||||
if !target.starts_with("./") {
|
if !target.starts_with("./") {
|
||||||
if internal && !target.starts_with("../") && !target.starts_with('/') {
|
if internal && !target.starts_with("../") && !target.starts_with('/') {
|
||||||
|
|
Loading…
Reference in a new issue