From 2e24385c487d5471aceae7d7e7de9da4c7d87064 Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Thu, 2 Apr 2020 14:14:30 +1100 Subject: Support dynamic import in bundles. (#4561) --- cli/tests/integration_tests.rs | 32 ++++++++++++++++++++++++++++++ cli/tests/subdir/subdir2/dynamic_import.ts | 6 ++++++ 2 files changed, 38 insertions(+) create mode 100644 cli/tests/subdir/subdir2/dynamic_import.ts (limited to 'cli') diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 8342da108..98c564b4d 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -490,6 +490,38 @@ fn bundle_js() { assert_eq!(output.stderr, b""); } +#[test] +fn bundle_dynamic_import() { + let dynamic_import = + util::root_path().join("cli/tests/subdir/subdir2/dynamic_import.ts"); + assert!(dynamic_import.is_file()); + let t = TempDir::new().expect("tempdir fail"); + let bundle = t.path().join("dynamic_import.bundle.js"); + let mut deno = util::deno_cmd() + .current_dir(util::root_path()) + .arg("bundle") + .arg(dynamic_import) + .arg(&bundle) + .spawn() + .expect("failed to spawn script"); + let status = deno.wait().expect("failed to wait for the child process"); + assert!(status.success()); + assert!(bundle.is_file()); + + let output = util::deno_cmd() + .current_dir(util::root_path()) + .arg("run") + .arg(&bundle) + .output() + .expect("failed to spawn script"); + // check the output of the test.ts program. + assert!(std::str::from_utf8(&output.stdout) + .unwrap() + .trim() + .ends_with("Hello")); + assert_eq!(output.stderr, b""); +} + #[test] fn repl_test_console_log() { let (out, err) = util::run_and_collect_output( diff --git a/cli/tests/subdir/subdir2/dynamic_import.ts b/cli/tests/subdir/subdir2/dynamic_import.ts new file mode 100644 index 000000000..a8921390d --- /dev/null +++ b/cli/tests/subdir/subdir2/dynamic_import.ts @@ -0,0 +1,6 @@ +(async (): Promise => { + const { printHello } = await import("../mod2.ts"); + printHello(); +})(); + +export {}; -- cgit v1.2.3