Open colinrotherham opened 1 year ago
For example
import '../../vendor/polyfills/Event.mjs'
import '../../vendor/polyfills/Function/prototype/bind.mjs'
import '../../vendor/polyfills/String/prototype/trim.mjs'
Where polyfill-library
could be core-js
or any other polyfill provider
import 'polyfill-library/polyfills/__dist/Event/min.js'
import 'polyfill-library/polyfills/__dist/Function.prototype.bind/min.js'
import 'polyfill-library/polyfills/__dist/String.prototype.trim/min.js'
Note: We'd need to swap our *.mjs
file copy step to a second Rollup run in format: 'es'
mode
Alternatively, could we skip straight to automating our polyfills via:
@babel/preset-env
in useBuiltIns: 'usage'
mode@babel/plugin-transform-runtime
to alias globals versus modifying window
Example spike for 2) + 3) https://github.com/colinrotherham/polyfill-playground
What
This issue has been created to investigate using polyfills from an npm package
We currently copy polyfills from:
polyfill-library
npm packageWe avoid unnecessary govuk-frontend dependencies but may have missed important bug fixes since ~2018:
Why
There is a performance impact if we're shipping duplicate polyfills that service teams already install. There's also a potential usability impact should older browsers be running our out-of-date polyfills with unknown issues (bugs, performance)
We can ask some questions:
polyfill-library
orcore-js
?Update: Looks like
core-js
only provides ES5+ polyfills so we'd be lacking the ES3+ upgrades like[].indexOf()
,.addEventListener()
,Date.now()
,document.querySelector()
etc frompolyfill-library
This may be considered a step towards:
Who needs to work on this
Developers
Who needs to review this
Developers
Done when