diff options
| author | Andreu Botella <andreu@andreubotella.com> | 2023-03-19 00:43:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-19 00:43:07 +0100 |
| commit | b64ec7926831896f4e43b685891111409de45e85 (patch) | |
| tree | b91550f9c21931f7bf691a6c298b64ff63c16041 /cli/tests/testdata | |
| parent | a80d1b6e663bd439bd12b7c65cc1ac017bafb886 (diff) | |
feat(compile): Enable multiple roots for a standalone module graph (#17663)
This change will enable dynamic imports and web workers to use modules
not reachable from the main module, by passing a list of extra side
module roots as options to `deno compile`.
This can be done by specifying "--include" flag that accepts a file path or a
URL. This flag can be specified multiple times, to include several modules.
The modules specified with "--include" flag, will be added to the produced
"eszip".
Diffstat (limited to 'cli/tests/testdata')
3 files changed, 20 insertions, 1 deletions
diff --git a/cli/tests/testdata/compile/dynamic_imports/import_path b/cli/tests/testdata/compile/dynamic_imports/import_path new file mode 100644 index 000000000..98222a208 --- /dev/null +++ b/cli/tests/testdata/compile/dynamic_imports/import_path @@ -0,0 +1 @@ +./import1.ts diff --git a/cli/tests/testdata/compile/dynamic_imports/main.ts b/cli/tests/testdata/compile/dynamic_imports/main.ts index 7b4c487be..b889e2203 100644 --- a/cli/tests/testdata/compile/dynamic_imports/main.ts +++ b/cli/tests/testdata/compile/dynamic_imports/main.ts @@ -3,4 +3,4 @@ console.log("Starting the main module"); setTimeout(() => { console.log("Dynamic importing"); import("./import1.ts").then(() => console.log("Dynamic import done.")); -}, 500); +}, 0); diff --git a/cli/tests/testdata/compile/dynamic_imports/main_unanalyzable.ts b/cli/tests/testdata/compile/dynamic_imports/main_unanalyzable.ts new file mode 100644 index 000000000..e8e3e849b --- /dev/null +++ b/cli/tests/testdata/compile/dynamic_imports/main_unanalyzable.ts @@ -0,0 +1,18 @@ +import { join } from "https://deno.land/std@0.178.0/path/mod.ts"; + +console.log("Starting the main module"); + +// We load the dynamic import path from the file system, to make sure any +// improvements in static analysis can't defeat the purpose of this test, which +// is to make sure the `--include` flag works to add non-analyzed imports to the +// module graph. +const IMPORT_PATH_FILE_PATH = join( + Deno.cwd(), + "tests/testdata/compile/dynamic_imports/import_path", +); + +setTimeout(async () => { + console.log("Dynamic importing"); + const importPath = (await Deno.readTextFile(IMPORT_PATH_FILE_PATH)).trim(); + import(importPath).then(() => console.log("Dynamic import done.")); +}, 0); |
