Ability to reinitialize components of module (or replace controller/components in runtime)
See original GitHub issueAbility 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:
- Created 6 years ago
- Reactions:4
- Comments:8 (5 by maintainers)
Top GitHub Comments
was this ever made?
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.