New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: remove default array/object polyfills #3641
perf: remove default array/object polyfills #3641
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #3641 +/- ##
=======================================
Coverage 99.26% 99.26%
=======================================
Files 224 224
Lines 4326 4326
Branches 1231 1227 -4
=======================================
Hits 4294 4294
Misses 26 26
Partials 6 6
Continue to review full report at Codecov.
|
@tmorehouse Can you please test the deployment preview on IE 11 and confirm that everything is still working as it should? |
Yeah, that removal of the polyfill for Array.from() killed my user's IE11. So it goes. I'm using latest everything (more fool me), but the polyfill is: That's not precisely what you suggest, so I guess I'll try to change it around. As far as I can tell I do have _array.from() in my code, so it's being polyfilled from somewhere.... but it's definitely not converting a dom object into an array, which I think is what you're trying to do in b-tabs / selectAll / arrayFrom Does anyone have an @babel/preset-env configuration which works with this new code? No worries, I switched to your recommendation to use Polyfill.io (so I hit IE11 users with extra stuff only!) and that works ok again. |
I've had a problem which I think is due to this. esm/utils/array.js take a local copy of Array.from, which it exports for use in other code. If Array.from has not yet been polyfilled, then even if it's polyfilled later the code will still use the undefined version. I'm seeing this in a Nuxt environment where I'm having difficulty getting the polyfill to execute before the array.js code does. I could be wrong, but isn't it a bad idea to take a copy of a function you expect to be polyfilled? Would it be better to use Array.from etc directly? It feels like old code which exists because we used to have polyfill implementations in there. |
…revents polyfills. This is a workaround by patching the results of the nuxt build until I have something better. More details here: bootstrap-vue/bootstrap-vue#3641 https://cmty.app/nuxt/nuxt.js/issues/c10213
We use references to the often used methods like "Array.from", as javascript minifiers will minify a variable name down to one or two characters, where it normally would leave "Array.from" if used directly. Polyfills should normally be loaded before any other code is loaded into a browser. |
Thanks for your reply - interesting about the minifier. Do you know how I can achieve getting the polyfill in there first in Nuxt? I've tried:
...but bootstrap vue gets in there first. I presume the nuxt build adds the plugins from packages first. I've opened an issue over there in case I'm missing something: |
For polyfills, you could load them in nuxt.config.js: module.exports = {
// ...
head: {
meta: [{ 'http-equiv': 'X-UA-Compatible', content: 'IE=edge' }],
script: [
{
src: '//polyfill.io/v3/polyfill.min.js?features=es2015%2CIntersectionObserver',
crossorigin: 'anonymous'
}
]
},
// ...
} polyfill.io only sends the required polyfills to the browser based on its user agent string. |
Could you show a copy of your nuxt.config.js? Specifically your plugins and modules entry? It might be that Nuxt processes How are you creating your polyfill plugin? as a module or a plugin? |
My making each shortcut a method, it allows for handling of late loaded polyfills. See #3641 (comment)
I tried the script method, but I can see from a console log in array.js that Array.from is undefined at that point. I can also see from the Network tab that the npm scripts are loaded before the polyfill one is. My nuxt.config is a bit long, but here's the modules section:
Lots of plugins, but here's the start:
The resulting index.js built shows bootstrap-vue loaded very early on, before I can get any of my stuff in there:
So I can't find any way to get a polyfill in there early enough (there may be one, I just don't know what it is). |
What is the difference between |
They're both attempts to get this to work. polyfills.js is a simple
plugin I wrote which imports from corejs. nuxt-polyfill is an npm
module which you can configure to import from polyfills.io.
They both work with code in general; it's code with the trick of a local
copy of the functions that I can't get working (I understand why you're
doing it given the minification benefit).
…------ Original Message ------
From: "Troy Morehouse" <notifications@github.com>
To: "bootstrap-vue/bootstrap-vue" <bootstrap-vue@noreply.github.com>
Cc: "Edward Hibbert" <edward@ehibbert.org.uk>; "Comment"
<comment@noreply.github.com>
Sent: 18/01/2020 17:45:36
Subject: Re: [bootstrap-vue/bootstrap-vue] perf: remove default
array/object polyfills (#3641)
What is the difference between 'nuxt-polyfill' and
'~/plugins/polyfills'? is the latter providing something that the
former isnt'?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3641?email_source=notifications&email_token=AAAN26GLTUX6HRKNGOQI5HLQ6M54BA5CNFSM4H67MCCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJJ6AVI#issuecomment-575922261>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAN26CBERBTDBFCAQ44N2DQ6M54BANCNFSM4H67MCCA>.
|
…ndling late loaded polyfills (#4647) * chore(utils): pass all Array/Object shortcuts as functions My making each shortcut a method, it allows for handling of late loaded polyfills. See #3641 (comment) * Update object.js * Update object.js * Update dom.js * Update dom.js * Update dom.js Co-authored-by: Jacob Müller <jacob.mueller.elz@gmail.com>
Describe the PR
This PR removes the default polyfills for:
Array.from()
Array.isArray()
Object.assign()
Object.is()
This should not be a breaking change since our polyfill recommendations in the docs should catch those anyway (for IE 11 and older android)
PR checklist
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
The PR fulfills these requirements:
dev
branch, not themaster
branch[...] (fixes #xxx[,#xxx])
, where "xxx" is the issue number)fix(alert): not alerting during SSR render
,docs(badge): update pill examples, fix typos
,chore: fix typo in README
, etc). This is very important, as theCHANGELOG
is generated from these messages.If new features/enhancement/fixes are added or changed:
package.json
for slot and event changes)If adding a new feature, or changing the functionality of an existing feature, the PR's
description above includes: