Skip to content

Commit c77b0fc

Browse files
shlomiassafblakeembrey
authored andcommitted
Support ES2015-style exports for plugins (#594)
1 parent bb0068a commit c77b0fc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/lib/utils/plugins.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,15 @@ export class PluginHost extends AbstractComponent<Application> {
4242
const plugin = plugins[i];
4343
try {
4444
const instance = require(plugin);
45-
if (typeof instance === 'function') {
45+
const initFunction = typeof instance.load === 'function'
46+
? instance.load
47+
: instance // support legacy plugins
48+
;
49+
if (typeof initFunction === 'function') {
4650
instance(this);
4751
logger.write('Loaded plugin %s', plugin);
4852
} else {
49-
logger.error('The plugin %s did not return a function.', plugin);
53+
logger.error('Invalid structure in plugin %s, no function found.', plugin);
5054
}
5155
} catch (error) {
5256
logger.error('The plugin %s could not be loaded.', plugin);

0 commit comments

Comments
 (0)