Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Load feature-specific dependencies on first use

Đang mở
#1,577 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
58/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
docker, node.js, typescript
Lĩnh vực
backend, performance

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
TypeScript
Star
2.6k
Fork
277
Merge trung bình
1 ngày 53 phút
Pull request đã merge (30 ngày)
58

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của testcontainers/testcontainers-node

Tất cả issue của testcontainers/testcontainers-node

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.