From b64ec7926831896f4e43b685891111409de45e85 Mon Sep 17 00:00:00 2001 From: Andreu Botella Date: Sun, 19 Mar 2023 00:43:07 +0100 Subject: feat(compile): Enable multiple roots for a standalone module graph (#17663) This change will enable dynamic imports and web workers to use modules not reachable from the main module, by passing a list of extra side module roots as options to `deno compile`. This can be done by specifying "--include" flag that accepts a file path or a URL. This flag can be specified multiple times, to include several modules. The modules specified with "--include" flag, will be added to the produced "eszip". --- cli/tests/integration/compile_tests.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'cli/tests/integration/compile_tests.rs') diff --git a/cli/tests/integration/compile_tests.rs b/cli/tests/integration/compile_tests.rs index add53434f..828e04b1f 100644 --- a/cli/tests/integration/compile_tests.rs +++ b/cli/tests/integration/compile_tests.rs @@ -592,3 +592,37 @@ fn dynamic_import() { .unwrap(); assert_eq!(String::from_utf8(output.stdout).unwrap(), expected); } + +#[test] +fn dynamic_import_unanalyzable() { + let _guard = util::http_server(); + let dir = TempDir::new(); + let exe = if cfg!(windows) { + dir.path().join("dynamic_import_unanalyzable.exe") + } else { + dir.path().join("dynamic_import_unanalyzable") + }; + let output = util::deno_cmd() + .current_dir(util::root_path()) + .arg("compile") + .arg("--allow-read") + .arg("--include") + .arg(util::testdata_path().join("./compile/dynamic_imports/import1.ts")) + .arg("--output") + .arg(&exe) + .arg( + util::testdata_path() + .join("./compile/dynamic_imports/main_unanalyzable.ts"), + ) + .output() + .unwrap(); + assert!(output.status.success()); + + let output = Command::new(&exe).env("NO_COLOR", "").output().unwrap(); + assert!(output.status.success()); + let expected = std::fs::read_to_string( + util::testdata_path().join("./compile/dynamic_imports/main.out"), + ) + .unwrap(); + assert_eq!(String::from_utf8(output.stdout).unwrap(), expected); +} -- cgit v1.2.3