When you need it
Two scenarios call for the configurator:-
Native is too strict. core-js feature detection may reject a native implementation that is close enough for your needs. The most common example is
Promise: core-js requires nativePromiseto support unhandled rejection tracking and@@species. If your environment’sPromisepasses all other checks but fails these, core-js installs its own polyfill. If you trust the native implementation and want to skip the polyfill, you can tell core-js to use native whenever it is available at all. - Native is knowingly broken. Some environments have broken native implementations that pass core-js feature detection but behave incorrectly at runtime. In this case you can force the polyfill regardless of what feature detection says.
The three modes
useNative — prefer native, only fall back to polyfill when absent
useNative — prefer native, only fall back to polyfill when absent
The polyfill is used only when the native implementation is completely absent. Feature detection checks are skipped; if the constructor or method exists, the native version is used as-is.Use this when you trust the environment’s native implementation even though core-js’s stricter checks would normally replace it.
usePolyfill — always use the polyfill
usePolyfill — always use the polyfill
The core-js polyfill is installed unconditionally, replacing the native implementation even when one exists and appears to work.Use this when you know the native implementation is broken in a way that core-js feature detection does not catch.
useFeatureDetection — default behaviour
useFeatureDetection — default behaviour
core-js runs its full feature detection suite and uses the native implementation only if it passes every check. This is the default for all features.Use this to restore the default after setting a different mode, or to be explicit in your configuration.
Full example
Call order
The safe pattern is to call the configurator in the same file as your core-js import, placed above it:entry.js
The Promise example in detail
core-js requires native Promise to support two things beyond basic functionality:
- Unhandled rejection tracking — the environment must fire
unhandledrejectionevents when a rejection goes uncaught. @@species—Promise[Symbol.species]must be supported for subclassing to work correctly.
Promise entirely. In some environments — for instance, Node.js with custom process hooks, or environments where you are monitoring unhandled rejections through other means — the native Promise is functionally correct for your use case even though it fails the strict check.
Setting useNative: ['Promise'] tells core-js: “If Promise exists, use it. Do not replace it with the polyfill.”
AsyncIterator options
The configurator also accepts two additional options specifically for theAsyncIterator polyfill.
USE_FUNCTION_CONSTRUCTOR
By default, core-js accesses %AsyncIteratorPrototype% without using the Function constructor, which preserves compatibility with strict Content Security Policies (CSP). As a side-effect, native async generator objects will not be instanceof AsyncIterator in polyfilled environments.
If your CSP allows unsafe-eval (or you have no CSP), you can set this option to true to get a more complete AsyncIterator prototype chain:
AsyncIteratorPrototype
As an alternative to USE_FUNCTION_CONSTRUCTOR, you can pass in the real %AsyncIteratorPrototype% object yourself: