trueadm / t7-precompiler Goto Github PK
View Code? Open in Web Editor NEWt7 Precompiler
t7 Precompiler
doesn't seem to be in the package.json
Hey,
How this t7-precompiler is supposed to be used with webpack? I made simple t7-precompiler module that looks like this.
"use strict";
let compiler = require('t7-precompiler');
module.exports = function (source) {
try {
return compiler.compile(source, 'inferno');
} catch (e) {
throw new Error(e);
}
};
As you can see I'm trying to precompile sources for inferno, but I'm unable to get this working. Sources are compiled, but compiled output doesn't do anything.
source:
var t7 = require('t7');
t7.setPrecompile(true);
...
t7.module(function (t7) {
class Component extends Inferno.Component {
constructor(props) {
super(props);
this.state.counter = 0;
}
render() {
return t7`
<div>
<h1>Header!</h1>
<span>Counter is at: ${ this.state.counter }</span>
</div>
`;
}
}
t7.assign("Component", Component);
Inferno.render(t7`<Component />`, APP_ELEMENT);
});
Compiles into:
t7.module(function (t7) {
var Component = (function (_Inferno$Component) {
_inherits(Component, _Inferno$Component);
function Component(props) {
_classCallCheck(this, Component);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Component).call(this, props));
_this.state.counter = 0;
return _this;
}
_createClass(Component, [{
key: 'render',
value: function render() {
return t7.precompile([this.state.counter, { template: __nbWeX, templateKey: -938833914, components: null }]);
}
}]);
return Component;
})(_inferno2.default.Component);
t7.assign("Component", Component);
_inferno2.default.render(t7.precompile([{ template: __fxTFw, templateKey: -759185842, components: null }]), _dom.APP_ELEMENT);
When debugging: t7.precompile(****) doesn't return anything and If I look into source I can see this is empty function so it just returns undefined and ignores parameters. How is this supposed to be used?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.