Now we can use modulesDeps option to require dependencies from YModules:
{
modulesDeps: {
vow: 'Vow'
}
}
After compilation dependencies are provided in base templates as "global" variables.
modules.define('BEMHTML', ['vow'], function (provide, Vow) {
// Base templates of BEMTREE expect `vow` module from `Vow` variable.
});
Shortcomings
It is impossible get the module from global scope.
It is impossible get the module using CommonJS.
Interface expects variables from global scope.
Problem Solution
{
requires: {
'lib-name': {
globals: 'dependName', // var name from global scope
ym: 'depend-name', // module name from YModules
commonJS: 'path/to/module', // relative path to CommonJS module from target
}
}
}
For templates dependencies will be available in this.requre('lib-name'):
block('block').content(function () {
var lib = this.require('lib-name');
return lib.method();
});
Now we can use
modulesDeps
option to require dependencies from YModules:After compilation dependencies are provided in base templates as "global" variables.
Shortcomings
Problem Solution
For templates dependencies will be available in
this.requre('lib-name')
:In bundle file will be as follows:
If you want to get the dependency from the global scope for all modular systems:
In bundle file will be as follows: