9 – Add webform field programmatically

In older versions of Webform (Drupal 7), the function webform_component_insert() can be used to add fields to a webform, for example inside a hook_node_insert() implementation, so they are added when the webform is created.

Does anyone know how to do that in Webform 6.x? I would like to add fields to webforms automatically after they are created.