Questions
10 of 25
1What are dynamic modules in NestJS and when do you use them?
2How would you lazy-load a module in NestJS to improve startup time?
3What are the four properties inside @Module() decorator?
4What is the difference between a shared module and a global module in NestJS?
5What is a NestJS module, and why is it needed?
6What is the difference between exports in a module and making a provider global with @Global()?
7What is the purpose of a module in NestJS and what does the @Module() decorator do?
8Are NestJS modules singletons? What does that mean practically?
9What is a feature module in NestJS and why should you use them instead of putting everything in AppModule?
10Can a feature module re-export an imported module in NestJS? When is this useful?
11What does the @Global() decorator do and how does it change module behaviour in NestJS?
12What are the risks of overusing @Global() modules in NestJS?
13How do you register a global module exactly once in NestJS and what happens if you register it twice?
14What is the naming convention for dynamic module static methods in NestJS and what does each name signal?
15How do you structure a feature module that has sub-features in NestJS?
16What is the difference between a shared module and a global module in NestJS?
17How can a dynamic module expose a forFeature() method that works alongside a forRoot() registration in NestJS?
18What is the module encapsulation rule in NestJS and why does it matter?
19What must the object returned by a dynamic module's static method always include in NestJS?
20What is the difference between imports and providers inside @Module()?
21What is a shared module in NestJS?
22When should you export a module vs export individual providers from a module in NestJS?
23What is a dynamic module in NestJS and how is it different from a static module?
24How do you implement forRootAsync() in a dynamic module so that options can be loaded asynchronously from ConfigService?
25How do you write a dynamic module that supports both sync (register) and async (registerAsync) configuration sharing the same internal providers?
10 / 25

Can a feature module re-export an imported module in NestJS? When is this useful?

Difficulty: 5/10
module re-export, dependency injection, module organization

Yes — a module can re-export any module it imports, making that module's exports available to any consumer of the re-exporting module. This is the standard pattern for building layered shared infrastructure that avoids every feature module importing the same set of utility modules individually.

Re-exporting an imported module
When re-exporting is useful:
  1. 1

    Infrastructure bundles — group HttpModule, ConfigModule, LoggerModule into one CoreModule import.

  2. 2

    Layered APIs — a parent module exposes a sub-module's providers without exposing the sub-module's internals.

  3. 3

    Library modules — a library re-exports third-party modules it wraps so consumers don't need direct dependencies.

  4. 4

    Re-exporting a module is equivalent to exporting all of its exported providers at once.

Scenario Questions

0-2 years experience

  1. 1You have a UsersFeatureModule that imports the SharedModule which provides a LoggerService. How would you make LoggerService available to any module that imports UsersFeatureModule without importing SharedModule directly?
  2. 2If you forget to re-export SharedModule from UsersFeatureModule, what error will you see when another module tries to inject LoggerService?

2-5 years experience

  1. 1During a sprint you notice that a newly added OrdersFeatureModule can't resolve the ConfigService even though it imports ConfigModule. Explain how re-exporting could fix this and what trade‑offs you consider.
  2. 2You refactored a PaymentsFeatureModule to import a third‑party AuthModule. After the change, other modules that depend on AuthModule start failing. Walk through debugging steps and how proper re‑exporting might resolve the issue.

5-8 years experience

  1. 1In a large monorepo, several feature modules need access to a common DatabaseModule. Discuss the pros and cons of having each feature module import vs. having a CoreFeatureModule re‑export DatabaseModule, especially regarding startup time and circular dependencies.
  2. 2Your team is hitting memory pressure because many modules eagerly load providers from a shared AuthModule. How could you redesign the module exports/re‑exports to enable lazy loading while keeping the public API stable?

8+ years experience

  1. 1Your organization plans to migrate from a monolithic NestJS app to a microservice architecture. How would you use module re‑exports to define clear contract boundaries between services, and what long‑term maintenance considerations arise?
  2. 2Several teams depend on a legacy ReportingModule that re‑exports many internal utilities. Over time, the module has become a leaky abstraction. Propose a strategy to refactor the re‑exports to improve encapsulation without breaking downstream services.

Follow-up Questions

  • What happens if you accidentally export a module that also imports the current module?
  • How would you detect or prevent circular re‑exports in a large codebase?
  • Can you give an example where you’d choose not to re‑export a module even though it’s imported?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.