jonschlinkert / load-plugins

Thin wrapper around resolve-dep for loading plugins from node_modules or local directories. Like load-gulp-plugins, match dep, etc, but works for gulp, grunt, assemble, verb or anything other task runner or build system that uses plugins.
https://github.com/jonschlinkert
MIT License
22 stars 1 forks source link

Question: Lazy loading? #9

Closed arve0 closed 4 years ago

arve0 commented 8 years ago

I see gulp-load-plugins uses lazy loading. If I understand plugins correctly, load-plugins does not lazy load?

TrySound commented 8 years ago

@arve0 Yes, load-plugins doesn't support this. Tell me please, why you need lazy loading?

jonschlinkert commented 8 years ago

plugins are a pretty good use case for lazy loading. I've been using it a lot lately.

why you need lazy loading?

It ensures that only the modules that are actually used are required in. It can have a pretty dramatic effect on initialization time.

related: https://github.com/jonschlinkert/lazy-cache

arve0 commented 8 years ago

why you need lazy loading?

I might not actually need it, was just curious and pre-optimizing.

TrySound commented 8 years ago

@jonschlinkert Why this module? I thought requires caches by node natively.

jonschlinkert commented 8 years ago

I thought requires caches by node natively.

It does... after it requires in the module. The point of the "lazy" part of lazy-requiring is that a module isn't cached or loaded at all unless it's actually used at some point. e.g. there might be a module that is only used when a certain option is set. That's a good example of a dep that would benefit from being lazily required