Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

В версии 0.4.0 стал неверно собираться клиентский bh с использованием bh-client-module #24

Merged
merged 5 commits into from
Dec 22, 2014
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 18 additions & 9 deletions lib/bh-client-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ module.exports = {
}

file.writeLine('(function () {');
this._concatFile(file, bhEngine, inputSources, libPrepares, jsAttrName, jsAttrScheme);
this._defineModule('bh', file, depNames, libNames);
this._concatFile(file, bhEngine, inputSources, null, jsAttrName, jsAttrScheme);
this._defineModule('bh', file, depNames, libNames, libPrepares);

if (mimic) {
this._defineModule(mimic, file, depNames, libNames);
this._defineModule(mimic, file, ['bh'], ['bh'], null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему mimic зависит от bh, а не от реальных зависимостей?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну, насколько я понял, mimic - это что-то, имитирующее bh (к слову зачем тогда делается modules.define('bh')?). И проще сразу объявить его зависимость от bh, разве нет?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

к слову зачем тогда делается modules.define('bh')

При имитации должна оставаться возможность использовать модуль как bh в том числе.

И проще сразу объявить его зависимость от bh, разве нет?

Если bh модуль в коде после modules.define будет использовать зависимости, то код в mimic сломается.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если bh модуль в коде после modules.define будет использовать зависимости, то код в mimic сломается.

Поясни? Вот у меня есть сейчас такое:

modules.define('bh', ['i18n'], function (provide, i18n) {
  bh.lib.i18n = i18n;
  provide(bh);
});

modules.define('mimic_bh', ['bh'], function (provide, bh) {
  provide(bh);
});

modules.require('mimic_bh', function (mimic) {
  console.log(mimic.lib.i18n); // ok
});

}

file.writeLine('})()');
Expand Down Expand Up @@ -90,11 +90,7 @@ module.exports = {
file.writeLine('}');
}

if (libPrepares) {
libPrepares.forEach(function (libPrepare) {
file.writeLine(libPrepare);
});
}
this._addLibPrepares(file, libPrepares);

inputSources.forEach(function (inputSource) {
file.writeLine('// begin: ' + inputSource.relPath);
Expand All @@ -105,12 +101,25 @@ module.exports = {
return file;
},

_defineModule: function (name, file, depNames, libNames) {
_defineModule: function (name, file, depNames, libNames, libPrepares) {
file.writeLine('modules.define(\'' + name + '\'' +
(depNames ? ', ' + JSON.stringify(depNames) : '') +
', function(provide' + (libNames && libNames.length ? ', ' + libNames.join(', ') : '') + ') {'
);

if (libPrepares) {
this._addLibPrepares(file, libPrepares);
}

file.writeLine('provide(bh);');
file.writeLine('});');
},

_addLibPrepares: function (file, libPrepares) {
if (libPrepares) {
libPrepares.forEach(function (libPrepare) {
file.writeLine(libPrepare);
});
}
}
};