diff --git a/src/plugin-loader.js b/src/plugin-loader.js index 803928b99..9a8c18940 100644 --- a/src/plugin-loader.js +++ b/src/plugin-loader.js @@ -129,7 +129,7 @@ async function loadFromPackage(app, packageJsonPath, exitHooks) { */ async function loadFromFile(app, pluginFilePath, exitHooks) { try { - const plugin = await getPluginModule(pluginFilePath); + const plugin = await import(pluginFilePath); console.log(`Initializing plugin from ${pluginFilePath}`); return await initPlugin(app, plugin, exitHooks); } catch (error) { @@ -198,21 +198,6 @@ async function initPlugin(app, plugin, exitHooks) { return true; } -/** - * Loads a module from a file depending on the module type. - * @param {string} pluginFilePath Path to plugin file - * @returns {Promise} Promise that resolves to plugin module - */ -async function getPluginModule(pluginFilePath) { - if (isCommonJS(pluginFilePath)) { - return require(pluginFilePath); - } - if (isESModule(pluginFilePath)) { - return await import(pluginFilePath); - } - throw new Error(`Unsupported module type in ${pluginFilePath}`); -} - module.exports = { loadPlugins, };