diff options
author | Andreu Botella <andreu@andreubotella.com> | 2023-03-19 00:43:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-19 00:43:07 +0100 |
commit | b64ec7926831896f4e43b685891111409de45e85 (patch) | |
tree | b91550f9c21931f7bf691a6c298b64ff63c16041 /cli/tests/integration/compile_tests.rs | |
parent | a80d1b6e663bd439bd12b7c65cc1ac017bafb886 (diff) |
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".
Diffstat (limited to 'cli/tests/integration/compile_tests.rs')
-rw-r--r-- | cli/tests/integration/compile_tests.rs | 34 |
1 files changed, 34 insertions, 0 deletions
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); +} |