I highly recommend reading this: So, what's next?
For some cases could be useful to exclude some core-js
features or generate a polyfill for target engines. This API helps conditionally include or exclude certain parts of core-js
and build for targets. modules
, exclude
and targets
options are specified in the @core-js/compat
format.
import builder from '@core-js/builder';
const { script } = await builder({
modules: ['core-js/actual', /^esnext\.reflect\./],
exclude: [/^es\.math\./, 'es.number.constructor'],
targets: '> 0.5%, not dead, ie 9-11',
summary: {
console: { size: true, modules: false },
comment: { size: false, modules: true },
},
format: 'bundle',
filename: PATH_TO_MY_COREJS_BUNDLE,
});
ℹ️ When using TypeScript, make sure to set esModuleInterop
to true
.