[wp-trac] [WordPress Trac] #60647: Script Modules: Allow modules to depend on existing WordPress scripts

WordPress Trac noreply at wordpress.org
Tue Sep 24 07:48:52 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.7
Component:  Script Loader             |     Version:  6.5
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:  javascript
--------------------------------------+-------------------------

Comment (by gziolo):

 > For these reasons, I think it's not worth it to try to load scripts in
 modules. I think we'd better try having build scripts that creates a
 script and a module for some selected packages. And I can even see some
 differences between the script and the module version of something. For
 instance configuring the translations shouldn't be done in the same way to
 wp-i18n, we'd have to load contextual translations instead (lazy load them
 as needed rather than print them server side...)

 We iterate on this ticket based on the plan outlined by @youknowriad. I
 have just landed all the preparatory work done by @jonsurrell to align how
 script modules are integrated with WordPress core to mirror the same
 handling as scripts which was iterated for many WP releases. The next step
 is exposing more packages with the following priorities:
 - `@wordpress/a11y` which is nearly ready for WP 6.7 -
 https://github.com/WordPress/wordpress-develop/pull/7405, it is the best
 one to verify as it can be used to refactor `@wordpress/interactivity-
 router` and we could use it for the Gallery block when enabling expand on
 click feature.
 - `@wordpress/api-fetch` - the most requested package.
 - `@wordpress/hooks` - that's the key WP feature.
 - `@wordpress/i18n` - #60234 depends on it.

 There are some other nice to have some other vanilla JS packages that we
 could consider in the future:
 - `@wordpress/date` - it requires configuration on the server, useful only
 when it no longer depends on `momentjs`
 - `@wordpress/is-shallow-equal`
 - `@wordpress/keycodes` - not sure if loading a module for a constant is
 worth it
 - `@wordpress/priority-queue`
 - `@wordpress/url` - only WP specific utils, the same considerations as
 with `@wordpress/keycodes`
 - `@wordpress/warning` - that one could be used with
 `@wordpress/interactivity` package to fix
 https://github.com/WordPress/gutenberg/issues/61765

 There might be more, all of them don't depend on React so that seems for
 the time being the leading indicator of whether a package is universal
 enough. However, it isn't something that is clear enough at this stage.
 Happy to discuss it later, but for now we would like to tackle the most
 requested listed as top priorities.
 wordcount - might be too specific

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60647#comment:37>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list