summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorBartek Iwańczuk <biwanczuk@gmail.com>2020-06-24 16:59:12 +0200
committerGitHub <noreply@github.com>2020-06-24 16:59:12 +0200
commit3cbd1075c78703b4852760ec5bfa2e4dbb53c737 (patch)
tree2607a294047f42c18899a3fb0bdba89ce8e02f49 /cli/tests
parent3314b463215a8e59ec46d722adb70a22cd3ef832 (diff)
Incremental compilation for TypeScript (#6428)
This commit adds incremental compilation capabilities to internal TS compiler. Instead of using "ts.createProgram()" API for compilation step (during deno startup), "ts.createIncrementalProgram()" API is used instead. Thanks to TS' ".tsbuildinfo" file that already stores all necessary metadata for compilation I was able to remove our own invention that is ".graph" file. ".tsbuildinfo" file is stored alongside compiled source and is used to cache-bust outdated dependencies, facilitated by the "version" field. The value for "version" field is computed in Rust during loading of module graph and is basically a hash of the file contents. Please keep in mind that incremental compilation is only used for initial compilation (or dynamic imports compilation) - bundling and runtime compiler APIs haven't been changed at all. Due to problems with source map I changed compilation settings to inline source map (inlineSourceMap instead of sourceMap).
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/054_info_local_imports.out1
-rw-r--r--cli/tests/integration_tests.rs2
-rw-r--r--cli/tests/single_compile_with_reload.ts4
-rw-r--r--cli/tests/single_compile_with_reload.ts.out2
-rw-r--r--cli/tests/single_compile_with_reload_dyn.ts11
5 files changed, 15 insertions, 5 deletions
diff --git a/cli/tests/054_info_local_imports.out b/cli/tests/054_info_local_imports.out
index 9794e4ede..32cfd8525 100644
--- a/cli/tests/054_info_local_imports.out
+++ b/cli/tests/054_info_local_imports.out
@@ -1,7 +1,6 @@
local: [WILDCARD]005_more_imports.ts
type: TypeScript
compiled: [WILDCARD]005_more_imports.ts.js
-map: [WILDCARD]005_more_imports.ts.js.map
deps:
file://[WILDCARD]/005_more_imports.ts
└─┬ file://[WILDCARD]/subdir/mod1.ts
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index d5b4016c1..890249072 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -2049,7 +2049,7 @@ itest!(single_compile_with_reload {
});
itest!(performance_stats {
- args: "run --reload --log-level debug 002_hello.ts",
+ args: "bundle --log-level debug 002_hello.ts",
output: "performance_stats.out",
});
diff --git a/cli/tests/single_compile_with_reload.ts b/cli/tests/single_compile_with_reload.ts
index 3dd728366..a4d6d0341 100644
--- a/cli/tests/single_compile_with_reload.ts
+++ b/cli/tests/single_compile_with_reload.ts
@@ -1,4 +1,4 @@
-await import("./005_more_imports.ts");
+await import("./single_compile_with_reload_dyn.ts");
console.log("1");
-await import("./005_more_imports.ts");
+await import("./single_compile_with_reload_dyn.ts");
console.log("2");
diff --git a/cli/tests/single_compile_with_reload.ts.out b/cli/tests/single_compile_with_reload.ts.out
index 2cdd71673..c3e87e7d3 100644
--- a/cli/tests/single_compile_with_reload.ts.out
+++ b/cli/tests/single_compile_with_reload.ts.out
@@ -1,5 +1,5 @@
Compile [WILDCARD]single_compile_with_reload.ts
-Compile [WILDCARD]005_more_imports.ts
+Compile [WILDCARD]single_compile_with_reload_dyn.ts
Hello
1
2
diff --git a/cli/tests/single_compile_with_reload_dyn.ts b/cli/tests/single_compile_with_reload_dyn.ts
new file mode 100644
index 000000000..52dd1df7b
--- /dev/null
+++ b/cli/tests/single_compile_with_reload_dyn.ts
@@ -0,0 +1,11 @@
+import { returnsHi, returnsFoo2, printHello3 } from "./subdir/mod1.ts";
+
+printHello3();
+
+if (returnsHi() !== "Hi") {
+ throw Error("Unexpected");
+}
+
+if (returnsFoo2() !== "Foo") {
+ throw Error("Unexpected");
+}