My Software contains a
lib package, a
cli package and an arbitrary number of plugin packages.
The plugin packages do the algorithmic work.
The lib package basically just executes the plugins and passes the result of each plugin to the next plugin and exposes the
libs functionality to the
cli package. The
cli package reads the configuration file and passes the configuration(which plugins to execute in which order) to the
lib package. The
lib is basically a single line of typescript code that uses the
compose/pipe/flow function from functional programming and looks like this:
export const bumpup: (plugins: Plugin)=> BumpupData = (plugins) => flow(...plugins)();
The reason for making an extra package for a single line is
- Eventually the
libshould be usable without the
cliby other packages
libprovides the interfaces for plugins and I don't want plugin authors to depend on the
clipackage to write their plugins, especially for the case where the
libis used without the
The plugins are read from the configuration and are loaded dynamically at runtime from the
node_modules folder with the dynamic import from ES6.
That module loading code takes the name of the package that should be loaded and returns a function complying to the plugin interface that can be passed to the lib function.
In which package does the code for loading the modules belong and why?
What are reason for and against putting that code in one of the packages.
I have the feeling that the pattern of separating software in
lib package is very common, is there a name for that pattern so I can read more on that pattern?