From 4b7d3b060e88c02bc0ca12664f52111a4666b167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 10 Jun 2020 16:02:41 +0200 Subject: fix: several regressions in TS compiler (#6177) This commit fixes several regressions in TS compiler: * double compilation of same module during same process run * compilation of JavaScript entry point with non-JS imports * unexpected skip of emit during compilation Additional checks were added to ensure "allowJs" setting is used in TS compiler if JavaScript has non-JS dependencies. --- cli/tests/integration_tests.rs | 6 ++++++ cli/tests/single_compile_with_reload.ts | 4 ++++ cli/tests/single_compile_with_reload.ts.out | 5 +++++ cli/tests/ts_import_from_js.deps.js | 2 ++ cli/tests/ts_import_from_js.js | 4 +++- cli/tests/ts_import_from_js.js.out | 2 ++ 6 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 cli/tests/single_compile_with_reload.ts create mode 100644 cli/tests/single_compile_with_reload.ts.out create mode 100644 cli/tests/ts_import_from_js.deps.js (limited to 'cli/tests') diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index c62a9a501..fafce3eb0 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -1938,6 +1938,12 @@ itest!(cjs_imports { itest!(ts_import_from_js { args: "run --quiet --reload ts_import_from_js.js", output: "ts_import_from_js.js.out", + http_server: true, +}); + +itest!(single_compile_with_reload { + args: "run --reload --allow-read single_compile_with_reload.ts", + output: "single_compile_with_reload.ts.out", }); itest!(proto_exploit { diff --git a/cli/tests/single_compile_with_reload.ts b/cli/tests/single_compile_with_reload.ts new file mode 100644 index 000000000..3dd728366 --- /dev/null +++ b/cli/tests/single_compile_with_reload.ts @@ -0,0 +1,4 @@ +await import("./005_more_imports.ts"); +console.log("1"); +await import("./005_more_imports.ts"); +console.log("2"); diff --git a/cli/tests/single_compile_with_reload.ts.out b/cli/tests/single_compile_with_reload.ts.out new file mode 100644 index 000000000..2cdd71673 --- /dev/null +++ b/cli/tests/single_compile_with_reload.ts.out @@ -0,0 +1,5 @@ +Compile [WILDCARD]single_compile_with_reload.ts +Compile [WILDCARD]005_more_imports.ts +Hello +1 +2 diff --git a/cli/tests/ts_import_from_js.deps.js b/cli/tests/ts_import_from_js.deps.js new file mode 100644 index 000000000..bfea5ac79 --- /dev/null +++ b/cli/tests/ts_import_from_js.deps.js @@ -0,0 +1,2 @@ +import "./005_more_imports.ts"; +export { printHello } from "http://localhost:4545/cli/tests/subdir/mod2.ts"; diff --git a/cli/tests/ts_import_from_js.js b/cli/tests/ts_import_from_js.js index e06ca15a2..f912c2723 100644 --- a/cli/tests/ts_import_from_js.js +++ b/cli/tests/ts_import_from_js.js @@ -1 +1,3 @@ -import "./005_more_imports.ts"; +import { printHello } from "./ts_import_from_js.deps.js"; +printHello(); +console.log("success"); diff --git a/cli/tests/ts_import_from_js.js.out b/cli/tests/ts_import_from_js.js.out index e965047ad..e1d7a869f 100644 --- a/cli/tests/ts_import_from_js.js.out +++ b/cli/tests/ts_import_from_js.js.out @@ -1 +1,3 @@ Hello +Hello +success -- cgit v1.2.3