Repository navigation
Import NestJS statically in specs so NestJS 12 boots one copy of it - #148
Merged
Merged
Conversation
Five integration specs loaded @nestjs/common, @nestjs/core and @nestjs/drizzle with import() inside before(). NestJS 12 ships core and common as ESM-only, and under tsx an import() of an ESM-only package loads a second copy next to the one src/ requires. The specs' NestFactory then registered a different HttpAdapterHost class from the one nestjs-cls's ClsRootModule injects, so every non-HTTP boot failed with "Nest can't resolve dependencies of the ClsRootModule". That is what kept the NestJS 12 Dependabot group red. Static imports change nothing on NestJS 11. This is the third two-copies failure, after nestjs-cls and @nestjs/outbox, so GUIDELINES section 7 states the rule and npm run lint enforces it: scripts/check-static-imports.mjs fails on any import() of @nestjs/*, @nestjs-cls/* or nestjs-cls in src/, test/ and scripts/.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@nestjs/common,@nestjs/coreand@nestjs/drizzlewithimport()insidebefore(). NestJS 12 ships core and common as ESM-only, and undernode --import tsxanimport()of an ESM-only package loads a second copy next to the onesrc/requires. The specs'NestFactorythen registered a differentHttpAdapterHostclass from the onenestjs-cls'sClsRootModuleinjects, so every non-HTTP boot failed with "Nest can't resolve dependencies of the ClsRootModule (?, ModuleRef)".nestjs-clsand@nestjs/outbox, so the rule and its enforcement land here too.Changes
test/integration/{kafka-consumer-inmemory,kafka-request-reply-inmemory,rabbit-inbox,reliable-messaging.kafka,reliable-messaging.rabbitmq}.spec.ts: the@nestjs/*imports move frombefore()to the top of the file. Our own env-reading modules stay dynamic.scripts/check-static-imports.mjs, run bynpm run lint: fails on anyimport()of@nestjs/*,@nestjs-cls/*ornestjs-clsinsrc/,test/andscripts/. On the unfixed tree it reports exactly the 13 removed calls.GUIDELINES_NEST_REFERENCE_APP.md§7 states the rule ("When In Doubt" becomes §8).CHANGELOG.mdentry under Unreleased.Modules Touched
Public Surface (libraries)
package.jsondescription,docs/, repo About —npm run docs:check)Security Review
Dependency Review
Migrations
Validation
git diff --checknpm run typechecknpm run lintnpm run test:covnpm run security:auditValidation Notes
test:cov173 tests, 168 pass, 0 fail, 5 live-broker skips. Without it, 18 tests fail with theClsRootModuleerror.Release Notes
CHANGELOG.mdupdated