Felix K.
Felix K.

Reputation: 15663

NestJS: Drawbacks of dynamic modules?

Background

NestJS comes with a feature called dynamic modules which gives the caller (=importer) of a module the chance to configure a module and thereby its providers.

Using dynamic module features, we can make our configuration module dynamic so that the consuming module can use an API to control how the configuration module is customized at the time it is imported. (https://docs.nestjs.com/fundamentals/dynamic-modules)

Question

Does this flexibility come at any cost, meaning, are there any negative effects involved with this "dynamic modules" in the sense that it negatively impacts performance or the compilation result? Or is the only drawback of dynamic modules the little bit of extra code that is required to create them, in contrast to non-dynamic (=static) modules?

Upvotes: 0

Views: 629

Answers (1)

Jay McDoniel
Jay McDoniel

Reputation: 70151

The only drawbacks that I have found with Dynamic Modules is that they can sometimes be a headache to debug if things go sideways during development. Otherwise, I haven't noticed anything changing in compilation or runtime.

I will say I am having a bit of a problem with configuring a dynamic module once and importing the then configured module without using a middle-man module to manage it, but otherwise they work great.

Edit 10/18/19

Wanted to come back and say that the issue I've been facing has been solved. It's a bit of an interesting solution, but I think overall it's a pretty cool one to see. Here is a high level context of it, hopefully there will be a blog post about it in the near future.

Upvotes: 3

Related Questions