Skip to content

Modules do not load or work in the full site editor (FSE) #69351

@Zealth57

Description

@Zealth57

Description

When using scripts as modules, there does not seem to be a way to register them in a way that they load with blocks in the Site Editor. I have tried registering the module, enqueuing the module, setting the handle int he script, editorScript, viewScriptModule, everything. The most it will do it load outside the iframe of the Site Editor, but the blocks load inside the iframe so the module JS is never fired. The modules seem to load and work fine when editing a page or viewing it on the frontend. But blocks don't work when going to Appearance -> Editor and viewing a page in the Site Editor context.

Step-by-step reproduction instructions

  • Create a block that relies on a script module (output the JS using wp_enqueue_script_module or wp_register_script_module)
  • Observe the JS is loaded when editing a page, viewing a page, and outside the blocks iframe tag in the FSE

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Script Modules APIRelated to the Script Modules API that adds support for native ES modules and import maps[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions