loadPlugins(plugins = {}) {
    const loadedPlugins = new Map();

    // first load plugins from Backend.plugin.use
    for (const [name, { plugin: instance, options }] of Object.entries(
      plugins,
    )) {
      const plugin = new Plugin(instance, { name, ...options });

      // the plugin cluster can be loaded in the startup script
      // and we need the manifest
      plugin.manifest = plugin.manifest || options.manifest;

      plugin.init(name);

      if (loadedPlugins.has(plugin.name)) {
        throw assertionError.get("name_already_exists", plugin.name);
      }

      loadedPlugins.set(plugin.name, plugin);
    }

    // then try to load plugins from the filesystem
    if (!fs.existsSync(this.pluginsEnabledDir)) {
      return loadedPlugins;
    }

    let pluginsPath = [];

    try {
      pluginsPath = fs
        .readdirSync(this.pluginsEnabledDir)
        .map((name) => path.join(this.pluginsEnabledDir, name))
        .filter((filePath) => fs.statSync(filePath).isDirectory());
    } catch (e) {
      throw assertionError.get(
        "invalid_plugins_dir",
        this.pluginsEnabledDir,
        e.message,
      );
    }

    debug("loading plugins: %a", pluginsPath);

    for (const relativePluginPath of pluginsPath) {
      const plugin = Plugin.loadFromDirectory(relativePluginPath);

      plugin.init(plugin.manifest.raw.name);

      if (loadedPlugins.has(plugin.name)) {
        throw assertionError.get("name_already_exists", plugin.name);
      }

      loadedPlugins.set(plugin.name, plugin);
    }

    return loadedPlugins;
  }
Load detected plugins in memory

@returns {object} list of loaded plugin