Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

275
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda