feat: invocation option for Flecks.provide()
This commit is contained in:
parent
071509223b
commit
bbcf0d8798
|
@ -198,6 +198,8 @@ is *exactly equivalent* to the gather example above. By default, `Flecks.provide
|
|||
|
||||
```javascript
|
||||
{
|
||||
// Whether to invoke the default export as a function.
|
||||
invoke = true,
|
||||
// The transformation used on the class path.
|
||||
transformer = camelCase,
|
||||
}
|
||||
|
|
|
@ -365,6 +365,7 @@ export default class Flecks {
|
|||
static provide(
|
||||
context,
|
||||
{
|
||||
invoke = true,
|
||||
transformer = camelCase,
|
||||
} = {},
|
||||
) {
|
||||
|
@ -373,7 +374,7 @@ export default class Flecks {
|
|||
context.keys()
|
||||
.map((path) => {
|
||||
const {default: M} = context(path);
|
||||
if ('function' !== typeof M) {
|
||||
if (invoke && 'function' !== typeof M) {
|
||||
throw new ReferenceError(
|
||||
`Flecks.provide(): require(${
|
||||
path
|
||||
|
@ -384,7 +385,7 @@ export default class Flecks {
|
|||
}
|
||||
return [
|
||||
transformer(this.symbolizePath(path)),
|
||||
M(flecks),
|
||||
invoke ? M(flecks) : M,
|
||||
];
|
||||
}),
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user