Skip to content

Commit

Permalink
Refactor dynamic codegen module creation (#791)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffcharles authored Oct 23, 2024
1 parent b95c4fc commit ccb7ca4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/cli/src/codegen/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Imports> {
let import_namespace = self.provider.import_namespace()?;
Expand Down Expand Up @@ -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)?;
Expand Down

0 comments on commit ccb7ca4

Please sign in to comment.