Skip to content

viewScriptModule is also being loaded in the block editor #72833

@juanmaguitar

Description

@juanmaguitar

Description

viewScriptModule file defined in the block.json is meant to be loaded only in the frontend when the block is displayed but right now is also being loaded in the block editor

Step-by-step reproduction instructions

  1. Go to the plugins folder of a WordPress instance
  2. Run npx @wordpress/create-block@latest demo-iapi-block --template @wordpress/create-block-interactive-template to quickly create a block with a viewScriptModule definition
  3. Enter into that folder (cd demo-iapi-block), install dependencies (npm install) and run the build process (npm run build)
  4. Activate the plugin, open any post and insert Demo Iapi Block
  5. Save and reload the Block Editor

Current behaviour

view.js defined as viewScriptModule is loaded in the Block Editor

Image

Expected behaviour

view.js defined as viewScriptModule should not be loaded in the Block Editor. It should only be loaded in the frontend when the block is displayed.

Screenshots, screen recording, code snippet

No response

Environment info

  • WP Version: 6.8.3
  • Tested with WordPress Studio and wp-env
  • No other plugins activated

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

    Needs Technical FeedbackNeeds testing from a developer perspective.[Feature] Block APIAPI that allows to express the block paradigm.[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions