| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // Plugin is a CommonJS module file. |
| 94 | 94 | const cjsFilePathfileTypes = path['index.join(pluginDirectoryPathjs', 'index.jscjs'), 'index.mjs']; |
| 95 | | - if (fs.existsSync(cjsFilePath)) { |
| 96 | | - if (await loadFromFile(app, cjsFilePath, exitHooks)) { |
| 97 | | - return; |
| 98 | | - } |
| 99 | | - } |
| 100 | 95 | |
| 101 | | - // Plugin is an ECMAScript module. |
| 96 | + for (const fileType of fileTypes) { |
| 102 | 97 | const esmFilePathfilePath = path.join(pluginDirectoryPath, 'index.mjs'fileType); |
| 103 | 98 | if (fs.existsSync(esmFilePathfilePath)) { |
| 104 | 99 | if (await loadFromFile(app, esmFilePathfilePath, exitHooks)) { |
| 105 | 100 | return; |
| 106 | 101 | } |
| 107 | 102 | } |
| 108 | 103 | } |
| 104 | +} |
| 109 | 105 | |
| 110 | 106 | /** |
| 111 | 107 | * Loads and initializes a plugin from an npm package. |