Skip to content

javascript.import_js() crashes but javascript.import_modules() works fine #2684

Description

@cjlee112

Running javascript.import_js('https://threejs.org/build/three.module.js', alias='THREE') crashes with javascript error message "Uncaught SyntaxError: Cannot use import statement outside a module". Note this is just the module used in the Gallery example (https://brython.info/gallery/three_webgl_interactive_cubes.html).

But running the exact same thing with import_modules() works fine:

def run_three(THREE):
    geometry = THREE.BoxGeometry.new(20, 20, 20)
    print('run_three OK')

javascript.import_modules(['https://threejs.org/build/three.module.js'], run_three)

Crash occurs on both 3.13 and 3.14, tested on Chromium 147

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions