Can dart create readable javascript libraries?

goal

I would like to write a javascript library (framework), but you need OOP and mixins.

Sent to typescript, but it does not support mixins (the manual says that it is, but the compiler / specs have nothing to do with mixin).

Typescript

The following code is provided in typescript:

class Greeter { greeting: string; constructor(message: string) { this.greeting = message; } greet() { return "Hello, " + this.greeting; } } 

Compiles:

 var Greeter = (function () { function Greeter(message) { this.greeting = message; } Greeter.prototype.greet = function () { return "Hello, " + this.greeting; }; return Greeter; })(); 

Then, customers can simply call:

 var greeter = new Greeter("world"); 

Dart

Can a dart do something like this? Can anyone show how?

The main goal is that the javascript generated is readable, preferably with all the other darts in another script.

I saw this question and this answer , but none of them gives a readable JS file, as in the typescript example above.

+6
source share
2 answers

Since @SetLadd mentioned https://github.com/dart-lang/dev_compiler , it was built for this purpose (among others). Some of them said that after some time they could produce useful products.

dev_compiler has a dartdevc command line dartdevc .

+6
source

Dart Dev Compiler (DDC) is an experimental development tool and transpiler.
This is at a very early stage today. The initial fixation was carried out on November 17, 2014.

DDC tries to display as accurately as possible on the idiomatic EcmaScript 6 (ES6).

Maybe someday there will be a day when we can say with confidence: "This is a mature development tool and transpiler," but the DDC is still at a very early stage.

+2
source

All Articles