How can I load a javascript file that is type=”module” the WordPress way?

Here is the final code I now use to add type=”module” to my scripts.

wp_register_script('my-script', get_theme_file_uri('/js/script.js'), ['axios'], '1.0');
wp_enqueue_script('my-script');

add_filter("script_loader_tag", "add_module_to_my_script", 10, 3);
function add_module_to_my_script($tag, $handle, $src)
{
    if ("my-script" === $handle) {
        $tag = '<script type="module" src="' . esc_url($src) . '"></script>';
    }

    return $tag;
}