Skip to content

Declare missing module dependencies - #1485

Merged
cristianrgreco merged 1 commit into
mainfrom
claude/declare-missing-module-dependencies
Oct 10, 2026
Merged

cristianrgreco merged 1 commit into
mainfrom
claude/declare-missing-module-dependencies

Conversation

@cristianrgreco

Copy link
Copy Markdown
Collaborator

Summary

@testcontainers/k3s and @testcontainers/selenium import packages at runtime that they don't declare. They only resolve today because npm hoists them from testcontainers's own dependency tree. Under a strict layout (pnpm with hoist=false, Yarn PnP) both modules crash on import.

Package Undeclared import Fix
@testcontainers/k3s tar-stream (k3s-container.ts:2) add to dependencies (+ @types/tar-stream dev)
@testcontainers/selenium tar-fs, tmp (selenium-container.ts) add to dependencies (+ @types/tar-fs, @types/tmp dev)
@testcontainers/azurite (test utils only) @azure/core-auth add to devDependencies

Version ranges match what is already resolved in the lockfile, so package-lock.json only gains the new manifest entries and no installed version changes.

To stop this from coming back, this enables Biome's noUndeclaredDependencies rule. Biome is already our linter, so no new tooling is needed. It's turned off for *.test.ts because vitest is declared at the workspace root, which the rule doesn't look at.

Reproduction (published 12.2.0)

echo '{"private":true}' > package.json && echo 'hoist=false' > .npmrc
npx pnpm@9.15.9 add @testcontainers/k3s@12.2.0 @testcontainers/selenium@12.2.0
node -e "require('@testcontainers/k3s')"       # Error: Cannot find module 'tar-stream'
node -e "require('@testcontainers/selenium')"  # Error: Cannot find module 'tar-fs'

With tarballs packed from this branch, the same strict install imports both modules successfully.

Verification

  • Red: with the rule enabled and the manifests reverted, npx biome lint . gives Found 4 errors. (k3s-container.ts:2, selenium-container.ts:3, selenium-container.ts:16, azurite-test-utils.ts:1)
  • Green: with the manifests fixed, npx biome lint . gives Checked 456 files ... No fixes applied.
  • Strict pnpm install of locally packed @testcontainers/k3s and @testcontainers/selenium tarballs: require() works for both (it fails on 12.2.0, see above).
  • npm run check-compiles: passes
  • npm run format / npm run lint: no changes

No runtime code changed, so the module test suites weren't rerun.

Not breaking

This only adds dependencies that were already installed transitively at the same versions. No source or public API changes. npm users see no difference; strict package-manager users go from a crash on import to working.

Follow-up (not in this PR)

@testcontainers/gcloud exports SpannerEmulatorHelper, which imports @google-cloud/spanner (types plus a dynamic import), but spanner is only a devDependency. The docs ask users to install it themselves, so it is intentionally user-provided. It is probably best declared as an optional peerDependency, but that can make npm report conflicts for users on other spanner majors, so it deserves its own discussion.

k3s imports tar-stream and selenium imports tar-fs and tmp at runtime
without declaring them, so they only resolve through npm hoisting and
crash on import under strict installs (pnpm hoist=false, Yarn PnP).
Declare them, plus azurite's test-only @azure/core-auth, and enable
Biome's noUndeclaredDependencies rule to keep it that way.
@cristianrgreco cristianrgreco added bug Something isn't working patch Backward compatible bug fix labels Oct 8, 2026
@netlify

netlify Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for testcontainers-node ready!

Name Link
🔨 Latest commit ba7aa20
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-node/deploys/6ac7e9aa9b8dde00092bfd3a
😎 Deploy Preview https://deploy-preview-1485--testcontainers-node.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 212ec197-0a88-41d3-88d7-6c5e04cb941f

📥 Commits

Reviewing files that changed from the base of the PR and between c528f29 and ba7aa20.


⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json

📒 Files selected for processing (4)
  • biome.json
  • packages/modules/azurite/package.json
  • packages/modules/k3s/package.json
  • packages/modules/selenium/package.json

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review.



📝 Walkthrough

Walkthrough

Biome now treats undeclared dependencies as errors, except in files matching **/*.test.ts. The Azurite, k3s, and Selenium package manifests add dependencies and development type packages.


Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to ba7aa

The dependency declarations and lockfile are consistent, and the new lint rule helps catch undeclared dependencies. No material merge risk remains.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: declaring missing module dependencies.
Description check Passed The description directly explains the missing dependencies, the strict package-manager failure, the dependency fixes, lint rule change, and verification results.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cristianrgreco
cristianrgreco merged commit 0ad4c70 into main Oct 10, 2026
276 checks passed
@cristianrgreco
cristianrgreco deleted the claude/declare-missing-module-dependencies branch October 10, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working patch Backward compatible bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant