Add Imports to Existing WordPress Import Map

Turns out to be quite simple in WordPress 6.5.

Use wp_register_script_module to register the imports, and include them as dependencies in wp_enqueue_script_module:

add_action('wp_enqueue_scripts', 'enqueue_three_d_script');

function enqueue_three_d_script() {
    wp_register_script_module(
        'three',
        "https://unpkg.com/[email protected]/build/three.module.js",
        array(),
        null
    );
    wp_register_script_module(
        'three/addons/',
        "https://unpkg.com/[email protected]/examples/jsm/",
        array(),
        null
    );
    wp_enqueue_script_module(
        'three-d-script', 
        SCRIPTS_DIR . 'threeDTest.js', 
        array('three', 'three/addons/'), 
        null
    );
}

error code: 523