TelluIoT / ThingML

The ThingML modelling language
https://github.com/TelluIoT/ThingML
Apache License 2.0
101 stars 32 forks source link

Javascript package compiler #250

Closed fungiboletus closed 5 years ago

fungiboletus commented 5 years ago

My problem

I want to generate a javascript package using ThingML, to use in a web application.

The current situation

The javascript.browser compiler works but the generated code cannot be integrated in large applications : everything is exposed as global variables and it uses quite a few ES6 features so it doesn't support obsolete browsers such as Internet Explorer. It could be possible to use Babel to make it more compatible. The dependency management, a list in a index.html file, is a bit old school.

The javascript.node compiler is cleaner and looks like a better starting point but it uses NodeJS only APIs such as process.stderr.write(''+msg+'\n') instead of console.log(msg) which makes it incompatible with the web browser, even when using browserify stuff. It's also not packaged correctly so far.

The javascript.react compiler is something else.

My suggestion : a package compiler

I think it could be possible to generate a package, that works both for node and the browser. I may or may not implement it.

brice-morin commented 5 years ago

Well, the Node.JS and other JS compilers share most of their code. Ideally, if you could make a tiny thingml project, generate it for the browser and modify it by hand so that I know precisely what need to be done, I may be able to do it or at least help you.

As for the javascript.react compiler, I do not have much control on it...

fungiboletus commented 5 years ago

It's a lot simpler to start from the NodeJS compiler I think. So far it looks like I only have to remove the process.stout.write override to go back to the console.log and put a if before the proccess.on('SIGINT',

fungiboletus commented 5 years ago

However I don't understand how to run the currently developped ThingML from eclipse, and mvn install takes forever everytime I change a line.

brice-morin commented 5 years ago

To quickly test (outside Eclipse),

cd ThingML
mvn clean install #if you just have touched the compilers, just mvn clean install compilers
cd /compilers/official-network-plugins/target
java -jar official-network-plugins-2.0.0-SNAPSHOT-jar-with-dependencies.jar

and follow the help :-)

fungiboletus commented 5 years ago

Yes, that's what I was doing but quickly isn't exactly how I would call the mvn step.

But it's fine, I figured out how to run the compiler in Eclipse Debugger with having to run maven before.