While bundling our TS project into es5 using babel and webpack, we see polyfills for standard string methods like
String.replace
, String.match
, String.split
$ Added following core-js polyfill:
es.array.join { "ie":"11" }
$ Added following core-js polyfills:
es.string.replace { "edge":"17", "firefox":"67", "ie":"11", "ios":"12", "safari":"12.1", "samsung":"9.2" }
es.string.split { "edge":"17", "ie":"11" }
As per compatibility charts of MDN & other trusted compat tables, these methods are fully supported by all these platforms. But why would babel add polyfills for them remains a question to us.
Is there a way to disable polyfills of these standard methods via babel config? Below is our babel configuration, Hint us if we are missing something.
const presets = [
[
'@babel/env', // Using babel preset-env
{
debug: true, // Disabling debug output in console
targets: {
browsers: ['> 1%', 'not dead', 'not ie < 8'], // Spit code for all browsers with usage > 1% and not dead.
},
useBuiltIns: 'usage', // Use polyfills for runtime feature support
corejs: 3, // Use core-js 3 Polyfills.
},
],
];
const plugins = [
'@babel/plugin-transform-runtime', // Use Babel helpers to prevent code bloating with helpers
];
module.exports = { presets, plugins };