Limits of core-js Promise polyfill when global and pure builds coexist
0 reputation · 06 Jun 2020, 20:40 UTC
We are designing a hybrid bundle where one entry point relies on the default core-js import to polyfill Promise for legacy browsers, while a separate widget on the same page uses the pure, non-global core-js modules. The goal is to keep both code paths working without one silently overwriting the other.
The core-js documentation states that polyfills are applied globally by default and that loading multiple versions in the same environment can cause conflicts. It also offers pure versions that avoid global namespace pollution. However, the documented guidance does not clearly define the interaction boundary when a global build and a pure build coexist, nor does it specify whether the polyfill defers to an existing native Promise or replaces it unconditionally.
Given that microtask scheduling may differ between the polyfill and native implementations in very old engines, what are the supported limits for mixing these two import styles? Does core-js provide a mechanism to isolate the global Promise injection per bundle, or must the entire page standardize on a single version? Is there a documented compatibility matrix for Promise behavior across the engine versions that core-js targets?