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

WordPress Trac noreply at wordpress.org
Wed Apr 10 10:25:56 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):

 @youknowriad  I have some questions about the approach of adding new
 modules for the functionality that modules require. Let's look at an
 `apiFetch` module as an example folks are already requesting that exhibits
 challenges for a module.

 The `wp-api-fetch` script relies on some imperative code to set it up for
 use in WordPress, that's something we'd need to address. There are likely
 other things we could improve in its module version.

 What's the module version going to look like? Does it try to maintain the
 same API for the sake of familiarity? What does this mean for the
 `@wordpress/api-fetch` package that already includes module and commonjs
 builds? Will there be a new package for the modern api-fetch module
 version? Releasing a new major version with breaking changes would be a
 good way to move forward in the npm ecosystem, but does that imply a
 breaking change for the `wp-api-fetch` script? How would the script be
 maintained independently of the module version?

 To be clear, I'm not opposed to the approach. I do like that it provides a
 way to separate more modern modules from legacy scripts and an opportunity
 to start with a clean slate, but I do want to explore the some of the
 difficult questions it raises.

 ----

 > I see more value personally (for a start) to be able to use modules
 within scripts (lazy load modules).

 This may be sufficient for its own ticket. If we want to implement this I
 think the work will be separate from allowing dependence in the other
 direction.

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


More information about the wp-trac mailing list