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

181
Visualizações
Loading certain javascript files/modules when bundle is first loaded?

I want to have a bunch of TS/JS files around my src folder that should always be loaded/required/imported at startup without every programmer in the team have to worry to put them in some global "services.ts" file that is loaded at startup.

Traditionally I would have a services.ts file that gets imported in my index.ts or App.tsx

// src/services.ts
import "events/eventManager.service"
import "sentry/sentry.service"
import "fetch/retry.service"

By importing those files, they all perform some operations on module level (when they are loaded).

// index.ts
import "services"

I am looking now for a way that I can get rid of the src/services.ts file and its manual imports but instead have all the service files loaded already when index.ts get loaded.

I thought there might be some sort of babel mechanism to import files from src by a pattern src/**/*.service.ts that all get implicitly loaded before index.ts is loaded.

Or it builds up a virtual module services which I could then async import using await import("services") which would be fine too.

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