bem-sdk-archive / bem-bundle

Primal BEMBundle object. DEPRECATED →
https://github.com/bem/bem-sdk/tree/master/packages/bundle
Other
5 stars 0 forks source link

Make a PoC of this object #1

Closed qfox closed 8 years ago

qfox commented 8 years ago
const BemBundle = require('bem-bundle');
const bundle = new BemBundle(...);

bundle.path // path/to/bundle-dir
bundle.name // bundle-dir
bundle.files // [path/to/bundle-dir/bundle-dir.js, path/to/bundle-dir/bundle-dir.css]
bundle.techs // ['css', 'js', …]

bundle.bemdecl // [tenorok, tenorok] — Normalized declaration 
bundle.bemjson // ?Object
bundle.data // Any Object

Properties:

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.
  }
}
skad0 commented 8 years ago

Closed in #2