denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
95.33k stars 5.29k forks source link

Panic on inconsistent exports in package.json #26031

Open Skalman opened 1 week ago

Skalman commented 1 week ago

Version: Deno 2.0.0-rc.10

Steps to reproduce:

  1. Create a dir with a package.json containing { "exports": { ".": "./a", "a": "./a" } }
  2. Run RUST_BACKTRACE=1 deno task

Expected result: Some reasonable error message.

Result:

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: linux x86_64
Version: 2.0.0-rc.10
Args: ["deno", "task"]

thread 'main' panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_package_json-0.1.2/src/lib.rs:401:7:
"exports" cannot contains some keys starting with '.' and some not.
        The exports object must either be an object of package subpath keys
        or an object of main entry condition name keys only.
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: deno_package_json::PackageJson::load_from_value
   3: deno_package_json::PackageJson::load_from_path
   4: deno_config::workspace::discovery::discover_workspace_config_files_for_single_dir::{{closure}}
   5: deno_config::workspace::discovery::discover_workspace_config_files_for_single_dir
   6: deno_config::workspace::WorkspaceDirectory::discover
   7: deno::args::CliOptions::from_flags
   8: deno::factory::CliFactory::cli_options
   9: deno::tools::task::execute_script::{{closure}}
  10: deno::spawn_subcommand::{{closure}}
  11: <deno_unsync::tokio::task::MaskFutureAsSend<F> as core::future::future::Future>::poll
  12: tokio::runtime::task::raw::poll
  13: deno::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
marvinhagemeister commented 1 day ago

Related, the patch feature also fails instead of erroring when the exports shape is invalid https://github.com/denoland/deno/issues/25435