lib/rvc.js
function load(file, options) {
	if (options.cache && rr.cache['rvc!' + file]) {
		return Promise.resolve(rr.cache['rvc!' + file]);
	}

	return requireJSAsync(file).then(function (Component) {
		// flush requireJS's cache
		_.forEach(requireJS.s.contexts._.defined, function (value, key, array) {
			if (key.substr(0, 4) === 'rvc!') {
				delete array[key];
			}
		});

		return utils.wrap(utils.selectTemplate(options, Component), options).then(function (template) {
			var basePath = path.relative(options.settings.views, path.dirname(file));
			Component.defaults.template = options.template = template;

			return Promise.join(utils.buildComponentsRegistry(options), utils.buildPartialsRegistry(basePath, options), function (components, partials) {
				_.assign(Component.components, components);
				_.assign(Component.partials, partials);
				options.components = {};
				options.partials = {};

				if (options.cache) {
					rr.cache['rvc!' + file] = Component;
				}

				return Component;
			});
		});
	});
}
function load(file, options) {
	if (options.cache && rr.cache['rvc!' + file]) {
		return Promise.resolve(rr.cache['rvc!' + file]);
	}

	return requireJSAsync(file).then(function (Component) {
		// flush requireJS's cache
		_.forEach(requireJS.s.contexts._.defined, function (value, key, array) {
			if (key.substr(0, 4) === 'rvc!') {
				delete array[key];
			}
		});

		return utils.wrap(utils.selectTemplate(options, Component), options).then(function (template) {
			var basePath = path.relative(options.settings.views, path.dirname(file));
			Component.defaults.template = options.template = template;

			return Promise.join(utils.buildComponentsRegistry(options), utils.buildPartialsRegistry(basePath, options), function (components, partials) {
				_.assign(Component.components, components);
				_.assign(Component.partials, partials);
				options.components = {};
				options.partials = {};

				if (options.cache) {
					rr.cache['rvc!' + file] = Component;
				}

				return Component;
			});
		});
	});
}
function load ( file , options ) { if ( options . cache && rr . cache [ 'rvc!' + file ] ) { return Promise . resolve ( rr . cache [ 'rvc!' + file ] ) ; } return requireJSAsync ( file ) . then ( function ( Component ) { // flush requireJS's cache _ . forEach ( requireJS . s . contexts . _ . defined , function ( value , key , array ) { if ( key . substr ( 0 , 4 ) === 'rvc!' ) { delete array [ key ] ; } } ) ; return utils . wrap ( utils . selectTemplate ( options , Component ) , options ) . then ( function ( template ) { var basePath = path . relative ( options . settings . views , path . dirname ( file ) ) ; Component . defaults . template = options . template = template ; return Promise . join ( utils . buildComponentsRegistry ( options ) , utils . buildPartialsRegistry ( basePath , options ) , function ( components , partials ) { _ . assign ( Component . components , components ) ; _ . assign ( Component . partials , partials ) ; options . components = { } ; options . partials = { } ; if ( options . cache ) { rr . cache [ 'rvc!' + file ] = Component ; } return Component ; } ) ; } ) ; } ) ; }
Create a component from the given file using RVC

@param {String} file
@param {Object} options
@returns {Promise}
@public
Create a component from the given file using RVC