Load feature-specific dependencies on first use
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 58/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- docker, node.js, typescript
- 领域
- backend, performance
调研方向
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 内容生成。
描述
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(andssh2, with its optional nativecpu-featuresbuild) is needed only forTestContainers.exposeHostPorts.undiciis needed only for the HTTP wait strategy.archiveris needed only when copying files into a container.docker-composeis needed only forDockerComposeEnvironment.
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.tspackages/testcontainers/src/wait-strategies/http-wait-strategy.tspackages/testcontainers/src/generic-container/generic-container.tsandstarted-generic-container.tspackages/testcontainers/src/container-runtime/clients/compose/
Notes
- Runtime dependencies must keep loading from CommonJS (AGENTS.md).
ssh-remote-port-forwardcould become an optional dependency, which would also remove the native build step from installs that never expose host ports. That part would bemajor.- 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
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
testcontainers/testcontainers-node 的其他 Issue
-
enhancement minor
难度 2/5 1-3 小时 新手友好度 74/100
testcontainers/testcontainers-node#1539 ·
维护者通常 1 天内回复
-
enhancement minor
难度 2/5 1-3 小时 新手友好度 82/100
testcontainers/testcontainers-node#1533 ·
维护者通常 1 天内回复
-
enhancement minor
难度 2/5 1-3 小时 新手友好度 77/100
testcontainers/testcontainers-node#1531 ·
维护者通常 1 天内回复
-
enhancement minor
难度 2/5 1-3 小时 新手友好度 76/100
testcontainers/testcontainers-node#1529 ·
维护者通常 1 天内回复
-
enhancement minor
难度 2/5 1-3 小时 新手友好度 78/100
testcontainers/testcontainers-node#1528 ·
维护者通常 1 天内回复
查看 testcontainers/testcontainers-node 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 80/100
aws/agentcore-cli#2606 ·
维护者通常 1 天内回复
-
ai-driven-qa bug Cosmetic
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
ai-driven-qa bug claude Minor
难度 2/5 1-3 小时 新手友好度 64/100
linagora/twake-mail-admin#301 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
reproduced
难度 2/5 1-3 小时 新手友好度 70/100
anomalyco/opencode#56038 · 1 条评论 ·
维护者通常 1 天内回复