From 01028fcdf4f379a7285cc15079306e3ac31edcc1 Mon Sep 17 00:00:00 2001 From: Andreu Botella Date: Sun, 5 Mar 2023 02:37:54 +0100 Subject: test(compile): Add a test for dynamic imports in `deno compile` (#18017) denoland/eszip#115 added support for statically-analyzed dynamic imports in eszip, which made `deno compile` support dynamic imports starting from #17858. This PR adds a test for it. ---- This test is adapted from PR #17663. Closes #17908 --- cli/tests/testdata/compile/dynamic_imports/import1.ts | 3 +++ cli/tests/testdata/compile/dynamic_imports/import2.ts | 1 + cli/tests/testdata/compile/dynamic_imports/main.out | 5 +++++ cli/tests/testdata/compile/dynamic_imports/main.ts | 6 ++++++ 4 files changed, 15 insertions(+) create mode 100644 cli/tests/testdata/compile/dynamic_imports/import1.ts create mode 100644 cli/tests/testdata/compile/dynamic_imports/import2.ts create mode 100644 cli/tests/testdata/compile/dynamic_imports/main.out create mode 100644 cli/tests/testdata/compile/dynamic_imports/main.ts (limited to 'cli/tests/testdata') diff --git a/cli/tests/testdata/compile/dynamic_imports/import1.ts b/cli/tests/testdata/compile/dynamic_imports/import1.ts new file mode 100644 index 000000000..2d9dde2a4 --- /dev/null +++ b/cli/tests/testdata/compile/dynamic_imports/import1.ts @@ -0,0 +1,3 @@ +import "./import2.ts"; + +console.log("import1.ts"); diff --git a/cli/tests/testdata/compile/dynamic_imports/import2.ts b/cli/tests/testdata/compile/dynamic_imports/import2.ts new file mode 100644 index 000000000..22321a5a7 --- /dev/null +++ b/cli/tests/testdata/compile/dynamic_imports/import2.ts @@ -0,0 +1 @@ +console.log("import2.ts"); diff --git a/cli/tests/testdata/compile/dynamic_imports/main.out b/cli/tests/testdata/compile/dynamic_imports/main.out new file mode 100644 index 000000000..4304fb06f --- /dev/null +++ b/cli/tests/testdata/compile/dynamic_imports/main.out @@ -0,0 +1,5 @@ +Starting the main module +Dynamic importing +import2.ts +import1.ts +Dynamic import done. diff --git a/cli/tests/testdata/compile/dynamic_imports/main.ts b/cli/tests/testdata/compile/dynamic_imports/main.ts new file mode 100644 index 000000000..7b4c487be --- /dev/null +++ b/cli/tests/testdata/compile/dynamic_imports/main.ts @@ -0,0 +1,6 @@ +console.log("Starting the main module"); + +setTimeout(() => { + console.log("Dynamic importing"); + import("./import1.ts").then(() => console.log("Dynamic import done.")); +}, 500); -- cgit v1.2.3