[wp-trac] [WordPress Trac] #60647: Script Modules: Allow modules to depend on existing WordPress scripts
WordPress Trac
noreply at wordpress.org
Tue Apr 23 15:12:46 UTC 2024
#60647: Script Modules: Allow modules to depend on existing WordPress scripts
-----------------------------+-------------------------
Reporter: jonsurrell | Owner: jonsurrell
Type: feature request | Status: assigned
Priority: normal | Milestone: 6.6
Component: Script Loader | Version: 6.5
Severity: normal | Resolution:
Keywords: has-patch | Focuses: javascript
-----------------------------+-------------------------
Comment (by jonsurrell):
I've come to agree with @youknowriad that we should introduce modules
progressively as needed without migrating whatever we have in scripts to
modules.
I'm currently working on a proof-of-concept to migrate `apiFetch`
functionality to a module. I'd like to keep its API mostly the same so
folks don't have to learn a new API. Building and maintaining modules will
bring with it another set of challenges.
`apiFetch` is also a nice module to explore because it has imperative
configuration in WordPress that's currently handled by
`wp_add_inline_script`. I believe modules will need an interface to pass
configuration from the server to the client, but rather than the
imperative style scripts currently use, modules should be able to read
data on demand. [https://github.com/WordPress/wordpress-develop/pull/6433
PR#6433 (work in progress at the moment)] contains an approach that
introduces a filter `scriptmoduledata_{$module_id}` that can be used to
attach data to an object that will be JSON serialized in the DOM for
modules to read.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60647#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list