For now gulp-bem has pretty obvious way to build css files, but in JavaScript land there is no cascade declarations in the core (but there is prototypes).
I propose a draft for including javascript files and building them together - browserify all JavaScript files with some additional sugar, that will handle require of bem identifiers. This could be done with exporting builded code in {bem} into require cache of browserify. It will fix issue with unclear require path's, but not with levels of definition (thou order of building will be handled by tree.deps, which is nice).
Example:
// base/omnibutton.js
// block/omnibutton.js
var Class = require('jsface').Class;
var Omnibutton = require('omnibutton');
var MyOmnibutton = Class(Omnibutton, { /*...*/ });
module.exports = MyOmnibutton;
Notice, that require('jsface') should automaticly work without any additional preparations (besides npm i jsface --save).
If we won't add extra features and use browserify as it is, require in block/omnibutton.js will export {} (by rules, that NodeJS using for resolving recursive dependencirs) and will not have base/omnibutton.js instance as we want.
May be it could be solved by forcing new cache entity after building concrete JavaScript file in block.
For now
gulp-bem
has pretty obvious way to build css files, but in JavaScript land there is no cascade declarations in the core (but there is prototypes).I propose a draft for including javascript files and building them together - browserify all JavaScript files with some additional sugar, that will handle
require
of bem identifiers. This could be done with exporting builded code in{bem}
into require cache of browserify. It will fix issue with unclearrequire
path's, but not with levels of definition (thou order of building will be handled bytree.deps
, which is nice).Example:
If we won't add extra features and use browserify as it is,
require
inblock/omnibutton.js
will export{}
(by rules, that NodeJS using for resolving recursive dependencirs) and will not havebase/omnibutton.js
instance as we want.May be it could be solved by forcing new cache entity after building concrete JavaScript file in block.