enb / enb-bh

BH support for ENB
Other
15 stars 12 forks source link

Incorrect use of requires.*.globals value in bh-bundle tech #110

Closed arikon closed 9 years ago

arikon commented 9 years ago

Tech options:

{
  requires: {
    i18n: {
      globals: 'BEM.I18N'
    }
  }
}

Generated code:

var defineAsGlobal = true;
if (typeof modules === "object") {
    modules.define("BH", [], function(provide) {

        bh.lib.i18n = global["BEM.I18N"];
init();
        provide(bh);
    });
    modules.define("BEMHTML", ["BH"], function(provide) {
        provide(bh);
    });
    defineAsGlobal = false;
} else if (typeof exports === "object") {
    bh.lib.i18n = global["BEM.I18N"];
    init();
    bh["BEMHTML"] = bh;
    module.exports = bh;
    defineAsGlobal = false;
}
if (defineAsGlobal) {
    bh.lib.i18n = global["BEM.I18N"];
    init();
    global.BH = bh;
    global["BEMHTML"] = bh;
}

Should be:

var defineAsGlobal = true;
if (typeof modules === "object") {
    modules.define("BH", [], function(provide) {

        bh.lib.i18n = global["BEM"]["I18N"];
init();
        provide(bh);
    });
    modules.define("BEMHTML", ["BH"], function(provide) {
        provide(bh);
    });
    defineAsGlobal = false;
} else if (typeof exports === "object") {
    bh.lib.i18n = global["BEM"]["I18N"];
    init();
    bh["BEMHTML"] = bh;
    module.exports = bh;
    defineAsGlobal = false;
}
if (defineAsGlobal) {
    bh.lib.i18n = global["BEM"]["I18N"];
    init();
    global.BH = bh;
    global["BEMHTML"] = bh;
}