From 3d8a4d3b81e107bbb152ad69047f64d16ca800f3 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Wed, 26 Apr 2023 21:23:28 +0100 Subject: feat(cli): don't check permissions for statically analyzable dynamic imports (#18713) Closes #17697 Closes #17658 --- cli/tests/testdata/dynamic_import/empty_1.ts | 0 cli/tests/testdata/dynamic_import/empty_2.ts | 0 .../testdata/dynamic_import/permissions_remote_remote.ts | 2 +- .../dynamic_import/static_analysis_no_permissions.ts | 13 +++++++++++++ .../dynamic_import/static_analysis_no_permissions.ts.out | 2 ++ 5 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 cli/tests/testdata/dynamic_import/empty_1.ts create mode 100644 cli/tests/testdata/dynamic_import/empty_2.ts create mode 100644 cli/tests/testdata/dynamic_import/static_analysis_no_permissions.ts create mode 100644 cli/tests/testdata/dynamic_import/static_analysis_no_permissions.ts.out (limited to 'cli/tests/testdata/dynamic_import') diff --git a/cli/tests/testdata/dynamic_import/empty_1.ts b/cli/tests/testdata/dynamic_import/empty_1.ts new file mode 100644 index 000000000..e69de29bb diff --git a/cli/tests/testdata/dynamic_import/empty_2.ts b/cli/tests/testdata/dynamic_import/empty_2.ts new file mode 100644 index 000000000..e69de29bb diff --git a/cli/tests/testdata/dynamic_import/permissions_remote_remote.ts b/cli/tests/testdata/dynamic_import/permissions_remote_remote.ts index 0033bcccc..65a254191 100644 --- a/cli/tests/testdata/dynamic_import/permissions_remote_remote.ts +++ b/cli/tests/testdata/dynamic_import/permissions_remote_remote.ts @@ -1,3 +1,3 @@ await import( - "http://localhost:4545/dynamic_import/static_remote.ts" + "" + "http://localhost:4545/dynamic_import/static_remote.ts" ); diff --git a/cli/tests/testdata/dynamic_import/static_analysis_no_permissions.ts b/cli/tests/testdata/dynamic_import/static_analysis_no_permissions.ts new file mode 100644 index 000000000..de75ba87b --- /dev/null +++ b/cli/tests/testdata/dynamic_import/static_analysis_no_permissions.ts @@ -0,0 +1,13 @@ +try { + await import("./empty_1.ts"); + console.log("✅ Succeeded importing statically analyzable specifier"); +} catch { + console.log("❌ Failed importing statically analyzable specifier"); +} + +try { + await import("" + "./empty_2.ts"); + console.log("❌ Succeeded importing non-statically analyzable specifier"); +} catch { + console.log("✅ Failed importing non-statically analyzable specifier"); +} diff --git a/cli/tests/testdata/dynamic_import/static_analysis_no_permissions.ts.out b/cli/tests/testdata/dynamic_import/static_analysis_no_permissions.ts.out new file mode 100644 index 000000000..ba9249ab0 --- /dev/null +++ b/cli/tests/testdata/dynamic_import/static_analysis_no_permissions.ts.out @@ -0,0 +1,2 @@ +✅ Succeeded importing statically analyzable specifier +✅ Failed importing non-statically analyzable specifier -- cgit v1.2.3