Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Load feature-specific dependencies on first use

未关闭
#1,577 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
58/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
docker, node.js, typescript

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.
主要语言
TypeScript
星标
2.6k
派生
274
平均合并
1 天 14 小时
30 天内合并 PR
44

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

testcontainers/testcontainers-node 的其他 Issue

查看 testcontainers/testcontainers-node 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。