[wp-trac] [WordPress Trac] #56313: Add the ability to handle ES Modules and Import Maps

WordPress Trac noreply at wordpress.org
Sat Dec 23 09:26:35 UTC 2023


#56313: Add the ability to handle ES Modules and Import Maps
-------------------------------------+-------------------------------------
 Reporter:  idad5                    |       Owner:  luisherranz
     Type:  enhancement              |      Status:  assigned
 Priority:  normal                   |   Milestone:  6.5
Component:  Script Loader            |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch has-unit-      |     Focuses:  javascript,
  tests                              |  performance
-------------------------------------+-------------------------------------

Comment (by luisherranz):

 > Can you explain why this reinvents dependency management rather than
 working off of `WP_Dependencies` or `_WP_Dependency`?

 Oh, sure. Overall, I didn't see any benefit in doing so. Reusing
 `WP_Dependencies` resulted in a more complex code because there was
 practically no overlap as the dependency management we need for modules
 doesn't require the things that `WP_Dependencies` provides (like
 dependency printing ordering) but requires a few new things, like
 filtering by type, or, in the future, maintaining more than one dependency
 per module identifier to support `scopes`.

 > You mention not having registration and enqueuing together but don't
 include any rationale behind why extenders of WordPress should need to
 maintain two different mental models for how external files are loaded
 into the HTML.

 This was suggested to me as an improvement over the Scripts API in the
 past. I don't remember who was at this moment, but I'll ask to see if that
 person can provide additional rationale.

 To me, it made sense to separate both registration and enqueuing as a way
 to teach people that those are two separate steps, especially when working
 with modules where registered modules can't only end up being enqueued,
 but also preloaded or added to the import map.

 > I like the separation of dynamic and static modules, something that I
 think will be extremely helpful is if there is documentation to help guide
 developers in making the decision of which one to use.

 Absolutely 🙂

 > A useful test would be for circular dependency.

 I'll add one. Thank you!

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


More information about the wp-trac mailing list