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

105
Visualizações
re-exporting module evaluates module even though export is not used

In a large typescript react app with webpack we have a common module with a bunch of utilities, classes, types etc. This module is set up with an index file that re-exports all the individual modules. Like so

export * from './a';
export * from './b';
export * from './c';
...

Some of these individual modules a also use a similar index file to re-export stuff, so the export tree is several layers deep. It probably involves thousands of exported items.

The issue is that when a simple function is imported from this common ui module it evaluates ALL the individual modules as well. Some of these individual modules for example have exports with expensive constructors export const classA = new ClassA().

This common module is deeply ingrained through multiple apps that are quite large (think hundreds of thousands lines of code). Each individual file in our apps maybe imports at most 3 or 4 items from this common module.

Is there a way to clean this up so it is less wasteful without refactoring all the applications? Preferably without having to update all our individual import statements throughout all applications.

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