From f34fcd16ea4d504c8a87c0873c65598d70bb1d07 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Tue, 9 May 2023 12:37:13 +0200 Subject: fix(core): let V8 drive extension ESM loads (#18997) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This now allows circular imports across extensions. Instead of load + eval of all ESM files in declaration order, all files are only loaded. Eval is done recursively by V8, only evaluating files that are listed in `Extension::esm_entry_point` fields. --------- Co-authored-by: Bartek IwaƄczuk --- runtime/build.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/build.rs b/runtime/build.rs index 4f49ba681..18aaf7a7f 100644 --- a/runtime/build.rs +++ b/runtime/build.rs @@ -267,6 +267,17 @@ mod startup_snapshot { include_str!("js/99_main.js"), ), }]); + ext.esm_entry_point("ext:runtime_main/js/99_main.js"); + } + ); + + #[cfg(feature = "snapshot_from_snapshot")] + deno_core::extension!( + runtime_main, + deps = [runtime], + customizer = |ext: &mut deno_core::ExtensionBuilder| { + eprintln!("I am here!!!"); + ext.esm_entry_point("ext:runtime/90_deno_ns.js"); } ); @@ -315,7 +326,6 @@ mod startup_snapshot { // FIXME(bartlomieju): these extensions are specified last, because they // depend on `runtime`, even though it should be other way around deno_node::deno_node::init_ops_and_esm::(None, fs), - #[cfg(not(feature = "snapshot_from_snapshot"))] runtime_main::init_ops_and_esm(), ]; -- cgit v1.2.3