summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2020-02-20 14:58:05 +1100
committerGitHub <noreply@github.com>2020-02-19 22:58:05 -0500
commit6431622a6debc0443f9269fe0157571ec54701c0 (patch)
tree8657fe0eaeb492283f369c0813d46880683e5efb /cli/tests
parent0e579ee9dce917c1b783cea5506315f78b1e0a00 (diff)
fix: mis-detecting imports on JavaScript when there is no checkJs (#4040)
This PR fixes an issue where we recursively analysed imports on plain JS files in the compiler irrespective of "checkJs" being true. This caused problems where when analysing the imports of those files, we would mistake some import like structures (AMD/CommonJS) as dependencies and try to resolve the "modules" even though the compiler would not actually look at those files.
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/fix_js_imports.ts3
-rw-r--r--cli/tests/fix_js_imports.ts.out1
-rw-r--r--cli/tests/integration_tests.rs5
-rw-r--r--cli/tests/subdir/amd_like.js4
4 files changed, 13 insertions, 0 deletions
diff --git a/cli/tests/fix_js_imports.ts b/cli/tests/fix_js_imports.ts
new file mode 100644
index 000000000..4770b1ab6
--- /dev/null
+++ b/cli/tests/fix_js_imports.ts
@@ -0,0 +1,3 @@
+import * as amdLike from "./subdir/amd_like.js";
+
+console.log(amdLike);
diff --git a/cli/tests/fix_js_imports.ts.out b/cli/tests/fix_js_imports.ts.out
new file mode 100644
index 000000000..0967ef424
--- /dev/null
+++ b/cli/tests/fix_js_imports.ts.out
@@ -0,0 +1 @@
+{}
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index 251c6da3c..5429170c7 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -1004,6 +1004,11 @@ itest!(cafile_info {
http_server: true,
});
+itest!(fix_js_imports {
+ args: "run --reload fix_js_imports.ts",
+ output: "fix_js_imports.ts.out",
+});
+
#[test]
fn cafile_fetch() {
use deno::http_cache::url_to_filename;
diff --git a/cli/tests/subdir/amd_like.js b/cli/tests/subdir/amd_like.js
new file mode 100644
index 000000000..23babc4db
--- /dev/null
+++ b/cli/tests/subdir/amd_like.js
@@ -0,0 +1,4 @@
+// looks like an AMD module, but isn't
+const define = () => {};
+define(["fake_module"], () => {});
+export {};