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

Document API and make some usage examples #3

Open qfox opened 8 years ago

qfox commented 8 years ago

We should document this primal object to show why it was separated out of the rest.

At least, there should be examples of usage:

const bundle = new BemBundle({path: ...});
qfox commented 8 years ago
const Bundle = require('@bem/bundle');

const bundle = new Bundle({path: './pages/index.bemjson.js'});
Bundle.isBundle(bundle); // true
bundle.bemjson; // {block: 'a', mods: {m: v}}
bundle.decl; // [{entity: {block: 'a'}, tech: null}, {entity: {block: 'a', mod: {name: m, val: v}, tech: null}]
bundle.name; // "index"
bundle.path; // "./pages/index.bemjson.js"
const intoStream = require('into-stream');
const Bundle = require('@bem/bundle');
const Builder = require('gulp-bem-bundle-builder');

const builder = new Builder({ /* ... */ });
intoStream([
  // Generating virtual bundles
  new Bundle({path: './pages/index.bemjson.js'}),
  new Bundle({path: './pages/page1.bemjson.js'}),
  new Bundle({path: './pages/page2.bemjson.js'})
])
.pipe(builder({ /* ... */ ));