Best way to implement optional modules for node.js app

不问归期 提交于 2021-02-08 11:14:04

问题


I'm looking to create an app with optional modules that I will not know the names of in the application.

For example, imagine outlook, but the calendar/tasklist/mail pieces are optional components, you would npm install outlook-framework then create your app that requires "outlook-framework" but then I would like to import all packages installed that start with "outlook-". So I can npm install outlook-mail and that gives me email support, same for outlook-calendar, or even something I didn't write, maybe outlook-twitter or outlook-rss (or thirdpary-outlook-module)

Is there some existing mechanism for loading modules like this? Or does anyone have any better ideas for loading unknown, optional modules?

Thanks!


回答1:


I've decided that the packages will need to have a manifest, like "outlook-manifest.json" and to load the modules, I'll list directories in node_modules, find directories with a manifest, and load those.



来源:https://stackoverflow.com/questions/34533173/best-way-to-implement-optional-modules-for-node-js-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!