From b34e751a5b2193e8ce65203386e00147c08a7a64 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 15 Feb 2023 11:30:54 -0500 Subject: refactor: make resolver required (#17783) Makes the resolver required and prints a warning when vendoring and a dynamic import can't be resolved. Closes #16522 --- cli/tests/integration/run_tests.rs | 3 +++ cli/tests/integration/vendor_tests.rs | 8 ++++++++ cli/tests/testdata/vendor/dynamic_non_existent.ts | 11 +++++++++++ cli/tests/testdata/vendor/dynamic_non_existent.ts.out | 7 +++++++ 4 files changed, 29 insertions(+) create mode 100644 cli/tests/testdata/vendor/dynamic_non_existent.ts create mode 100644 cli/tests/testdata/vendor/dynamic_non_existent.ts.out (limited to 'cli/tests') diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index 3f2b8d81f..6baa408e9 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -3379,6 +3379,9 @@ async fn test_resolve_dns() { .unwrap(); let err = String::from_utf8_lossy(&output.stderr); let out = String::from_utf8_lossy(&output.stdout); + if !output.status.success() { + eprintln!("stderr: {err}"); + } assert!(output.status.success()); assert!(err.starts_with("Check file")); diff --git a/cli/tests/integration/vendor_tests.rs b/cli/tests/integration/vendor_tests.rs index cd2f7f12e..1f159fe80 100644 --- a/cli/tests/integration/vendor_tests.rs +++ b/cli/tests/integration/vendor_tests.rs @@ -478,6 +478,14 @@ fn dynamic_non_analyzable_import() { assert!(output.status.success()); } +itest!(dynamic_non_existent { + args: "vendor http://localhost:4545/vendor/dynamic_non_existent.ts", + temp_cwd: true, + exit_code: 0, + http_server: true, + output: "vendor/dynamic_non_existent.ts.out", +}); + #[test] fn update_existing_config_test() { let _server = http_server(); diff --git a/cli/tests/testdata/vendor/dynamic_non_existent.ts b/cli/tests/testdata/vendor/dynamic_non_existent.ts new file mode 100644 index 000000000..a48e2accb --- /dev/null +++ b/cli/tests/testdata/vendor/dynamic_non_existent.ts @@ -0,0 +1,11 @@ +// this should still vendor +// deno-lint-ignore no-constant-condition +if (false) { + await import("./non-existent.js"); +} + +export class Logger { + log(text: string) { + console.log(text); + } +} diff --git a/cli/tests/testdata/vendor/dynamic_non_existent.ts.out b/cli/tests/testdata/vendor/dynamic_non_existent.ts.out new file mode 100644 index 000000000..a1b2ade81 --- /dev/null +++ b/cli/tests/testdata/vendor/dynamic_non_existent.ts.out @@ -0,0 +1,7 @@ +Download http://localhost:4545/vendor/dynamic_non_existent.ts +Download http://localhost:4545/vendor/non-existent.js +Ignoring: Dynamic import not found "http://localhost:4545/vendor/non-existent.js". + at http://localhost:4545/vendor/dynamic_non_existent.ts:4:16 +Vendored 1 module into vendor/ directory. + +To use vendored modules, specify the `--import-map vendor/import_map.json` flag when invoking Deno subcommands or add an `"importMap": ""` entry to a deno.json file. -- cgit v1.2.3