Пытаюсь подружить enb-bem-i18n с project-stub на express + bem-core и не получается.
Вот мой make.js:
var techs = {
// essential
fileProvider: require('enb/techs/file-provider'),
fileMerge: require('enb/techs/file-merge'),
// optimization
borschik: require('enb-borschik/techs/borschik'),
// css
postcss: require('enb-postcss/techs/enb-postcss'),
postcssPlugins: [
require('postcss-import')(),
require('postcss-each'),
require('postcss-for'),
require('postcss-simple-vars')(),
require('postcss-calc')(),
require('postcss-nested'),
require('rebem-css'),
require('postcss-url')({ url: 'inline' }),
require('autoprefixer')(),
require('postcss-reporter')()
],
// js
browserJs: require('enb-js/techs/browser-js'),
// bemtree
bemtree: require('enb-bemxjst/techs/bemtree'),
// bemhtml
bemhtml: require('enb-bemxjst/techs/bemhtml'),
// i18n
i18n: require('enb-bem-i18n/techs/i18n'),
keysets: require('enb-bem-i18n/techs/keysets')
},
enbBemTechs = require('enb-bem-techs'),
levels = require('./levels');
module.exports = function(config) {
var isProd = process.env.YENV === 'production';
config.setLanguages(['en', 'ru']);
config.nodes('desktop.bundles/*', function(nodeConfig) {
nodeConfig.addTechs([
// essential
[enbBemTechs.levels, { levels: levels }],
[techs.fileProvider, { target: '?.bemjson.js' }],
[enbBemTechs.bemjsonToBemdecl],
[enbBemTechs.deps],
[enbBemTechs.files],
// i18n
[techs.keysets, {
lang: '{lang}'
}],
[techs.i18n, {
lang: '{lang}',
exports: { globals: 'force' }
}],
// css
[techs.postcss, {
target: '?.css',
oneOfSourceSuffixes: ['post.css', 'css'],
plugins: techs.postcssPlugins
}],
// bemtree
[techs.bemtree, { sourceSuffixes: ['bemtree', 'bemtree.js'] }],
// bemhtml
[techs.bemhtml, {
sourceSuffixes: ['bemhtml', 'bemhtml.js'],
forceBaseTemplates: true,
engineOptions: { elemJsInstances: true },
requires: {
i18n: { globals: 'BEM.I18N' }
}
}],
// i18n merge
[techs.fileMerge, {
target: '?.{lang}.bemhtml.js',
lang: '{lang}',
sources: ['?.bemhtml.js', '?.lang.{lang}.js']
}],
// client bemhtml
[enbBemTechs.depsByTechToBemdecl, {
target: '?.bemhtml.bemdecl.js',
sourceTech: 'js',
destTech: 'bemhtml'
}],
[enbBemTechs.deps, {
target: '?.bemhtml.deps.js',
bemdeclFile: '?.bemhtml.bemdecl.js'
}],
[enbBemTechs.files, {
depsFile: '?.bemhtml.deps.js',
filesTarget: '?.bemhtml.files',
dirsTarget: '?.bemhtml.dirs'
}],
[techs.bemhtml, {
target: '?.browser.bemhtml.js',
filesTarget: '?.bemhtml.files',
sourceSuffixes: ['bemhtml', 'bemhtml.js'],
engineOptions: { elemJsInstances: true }
}],
// js
[techs.browserJs, { includeYM: true }],
[techs.fileMerge, {
target: '?.js',
sources: ['?.browser.js', '?.browser.bemhtml.js']
}],
// borschik
[techs.borschik, { source: '?.js', target: '?.min.js', minify: isProd }],
[techs.borschik, { source: '?.css', target: '?.min.css', minify: isProd }]
]);
nodeConfig.addTargets([
'?.bemtree.js',
'?.min.css',
'?.min.js',
'?.lang.{lang}.js',
'?.{lang}.bemhtml.js'
]);
});
};
Все собирается успешно, но в момент старта приложения получаю ошибку:
/Users/anakatata/Desktop/test/desktop.bundles/index/index.ru.bemhtml.js:3401
i18n: global['BEM']['I18N'],
^
TypeError: Cannot read property 'I18N' of undefined
В чем может быть проблема?
Т.к. проблема может быть много где, я просто обновил веточку
i18n
вbem-express
: https://github.com/bem/bem-express/commit/f54cfd1468074b0bffc23383744855bd2904137eТам приведен пример сборки i18n для клиентского JS и BEMTREE. Для BEMHTML должно быть легко добавить по аналогии.