-
Notifications
You must be signed in to change notification settings - Fork 3
Issue-685: Add support for block metadata viewScriptModule field #744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Issue-685: Add support for block metadata viewScriptModule field #744
Conversation
|
For projects using a version of wp-scripts less than v30.8.0.
kaitlinbolling
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@efuller this looks good to me! Apologies for the long delay in reviewing this!
|
@kaitlinbolling no worries ... this ticket has been an absolute journey and it is not yet completed ... but we are close. There are a few code updates I need to make as well as some 'hopefully' simplified testing steps. |
Summary
Fixes #685
This pull request introduces support for the
viewScriptModulemetadata field to enable the use of the Interactivity API. Additionally, it enhances the build process by accommodating the--experimental-modulesflag, which modifies the Webpack configuration to support both single and array-based configurations. The changes also ensure backward compatibility with older versions of@wordpress/scripts.Details
viewScriptModulefield in block metadata registration.--experimental-modulesflag in the build and start commands, enabling the use of experimental features such as the Interactivity API.--experimental-modulesflag is used. This includes backward compatibility for projects using older versions of@wordpress/scripts.generateBaseConfigandgetConfigByType.@wordpress/scriptsdependency to version^30.14.1to ensure compatibility with the latest features.Use Case
Developers can now specify the
viewScriptModulefield in a block's metadata to utilize the Interactivity API. These changes ensure compatibility with modern build processes and enable seamless integration of interactive features in WordPress blocks.Testing Instructions
Follow these steps to test the changes:
wp-scriptsrepo to your machine.wp-scriptsfolder switch to that version of nodenpm installnpm run buildcdintopackages/build-toolnpm link(this will create a symlink to the npm global workspace)cdinto the project you would like to test fromnpm link @alleyinteractive/build-tool(this will tell your project to use the package we linked above)npm run buildwill work and produce the correct output. Does it build the assets correctly?@wordpress/scriptsto at least version30.8.0@wordpress/scripts, run your build again. If it works, proceed to next step.npm install @wordpress/interactivity--experimental-modulesflag to youralley-build buildscriptnpm unlink @alleyinteractive/build-toolor just deletenode_modulesand runnpm install.Additional Notes
Refer to the original issue for further context: #685. Updated documentation and helper functions ensure a smoother developer experience and compatibility with evolving WordPress tooling.