Skip to main content

add_imports_to_program

Function add_imports_to_program 

Source
pub fn add_imports_to_program(program: &mut Program, context: &ProgramContext)
Expand description

Insert import declarations into the program body. Handles both ESM imports and CommonJS require.

For existing imports of the same module (non-namespaced, value imports), new specifiers are merged into the existing declaration. Otherwise, new import/require statements are prepended to the program body.