question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

import module in condition based

See original GitHub issue

Is there a way to import module or add component to main module on condition based

ex:


@Module(
    {
        modules: [ModuleA, ModuleB, ModuleC]
    })

In this in some place i need only ModuleA, not ModuleB and ModuleC, but in some condition, I will be using ModuleB and not others.

Is there a way to import here based on some condition…

Also, I have the same situation in component loading. is that possible in components too? I would be happy if I have any one of these


Nest version: 4.6.4

 
For Tooling issues:
- Node version: 8.9.4  
- Platform: Windows  



Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
shekohexcommented, Apr 20, 2019

Okay, i know someone can help with that 😃

cc @bashleigh

2reactions
shekohexcommented, Apr 25, 2018

I think you are looking for Dynamic Modules see here https://docs.nestjs.com/modules at the end of this page.

in Dynamic Module you should have control of what will be included in components array, and so imports.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Conditional import of modules in Python - Stack Overflow
In my program I want to import simplejson or json based on OS being Linux or Windows. I take the OS name as...
Read more >
Dynamically/conditionally importing JavaScript modules
Dynamic imports are a great way to specify dynamic paths to import modules, as well as conditionalise whether they should be imported at...
Read more >
Conditional imports in one line using `else` - Ideas
Conditional imports are somewhat common in code that supports ... Choosing a module based on a condition (if for some reason you need...
Read more >
Learning about Python Conditional Import
Python conditional import comes into use while importing modules. In python, modules are pieces of code containing a set of functions that ...
Read more >
Conditional module imports in Angular | by Luuk Gruijs - Medium
Conditional module imports in Angular ... Whenever you're introducing third-party services to your Angular application there are cases that you need those ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found