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.

Ability to reinitialize components of module (or replace controller/components in runtime)

See original GitHub issue

Ability to reinitialize components of module or Ability to replace/merge controller/components in modules in runtime or Ability to create modules and add to application in runtime

I’m submitting a…


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Unable to (reinitialize components of module / replace/merge controller/components in modules in runtime / create modules and add to application in runtime)

Expected behavior

Possibility to do it.

What is the motivation / use case for changing the behavior?

Tools like nodemon or node_dev restarts application in cold mode. It means that behavior the same as manual ctrl+c -> node server.ts The goal is to adapt nestjs to hot module replacement API of webpack or similar tools. Because cold can take a lot of time up to 10 seconds which is bad developer experience. Most of the time config (connection string, etc.), node_modules, etc. are not changing during development. Hot module replacement is much faster. It would be nice if modules can ‘reinitialize’ feature (see other options in title or in ‘Current behavior’)

Example code with hmr:

const app = await NestFactory.create(AppModule);
await app.listen(config.get('port'));

// Example 1
if (module.hot) {
    module.hot.accept('./cat.module', () => {
        const { CatModule } = require('./cat.module'); // Required to get new reference.
        app.replaceModule(CatModuleOld, CatModule);
    });
}

// Example 2
if (module.hot) {
    module.hot.accept('./cat.module', () => {
        const { CatModule } = require('./cat.module'); // Required to get new reference.
        app.addModule(CatModule); // Acts like merge and overwrites old controllers paths, etc.
    });
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

10reactions
ppolicherlacommented, Oct 12, 2018

was this ever made?

0reactions
lock[bot]commented, Sep 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dagger- Should we create each component and module for ...
Declaring a separate module for each Activity is not a good idea at all. Declaring separate component for each Activity is even worse....
Read more >
Kubernetes Components
A Kubernetes cluster consists of the components that are a part of the control plane and a set of machines called nodes.
Read more >
Diagnostics and service - B&R Industrial Automation
Participants will learn how to replace modules and resume operation of the B&R ... B&R controller components come with an extensive diagnostics interface....
Read more >
Reset module command in cisco -6509 - Cisco Community
Switch#hw-module module 4 ? boot Specify boot options for the module through Power Management Bus control register. reset Reset specified component. simulate ...
Read more >
SAN Volume Controller: Troubleshooting Guide - IBM
IBM service support representative (SSR) can remove or install ... of a system restart from a pending power-off action or other controlled.
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