pongular icon indicating copy to clipboard operation
pongular copied to clipboard

Enable lazy loading of modules

Open StephenWakely opened this issue 11 years ago • 3 comments

Currently all node modules need to be loaded at server start up for them to be wired up.

It might be nice to create some form of mechanism to enable lazy loading of modules, so they are only required when needed.

StephenWakely avatar Jun 20 '14 13:06 StephenWakely

Interesting concept. We'd have to basically create some sort of dependency matching to the require file paths and then load them as modules require them? Ehh... I don't know... sounds terrible. I can't really think of an elegant way to handle something like that... not without major chances to the injection framework....

chesleybrown avatar Jun 20 '14 17:06 chesleybrown

Possibly some kind of module loader that could be injected. The class that requires the service would just invoke the loader and fetch the service and then unload at the end.

That's all I got at the minute. No it doesn't sound very elegant. And not sure if it would provide any advantage in a web app with multiple connections loading and unloading modules.

Could be useful for a desktop app where a low overhead is more important..

StephenWakely avatar Jun 20 '14 18:06 StephenWakely

Yeah. I've got to get on benchmarking this to see if having to load all the modules is really a performance issue or not. It's possible it's negligible? lol

chesleybrown avatar Jun 20 '14 19:06 chesleybrown