[wp-trac] [WordPress Trac] #60232: Modules API: Add import map polyfill

WordPress Trac noreply at wordpress.org
Thu Jan 11 14:38:16 UTC 2024


#60232: Modules API: Add import map polyfill
---------------------------+-----------------------------
 Reporter:  luisherranz    |      Owner:  (none)
     Type:  enhancement    |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Script Loader  |    Version:
 Severity:  major          |   Keywords:
  Focuses:  javascript     |
---------------------------+-----------------------------
 Now that WordPress is going to support import maps through the new
 [https://core.trac.wordpress.org/ticket/56313 Modules API], we need to
 make sure that they work on the majority of browsers because even though
 all the major ones already support import maps, some old versions still
 require a polyfill.

 The requirements for such polyfill are:

 - As all the modern browsers already support import maps and the polyfill
 is only for compatibility with old browsers, the polyfill should only be
 downloaded when the browser doesn't support import maps. So instead of the
 entire polyfill, we should add an inline script that checks if the
 polyfill is needed, and only add it in that case.

 - The polyfill should only provide functionality for the import maps and
 nothing else to be able to safely remove it in the future. So we need to
 make sure that the polyfill doesn't include other functionality than just
 the import map polyfilling.

 - The polyfill script will need to be maintained until the percentage of
 users using old browsers without import map support drops significantly.

 I've opened [https://github.com/guybedford/es-module-shims/issues/406 an
 issue on the es-module-shims] repository to start working on that, and
 this work should be finished before the WordPress 6.5 release.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60232>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list