bem / bem-xjst

bem-xjst (eXtensible JavaScript Templates): declarative template engine for the browser and server
https://bem.github.io/bem-xjst
Other
116 stars 48 forks source link

[4.x] Compiled bundle is broken after minification #101

Closed tadatuta closed 9 years ago

tadatuta commented 9 years ago

How to reproduce:

var fs = require('fs'),
    bemxjst = require('bem-xjst'), // 4.2.3
    uglify = require('uglify-js'), // 2.4.24
    bemjson = { block: 'b1' },
    tmpl = function() {
        block('b1').tag()('ololo');
    };

fs.writeFileSync('tmpl.js', bemxjst.generate(tmpl));

console.log(require('./tmpl').apply(bemjson)); // <ololo class="b1"></ololo>

fs.writeFileSync('tmpl.min.js', uglify.minify('tmpl.js').code);

require('./tmpl.min').apply(bemjson);

// <ololo class="b1"></ololo>
// undefined:3
// s("b1").tag()("ololo")
// ^

// ReferenceError: s is not defined
//     at Object.eval (eval at <anonymous> (/Users/tadatuta/Sites/bem-xjst-uglify-bug/tmpl.min.js:1:6089), <anonymous>:3:1)
//     at d.build (/Users/tadatuta/Sites/bem-xjst-uglify-bug/tmpl.min.js:1:18392)
//     at n.compile (/Users/tadatuta/Sites/bem-xjst-uglify-bug/tmpl.min.js:1:5559)
//     at Object.<anonymous> (/Users/tadatuta/Sites/bem-xjst-uglify-bug/tmpl.min.js:1:22037)
//     at Module._compile (module.js:434:26)
//     at Object.Module._extensions..js (module.js:452:10)
//     at Module.load (module.js:355:32)
//     at Function.Module._load (module.js:310:12)
//     at Module.require (module.js:365:17)
//     at require (module.js:384:17)
sbmaxx commented 9 years ago

А чем закончилось-то?

sbmaxx commented 9 years ago

Если прибить

  var templates = this.recompileInput(code);

то всё будет ок :)

veged commented 9 years ago

сделал PR: #117

veged commented 9 years ago

landed in v4.2.6