From 83d902a7803adb0c69fe2c98e692a50dae446db9 Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Tue, 3 Mar 2020 08:18:27 +1100 Subject: Fix JavaScript dependencies in bundles. (#4215) Fixes #4602 We turned off `allowJs` by default, to keep the compiler from grabbing a bunch of files that it wouldn't actually do anything useful with. On the other hand, this caused problems with bundles, where the compiler needs to gather all the dependencies, including JavaScript ones. This fixes this so that when we are bundling, we analyse JavaScript imports in the compiler. --- cli/tests/integration_tests.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'cli/tests') diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index d7e807793..a475e9111 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -436,6 +436,36 @@ fn bundle_tla() { assert_eq!(output.stderr, b""); } +#[test] +fn bundle_js() { + use tempfile::TempDir; + + // First we have to generate a bundle of some module that has exports. + let mod6 = util::root_path().join("cli/tests/subdir/mod6.js"); + assert!(mod6.is_file()); + let t = TempDir::new().expect("tempdir fail"); + let bundle = t.path().join("mod6.bundle.js"); + let mut deno = util::deno_cmd() + .current_dir(util::root_path()) + .arg("bundle") + .arg(mod6) + .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 that nothing went to stderr + assert_eq!(output.stderr, b""); +} + #[test] fn repl_test_console_log() { let (out, err, code) = util::run_and_collect_output( -- cgit v1.2.3