diff --git a/cli/node/mod.rs b/cli/node/mod.rs index f2a645b5f6..7bb28d9843 100644 --- a/cli/node/mod.rs +++ b/cli/node/mod.rs @@ -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( diff --git a/cli/tests/integration/npm_tests.rs b/cli/tests/integration/npm_tests.rs index 3de6e5f2d9..787dab815c 100644 --- a/cli/tests/integration/npm_tests.rs +++ b/cli/tests/integration/npm_tests.rs @@ -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( diff --git a/cli/tests/testdata/npm/no_types_in_conditional_exports/main.out b/cli/tests/testdata/npm/no_types_in_conditional_exports/main.out new file mode 100644 index 0000000000..7d574aed26 --- /dev/null +++ b/cli/tests/testdata/npm/no_types_in_conditional_exports/main.out @@ -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" } diff --git a/cli/tests/testdata/npm/no_types_in_conditional_exports/main.ts b/cli/tests/testdata/npm/no_types_in_conditional_exports/main.ts new file mode 100644 index 0000000000..7ec2f18fd2 --- /dev/null +++ b/cli/tests/testdata/npm/no_types_in_conditional_exports/main.ts @@ -0,0 +1,2 @@ +import foo from "npm:@denotest/no-types-in-conditional-exports@1.0.0"; +console.log(foo); diff --git a/cli/tests/testdata/npm/registry/@denotest/no-types-in-conditional-exports/1.0.0/lib/foo-esm.js b/cli/tests/testdata/npm/registry/@denotest/no-types-in-conditional-exports/1.0.0/lib/foo-esm.js new file mode 100644 index 0000000000..0ead93520a --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/no-types-in-conditional-exports/1.0.0/lib/foo-esm.js @@ -0,0 +1,3 @@ +export default { + "foo": "bar" +}; \ No newline at end of file diff --git a/cli/tests/testdata/npm/registry/@denotest/no-types-in-conditional-exports/1.0.0/lib/foo.js b/cli/tests/testdata/npm/registry/@denotest/no-types-in-conditional-exports/1.0.0/lib/foo.js new file mode 100644 index 0000000000..dca03a472f --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/no-types-in-conditional-exports/1.0.0/lib/foo.js @@ -0,0 +1,3 @@ +module.exports = { + "foo": "bar" +}; \ No newline at end of file diff --git a/cli/tests/testdata/npm/registry/@denotest/no-types-in-conditional-exports/1.0.0/package.json b/cli/tests/testdata/npm/registry/@denotest/no-types-in-conditional-exports/1.0.0/package.json new file mode 100644 index 0000000000..5243944800 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/no-types-in-conditional-exports/1.0.0/package.json @@ -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" +}