What is the point - I use Babel and core-js for polyfill and here when using the loading of the dynamic module to reduce the size of the code and of course not to load on the page of what is not necessary, I faced that core-js on generated 4336 lines code for a script of 12 lines of code:
import isMobile from 'is-mobile';
document.addEventListener('DOMContentLoaded', function () {
if (isMobile() === true) {
import('./module/mobilemenu').then(function ({default: init}) {
const menu = document.querySelector('.mobile-menu');
init(menu, document.body);
});
}
});
Judging by the Babel documentation for the corresponding plugin (@babel/plugin-syntax-dynamic-import) combined with the parameter in the configuration babel.confi.js useBuiltIns: 'usage' it loads these modules from core-js:
import "core-js/modules/es6.promise";
import "core-js/modules/es6.array.iterator";
Is it possible to somehow optimize this file size, maybe core-js uses modules that are not used for the code above and they could be ignored IgnotePlugin?
I understand that support for old standards inflates the source code, but in this case the code from webpack without a preprocessor takes 400 and with Babel 10 times more, and I do not really like it :(
So maybe someone was trying to figure out what is the reason for the cumbersome file and whether it can be somehow shortened.
If you need more information, write in the comments, also open to criticism if I'm doing something wrong here ((