Skip to content

Commit c83d156

Browse files
committed
feat: handle call function from loaded option.require
- call directly - fallback to `default`
1 parent 95f2f52 commit c83d156

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/worker/base.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,15 @@ const run = async options => {
181181
} else if (Array.isArray(ref)) {
182182
const [path, options] = ref;
183183

184-
const mod = await load(path);
185-
mod.apply(null, ...options);
184+
const loadedModule = await load(path);
185+
186+
if (typeof loadedModule === 'function') {
187+
loadedModule.apply(null, ...options);
188+
} else if( typeof loadedModule.default === 'function') {
189+
loadedModule.default.apply(null, ...options);
190+
} else {
191+
channel.send({type: 'non-invokable-require-option'});
192+
}
186193
}
187194
}
188195

0 commit comments

Comments
 (0)