I'm currently using core-js to polyfill my project (by setting the useBuiltIns property to "usage" or "entry" at @babel/preset-env ) and trying to find a way to wrap a core-js polyfill within a feature detection.
I'm expecting something like this:
IN
import 'core-js/features/array/includes';
OUT (Original Output)
var core_js_modules_es_array_includes__WEBPACK_IMPORTED_MODULE_166__ = __webpack_require__("../node_modules/core-js/modules/es.typed-array.includes.js");
...
OUT (Expected)
if (Array.prototype.includes == undefined) {
var core_js_modules_es_array_includes__WEBPACK_IMPORTED_MODULE_166__ = __webpack_require__("../node_modules/core-js/modules/es.typed-array.includes.js");
....
}
Thank you.