Components not extensible
Closed this issue · 5 comments
This is from the make
function
https://github.com/ractivejs/rvc/blob/master/rvc.js#L386
options = {
template: definition.template,
partials: definition.partials,
css: definition.css,
components: imports
};
https://github.com/ractivejs/rvc/blob/master/rvc.js#L375
Component = Ractive.extend( options );
} catch ( err ) {
errback( err );
return;
}
callback( Component );
} else {
Component = Ractive.extend( options );
callback( Component );
Unless I'm overlooking something on the docs and readmes, this means rvc
components can't extend from rvc
components because
- The plugin uses
Ractive.extend
and notParent.extend
options
is hard-coded in the plugin, and not the one incomponent.exports
It would be nice to have something like
// Non-extending
component.exports = Ractive.extend({...});
// Extending
var OtherComponent = require('rvc!nonextending');
component.exports = OtherComponent.extend({...});
Perhaps the component definition could return a base
property, which is a constructor to extend from:
component.exports = {
base: require( 'rvc!parent.html' ),
...
};
What about a separate property on component with the moniker of the component to extend?
component.base = 'parent'
component.exports = {...}
@Rich-Harris Your comment just popped up. I like putting it outside the options, because it's a load thing, not an options thing.
Could be either object or string I suppose
It would be nice to have it similar to the non-loader syntax. Makes it more consistent.
Closing this issue. Figured out that inheritance is complicated compared to just building components with configurable options.