
Product
Introducing Socket Scanning for OpenVSX Extensions
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.
@nestjsplus/dyn-schematics
Advanced tools
This package contains a set of NestJS CLI schematics for generating modules that can be dynamically configured. The concepts behind the generated code is covered in detail in this article.
See below for a description of the use cases.
Install the package globally as shown below. Due to the implementation of the NestJS CLI, the package must be global.
npm install -g @nestjsplus/dyn-schematics
Currently, there are two use cases supported, each with a corresponding schematic:
module schematic, but creates a fully implemented dynamic module.These schematics are built on top of the Nest CLI infrastructure, so their usage is exactly as documented on that page.
Note: since these schematics are built on top of the Nest CLI, all of the optional arguments (such as specifying an optional path in which to generate the code) and options (such as
--dry-run,--flat) are available. Currently, however, the schematics do not generate spec files.
Note: I'm working on schematics to add new components to an existing dynamic module, such as additional options providers. This should be coming soon.
The following step will create a new folder using <pkg-name>, which will contain the standalone package files and folders for your new dynamic module package.
dynpkg schematicnest g -c @nestjsplus/dyn-schematics dynpkg <pkg-name>
dynpkg is the name of the schematic used to generate a new standalone package containing a dynamic module.<pkg-name> is the name of the new package you're building.The schematic will prompt you asking whether to create a test client. If you answer yes, it will add a small module, which you can later easily remove, to test out the newly generated schematic. I recommend you choose yes when first testing out the schematic.
Move to the sub-folder just created:
cd <pkg-name>
pkg-name is the name you supplied in the original nest g command above.Install the dependencies for the generated package:
npm install
If you answered yes to the prompt Generate a testing client?, a small testing module was automatically generated called <pkg-name>ClientModule. You can test that the template was properly generated by running:
npm run start:dev
Then browse to http://localhost:3000. Your browser should display Hello from <pkg-name>Module!.
The package.json and tsconfig.json files are generated according to the process described in this article. This means that publishing the package to npm is as simple as:
package.json with your author information, etc.npm publishSee the npm packaging article for more information.
Make sure you're in the project root folder, just as you would be if running something like nest g controller myController.
dnymod schematicnest g -c @nestjsplus/dyn-schematics dynmod <module-name>
dynmod is the name of the schematic used to generate a new dynamic module (which will be added to your existing project).<module-name> is the name of the new module you're building.The schematic adds the new module in a folder named <module-name>. Just like using the built-in module schematic (e.g., nest g module myNewModule), this will add the generated module to the imports list of your root module with the appropriate metadata and includes. At this point, you can customize the generated module as needed.
The files in the project have comments that should help guide you.
You can also refer to these articles:
How to build completely dynamic NestJS mdoules - for details on the concepts behind the dynamic module pattern.
Built a NestJS module for Knex.js in 5 minutes - an end-to-end tutorial on using these schematics.
See Changelog for more information.
Contributions welcome! See Contributing.
John Biundo (Y Prospect on Discord)
Licensed under the MIT License - see the LICENSE file for details.
FAQs
NestJS Dynamic Module Schematics for @nestjs/cli
We found that @nestjsplus/dyn-schematics demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.

Product
Bringing supply chain security to the next generation of JavaScript package managers

Product
A safer, faster way to eliminate vulnerabilities without updating dependencies