MithrilJS / mithril.js

A JavaScript Framework for Building Brilliant Applications
https://mithril.js.org
MIT License
14.02k stars 925 forks source link

Sweet.js Template compiler does not work with ES6 files #744

Closed mneumann closed 8 years ago

mneumann commented 9 years ago

I am trying to precompile my Mithril code using the template-compiler.sjs, but unluckily I have written my code in ES6 (using Babel as transpiler). If I translate the code to ES5 and then feed it to sweet.js, it of course can't find the 'm' name anymore, as it gets replaced but the full qualified imported name, which is something like _vendorMithril2$752['default']. Any hints? I think I am going to rewrite the code in ES5 (I am not using much of ES6), or use some sweet.js macros that enable ES6-compatibility.

dead-claudia commented 9 years ago

The template compiler probably needs some heavy refactoring/rewriting, anyways. That'll be especially true with the changes being slated for the next significant release, since some of them are breaking. Another thing is that the revision before last was published with version 0.1.23, which there have been some API additions since (the last was trivial).

And as for that attempted workflow, good luck. Babel mangles names for its imports. It always does. And SweetJS does not have complete ES6 support, or else that could work. A better idea would be to create a Babel plugin and use it, although that would also be non-trivial.

lhorie commented 8 years ago

I'm now recommending that peopel use mithril-objectify instead