Repository navigation
feat(core): accept module metadata as the root module - #18523
Merged
Merged
Conversation
NestFactory.create(), createApplicationContext() and
createMicroservice() now take plain module metadata, such as
{ controllers: [AppController] }, in place of a root module class.
Nest applies @module() to a new AppModule class, the same way
Test.createTestingModule() builds its root module, so unknown keys
are rejected as usual.
This was referenced Nov 16, 2026
ofri-peretz
added a commit
to ofri-peretz/eslint
that referenced
this pull request
Nov 18, 2026
NestJS 12.5.1 (nestjs/nest#18523) accepts module metadata as the root module, so NestFactory.create({ imports: [JwtModule.register(...)] }) registers JwtModule in main.ts with no *.module.ts. require-expiration read only module files and missed it. It now reads main.ts and bootstrap.ts as well. Also kills the rule's 8 surviving mutants (5 by test, 2 equivalent conditionals removed), locks nestjs-security's project scan to root metadata in main.ts, and advances the NestJS release cursor. Intent: docs/intents/nestjs-nest-v12.5.1-root-module-metadata Co-Authored-By: Claude <noreply@anthropic.com>
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.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
The root module passed to
NestFactoryhas to be a class (or a dynamic module with amoduleclass), so even the smallest app needs a decorated module class:Issue Number: N/A
What is the new behavior?
NestFactory.create(),createApplicationContext()andcreateMicroservice()also accept plain module metadata:IEntryNestModulegainsModuleMetadata. A plain object withoutmoduleorforwardRef(or a promise of one) is treated as metadata.@Module(metadata)to a newAppModuleclass per call, the same wayTest.createTestingModule()builds its root module. Unknown keys are rejected with the usual "Invalid property … passed into the @module() decorator" error, which also catches passing a module namespace object (await import('./app.module')) by mistake.AppModulein logs and the devtools graph.It's meant as a shorthand for small apps: middleware (
configure()) and lifecycle hooks on the root module still need a module class.Does this PR introduce a breaking change?
IEntryNestModuleis a public type and its union is wider now, so outside code that narrows it exhaustively could see new type errors.Other information
Docs for docs.nestjs.com to follow.