Core-js: Promise polyfill is used in firefox even with useNative set

Created on 21 Jun 2019  路  5Comments  路  Source: zloirock/core-js

I have to following imports at my entry point but the promise polyfill is still loaded.

import configurator from 'core-js/configurator'
configurator({ useNative: ['Promise'] })
import 'core-js/es/promise'

I understand that firefox doesn't have a full promise implantation, but it's fine for my needs. As I understood it setting useNative should cause the promise polyfill to only be loaded if there's no native implementation regardless of the correctness of that implementation.

bug

All 5 comments

imports are hoisted, so import "core-js/es/promise runs before calling the configurator.

@nicolo-ribaudo yep here should be require, but README examples use import and seem even with require it's broken in the actual version.

Nope, I incorrectly tested it, with require it works as expected. So the bug only in the documentation.

If you need an esm-compatible workaround:

// configure-core-js.js

import configurator from 'core-js/configurator'
configurator({ useNative: ['Promise'] })
// entry point
import "./configure-core-js.js";
import 'core-js/es/promise';

imports are hoisted, so import "core-js/es/promise runs before calling the configurator.

Of course. Silly me. Thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dwiyatci picture dwiyatci  路  4Comments

kalvenschraut picture kalvenschraut  路  6Comments

devongovett picture devongovett  路  4Comments

flcl42 picture flcl42  路  4Comments

Sequoia picture Sequoia  路  5Comments