Ok, I think I get what you're saying now. So you've made a factory plugin called 'myPluginFactory', and you're trying to figure out why it won't work outside of a component definition.
From what I understand, factory plugins allow you to accept configuration for creating an object. If you're factory isn't used within the context of a component, an object could be created, but there would be nothing to assign it to. There would also be no way for wire to know that you're trying to use a factory plugin, and some just creating a plain object like `context.myPluginFactory = { customProp: 'hello' }`.
Consider the built-in '
create' factory plugin.
define({
// This uses the create factory to create a component
// from the AMD module 'some/component',
// with args ('foo', 'bar')
// and assigns the created object to `context.someComponent`
someComponent: {
create: {
module: 'some/component',
args: ['foo', 'bar']
}
},
// this does not use the create factory,
// as we haven't told wire the name of the object
// we want to create.
create: {
module: 'some/component',
args: ['foo', 'bar']
}
});
I'm guessing you're trying to do something with your `myPluginFactory`
besides creating an object.
If you need to to create an object and do some other stuff, you can bite the bullet and assign it to an arbitrary key (though a factory with side-effects has some code smell, imo). Otherwise, if you just want to activate some arbitrary behavior from your spec, without returning an object, I would just put the code in a plain ol' AMD module. I do this for registering Handlebars templateHelper from my specs:
// templateHelpers/toUpperCase.js
define(['Handlebars', function(Handlebars) {
Handlebars.registerHelper('toUpperCase', function(str) {
return str.toUpperCase();
});
});
// spec.js
define({
// I'm using the `module` factory,
// to load (and run) the toUpperCase template helper module.
toUpperCaseHelper: {
module: 'templateHelpers/toUpperCase'
}
});
Note that I'm not accessing the 'toUpperCaseHelper' component at all. But the `module` factory has to be wrapped in an object, so wire doesn't think I"m trying to make a plain-old-js-object called 'module'.