Closed victortwc closed 4 years ago
https://babeljs.io/docs/en/babel-polyfill
🚨 As of Babel 7.4.0, this package has been deprecated in favor of directly including
core-js/stable
(to polyfill ECMAScript features) andregenerator-runtime/runtime
(needed to use transpiled generator functions):
As for your specific issue, please provide a reproduction.
Hi @sodatea, I understand that the cli is using core-js directly because babel-polyfill has been deprecated. I just wanted to understand what could cause the issue.
As for reproduction, it would be very difficult for me to provide it, as it is very specific to a Samsung tizen TV. The use case follows:
The TV SDK will send me an event with the current video progress (a number). I'm using xstate to manage a state machine that will handle the transitions and this event is passed up to the app via a callback. So the app is doing:
this.player.subscribe(this.handleStateUpdate);
handleStateUpdate(state) {
this.progressTime = state.progressTime;
}
It's a very simple event that will call the function and update the ui reactively, nothing fancy there. If I put a console.log to see the state variable and check on a remote devtools the UI updates, as if the event loop was delayed sufficiently for Vue to detect the changes. If I use a setTimeout wrapping the assignment it also works with core-js, maybe it's the queue-microtasks polyfill that's included from babel but not from core-js? I'm quite lost at this point.
I'll try to download an old version of Safari and try to repro locally (as the TV is using Safari 6 equivalent of webkit).
Thanks
Honestly, I'm not sure.
I use
babel-polyfill
withuseBuiltIns: "entry"
it works just fine
Does it work if you replace babel-polyfill
with core-js/stable
. Because in the default setup, the core-js
polyfills are required on-demand. So if core-js/stable
also works, we can narrow down the issue to the polyfills that are not loaded by default.
It doesn't work, unfortunately. I'll try experimenting a bit with the different polyfills that are being applied by babel. It's super strange.
So I tested corejs@2.6.11 by including only
import "core-js/fn/set";
import "core-js/fn/map";
import "core-js/fn/promise";
import "core-js/fn/object";
import "core-js/fn/array";
which is the bare minimal to make my app run on that device. The UI update works just fine. I'll try to find the offender now by including each package from core-js
.
Tested core-js@3.6.5 by including only
import "core-js/stable/symbol";
import "core-js/stable/object";
import "core-js/stable/array";
import "core-js/stable/promise";
import "core-js/stable/map";
import "core-js/stable/set";
which is the bare minimal to make my app run on that device. The UI update stopped working.
Found the breaking package from core-js@3: core-js/stable/promise
Using core-js@2 core-js/fn/promise
works fine, even using everything else from core-js@3 as in:
import "core-js3/stable/symbol";
import "core-js3/stable/object";
import "core-js3/stable/array";
import "core-js2/fn/promise";
import "core-js3/stable/map";
import "core-js3/stable/set";
Super weird edge case. Now I think it's out of scope of vue-cli, right @sodatea ?
Yeah. It's either in the core-js polyfill or the Vue nextTick
implementation.
You can check if the new polyfill breaks any logic of nextTick
https://github.com/vuejs/vue/blob/dev/src/core/util/next-tick.js
Version
4.3.1
Environment info
Steps to reproduce
core-js polyfill is not working the same way as babel-polyfill.
With core-js (or it's indirect use like @vue/cli-plugin-babel/preset) the app behaves weird, not updating the UI from events on Safari 6 (Samsung Tizen 2016).
What is expected?
App works after the preset applies all polyfills
What is actually happening?
Weird behavior, UI not updating even though the event method is called. (Could be related to macrotaks? Which polyfills would wrongly cause this?)
On Tizen 2016, the regular Vue CLI 4 project is not working properly after applying the polyfills. If I use
babel-polyfill
withuseBuiltIns: "entry"
it works just fine. Is there any fundamental difference between those?