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

188
Views
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
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!