mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 23:59:59 -05:00
b64ec79268
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".
18 lines
687 B
TypeScript
18 lines
687 B
TypeScript
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);
|