From 2ea41d3ac159e4c2e998d13412dc19680b01a6ca Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Sat, 19 Jun 2021 15:14:43 +0100 Subject: fix(core/modules): Prepare modules only once per runtime (#11015) This commit changes module loading implementation in "deno_core" to call "ModuleLoader::prepare" hook only once per entry point. This is done to avoid multiple type checking of the same code in case of duplicated dynamic imports. Relevant code in "cli/module_graph.rs" was updated as well. --- cli/tests/single_compile_with_reload.ts | 14 ++++++++++++++ cli/tests/single_compile_with_reload.ts.out | 5 +++++ cli/tests/single_compile_with_reload_worker.ts | 3 +++ 3 files changed, 22 insertions(+) create mode 100644 cli/tests/single_compile_with_reload_worker.ts (limited to 'cli/tests') diff --git a/cli/tests/single_compile_with_reload.ts b/cli/tests/single_compile_with_reload.ts index a4d6d0341..f84e91f2f 100644 --- a/cli/tests/single_compile_with_reload.ts +++ b/cli/tests/single_compile_with_reload.ts @@ -2,3 +2,17 @@ await import("./single_compile_with_reload_dyn.ts"); console.log("1"); await import("./single_compile_with_reload_dyn.ts"); console.log("2"); +await new Promise((r) => + new Worker( + new URL("single_compile_with_reload_worker.ts", import.meta.url).href, + { type: "module" }, + ).onmessage = r +); +console.log("3"); +await new Promise((r) => + new Worker( + new URL("single_compile_with_reload_worker.ts", import.meta.url).href, + { type: "module" }, + ).onmessage = r +); +console.log("4"); diff --git a/cli/tests/single_compile_with_reload.ts.out b/cli/tests/single_compile_with_reload.ts.out index 4ffaa6e77..b0b2fcaf1 100644 --- a/cli/tests/single_compile_with_reload.ts.out +++ b/cli/tests/single_compile_with_reload.ts.out @@ -2,3 +2,8 @@ Check [WILDCARD]single_compile_with_reload.ts Hello 1 2 +Check [WILDCARD]single_compile_with_reload_worker.ts +Hello from worker +3 +Hello from worker +4 diff --git a/cli/tests/single_compile_with_reload_worker.ts b/cli/tests/single_compile_with_reload_worker.ts new file mode 100644 index 000000000..103cafe20 --- /dev/null +++ b/cli/tests/single_compile_with_reload_worker.ts @@ -0,0 +1,3 @@ +console.log("Hello from worker"); +postMessage(null); +close(); -- cgit v1.2.3