Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

277
Views
Can reduce the dependence on core-js for dynamic import webpack?

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.

Babel: enter image description here

Clean: enter image description here

If you need more information, write in the comments, also open to criticism if I'm doing something wrong here ((

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!