[wp-trac] [WordPress Trac] #49360: Scripts: Add polyfill for window.URL

WordPress Trac noreply at wordpress.org
Wed Feb 12 01:44:13 UTC 2020


#49360: Scripts: Add polyfill for window.URL
---------------------------+-------------------------
 Reporter:  aduth          |       Owner:  aduth
     Type:  defect (bug)   |      Status:  reopened
 Priority:  normal         |   Milestone:  5.4
Component:  Script Loader  |     Version:  trunk
 Severity:  normal         |  Resolution:
 Keywords:  has-patch      |     Focuses:  javascript
---------------------------+-------------------------

Comment (by aduth):

 Continuing to explore this, specifically on whether there are options to
 pull in an existing browser-ready solution:

 - `universal-url` is written with CommonJS `require` statements and does
 not include any browser-ready bundle
 - `whatwg-url` implementation is quite large (90kb+ minified)
 - `core-js-bundle` is browser-ready, but is the entire `core-js` library,
 not something where individual parts can be used independently

 It wouldn't be much effort to create or maintain a minimal wrapper which
 just creates a browser-ready bundle. I just now created one published as
 [https://www.npmjs.com/package/core-js-url-browser core-js-url-browser]
 which could be used. The patch [attachment:"49360-core-js-url.diff"] shows
 how this would be integrated much the same as other polyfills without too
 much trouble. I've confirmed this works effectively in Internet Explorer.

 But as I look more at the existing [https://github.com/WordPress
 /wordpress-develop/blob/master/tools/webpack/packages.js packages Webpack
 configuration], I do feel that it would be worth exploring to extract a
 separate build configuration specific to vendor dependencies. I think this
 would simplify things greatly, allowing bundling one of the source
 polyfills, and incorporating minification by leveraging built-in Webpack
 functionality. The patch [attachment:"vendor-webpack.diff"] is a partial
 implementation of what this could look like. It feels like a larger task
 than we probably want to take on for the simple fix of the polyfill, but I
 think it would be a worthwhile improvement to vendor-script builds in
 general.

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


More information about the wp-trac mailing list