Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Load feature-specific dependencies on first use

Aperta
#1,577 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
58/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker, node.js, typescript

Direzione di ricerca

Read the four listed areas: port-forwarder.ts, http-wait-strategy.ts, the generic container files, and the compose clients directory. Check how port-generator.ts loads get-port and review AGENTS.md for the CommonJS requirement. Measure import time before and after; done means feature-specific dependencies load on first use and the measured saving justifies keeping the change.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

maintenance patch

What happens

Importing testcontainers loads every dependency up front, including ones most test files never use. Measured with the local build of 12.2.0 on Node 24:

Import Time
require("testcontainers"), warm about 165 ms
require("testcontainers"), cold about 330 ms
undici alone 69 ms
dockerode alone 66 ms
archiver alone 57 ms
ssh-remote-port-forward alone 23 ms
docker-compose alone 15 ms

The individual figures are from separate processes and overlap, so they do not add up.

  • ssh-remote-port-forward (and ssh2, with its optional native cpu-features build) is needed only for TestContainers.exposeHostPorts.
  • undici is needed only for the HTTP wait strategy.
  • archiver is needed only when copying files into a container.
  • docker-compose is needed only for DockerComposeEnvironment.

All four are imported statically. Test runners that isolate modules per test file pay the import once per file.

Expected

Feature-specific dependencies are loaded on first use. get-port is already loaded this way in port-generator.ts.

Where

  • packages/testcontainers/src/port-forwarder/port-forwarder.ts
  • packages/testcontainers/src/wait-strategies/http-wait-strategy.ts
  • packages/testcontainers/src/generic-container/generic-container.ts and started-generic-container.ts
  • packages/testcontainers/src/container-runtime/clients/compose/

Notes

  • Runtime dependencies must keep loading from CommonJS (AGENTS.md).
  • ssh-remote-port-forward could become an optional dependency, which would also remove the native build step from installs that never expose host ports. That part would be major.
  • Measure before and after. If the saving is small, close this.

Dependencies

  • Nothing blocks this. It can start now.
Lingua principale
TypeScript
Stelle
2.6k
Fork
274
Merge medio
1g 14h
PR unite (30g)
44

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di testcontainers/testcontainers-node

Tutte le issue di testcontainers/testcontainers-node

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.