From ccb7ca4765953d8d967151b1892e8ca3ec128360 Mon Sep 17 00:00:00 2001 From: Jeffrey Charles Date: Wed, 23 Oct 2024 09:37:31 -0400 Subject: [PATCH] Refactor dynamic codegen module creation (#791) --- crates/cli/src/codegen/dynamic.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/cli/src/codegen/dynamic.rs b/crates/cli/src/codegen/dynamic.rs index 9661f662..27c40d8b 100644 --- a/crates/cli/src/codegen/dynamic.rs +++ b/crates/cli/src/codegen/dynamic.rs @@ -66,6 +66,11 @@ impl DynamicGenerator { } } + /// Generate the starting module. + fn generate_initial_module(&self) -> Module { + Module::with_config(transform::module_config()) + } + /// Generate function imports. pub fn generate_imports(&self, module: &mut Module) -> Result { let import_namespace = self.provider.import_namespace()?; @@ -264,7 +269,7 @@ impl CodeGen for DynamicGenerator { )?; } - let mut module = Module::with_config(transform::module_config()); + let mut module = self.generate_initial_module(); let imports = self.generate_imports(&mut module)?; let bc_metadata = self.generate_main(&mut module, js, &imports)?; self.generate_exports(&mut module, &imports, &bc_metadata)?;