bundle.name should be calculated from bundle.path: path.basename(bundle.path)
bundle.techs should be calculated from bundle.files: ['path/to/file.bemhtml.js'] -> ['bemhtml.js']
bundle.bemdecl should be calculated from bundle.bemjson: bemjson-to-decl
bundle.path, bundle.files and bundle.bemjson should only provide fields
Constructor should looks like:
class Bundle {
/**
* Constructor ;-)
* @param {Object} opts - Params
* @param {?String[]} opts.levels - Additional levels used for bundle
* @param {?String} opts.path - Path to bundle (can be empty, but should be a string)
* @param {?BEMJSON} opts.bemjson - BEMJSON tree that also will be used to calculate BEMDecl. Must exist if no bemdecl passed
* @param {?BEMDecl} opts.bemdecl - BEMDecl. Must exist if no bemjson passed
* @param {?Object} opts.data - Additional data related to bundle
*/
constructor(opts) {
assert(opts.bemjson || opts.bemdecl, 'Bundle requires bemdecl or bemjson to be consistent');
assert(!opts.levels || Array.isArray(opts.levels), '`levels` should be an array of paths');
// etc.
}
}
Properties:
bundle.name
should be calculated frombundle.path
:path.basename(bundle.path)
bundle.techs
should be calculated frombundle.files
:['path/to/file.bemhtml.js'] -> ['bemhtml.js']
bundle.bemdecl
should be calculated frombundle.bemjson
: bemjson-to-declbundle.path
,bundle.files
andbundle.bemjson
should only provide fieldsConstructor should looks like: