mirror of
https://github.com/denoland/deno.git
synced 2025-01-02 20:38:47 -05:00
fix(npm): don't fail if conditional exports don't contains types (#16651)
If resolving types for an npm package, we didn't find "types" entry in the conditional exports declaration we were falling-through to regular resolution, instead of short-circuiting and giving up on resolving types, which might lead to unwarranted errors. Closes https://github.com/denoland/deno/issues/16649
This commit is contained in:
parent
7aa8e9c035
commit
300fd07fad
7 changed files with 37 additions and 0 deletions
|
@ -688,6 +688,8 @@ fn package_config_resolve(
|
|||
legacy_main_resolve(&package_config, referrer_kind, conditions)
|
||||
{
|
||||
return Ok(Some(path));
|
||||
} else {
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
return package_exports_resolve(
|
||||
|
|
|
@ -263,6 +263,14 @@ itest!(types_ambient_module_import_map {
|
|||
exit_code: 1,
|
||||
});
|
||||
|
||||
itest!(no_types_in_conditional_exports {
|
||||
args: "run --check --unstable npm/no_types_in_conditional_exports/main.ts",
|
||||
output: "npm/no_types_in_conditional_exports/main.out",
|
||||
exit_code: 0,
|
||||
envs: env_vars(),
|
||||
http_server: true,
|
||||
});
|
||||
|
||||
#[test]
|
||||
fn parallel_downloading() {
|
||||
let (out, _err) = util::run_and_collect_output_with_args(
|
||||
|
|
5
cli/tests/testdata/npm/no_types_in_conditional_exports/main.out
vendored
Normal file
5
cli/tests/testdata/npm/no_types_in_conditional_exports/main.out
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
Download http://localhost:4545/npm/registry/@denotest/no-types-in-conditional-exports
|
||||
Download http://localhost:4545/npm/registry/@denotest/no-types-in-conditional-exports/1.0.0.tgz
|
||||
Check [WILDCARD]npm/no_types_in_conditional_exports/main.ts
|
||||
[WILDCARD]
|
||||
{ foo: "bar" }
|
2
cli/tests/testdata/npm/no_types_in_conditional_exports/main.ts
vendored
Normal file
2
cli/tests/testdata/npm/no_types_in_conditional_exports/main.ts
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
import foo from "npm:@denotest/no-types-in-conditional-exports@1.0.0";
|
||||
console.log(foo);
|
|
@ -0,0 +1,3 @@
|
|||
export default {
|
||||
"foo": "bar"
|
||||
};
|
3
cli/tests/testdata/npm/registry/@denotest/no-types-in-conditional-exports/1.0.0/lib/foo.js
vendored
Normal file
3
cli/tests/testdata/npm/registry/@denotest/no-types-in-conditional-exports/1.0.0/lib/foo.js
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
"foo": "bar"
|
||||
};
|
14
cli/tests/testdata/npm/registry/@denotest/no-types-in-conditional-exports/1.0.0/package.json
vendored
Normal file
14
cli/tests/testdata/npm/registry/@denotest/no-types-in-conditional-exports/1.0.0/package.json
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "@denotest/no-types-in-conditional-exports",
|
||||
"version": "1.0.0",
|
||||
"main": "./lib/foo.js",
|
||||
"module": "./lib/foo-esm.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./lib/foo.js",
|
||||
"import": "./lib/foo-esm.js"
|
||||
},
|
||||
"./*": "./*"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
Loading…
Reference in a new issue