diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-03-19 03:39:53 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-18 12:39:53 -0400 |
commit | da8cb408c878aa6e90542e26173f1f14b5254d29 (patch) | |
tree | fda19fdecabb75cae8b2b5d3c72cdb9012a0af26 /cli/tests/integration_tests.rs | |
parent | 83f49161953c0c79056a56a19754fbf298f53f21 (diff) |
Provide compiled JSON to TypeScript compiler. (#4404)
Fixes #4101
Previously, we would just provide the raw JSON to the TypeScript
compiler worker, but TypeScript does not transform JSON. This caused
a problem when emitting a bundle, that the JSON would just be "inlined"
into the output, instead of being transformed into a module.
This fixes this problem by providing the compiled JSON to the TypeScript
compiler, so TypeScript just sees JSON as a "normal" TypeScript module.
Diffstat (limited to 'cli/tests/integration_tests.rs')
-rw-r--r-- | cli/tests/integration_tests.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 9cdf0af56..29203d411 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -399,6 +399,40 @@ fn bundle_single_module() { } #[test] +fn bundle_json() { + use tempfile::TempDir; + + let json_modules = util::root_path().join("cli/tests/020_json_modules.ts"); + assert!(json_modules.is_file()); + let t = TempDir::new().expect("tempdir fail"); + let bundle = t.path().join("020_json_modules.bundle.js"); + let mut deno = util::deno_cmd() + .current_dir(util::root_path()) + .arg("bundle") + .arg(json_modules) + .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("--reload") + .arg(&bundle) + .output() + .expect("failed to spawn script"); + // check the output of the the bundle program. + assert!(std::str::from_utf8(&output.stdout) + .unwrap() + .trim() + .ends_with("{\"foo\":{\"bar\":true,\"baz\":[\"qat\",1]}}")); + assert_eq!(output.stderr, b""); +} + +#[test] fn bundle_tla() { // First we have to generate a bundle of some module that has exports. let tla_import = util::root_path().join("cli/tests/subdir/tla.ts"); |