[Solved] how is dart compiled into javascript? [closed]


There is quite a bit of code included that emulates features Dart provides, but that can’t be translated directly to ES5, (like classes, mixins, …).

There is also quite some code included that polyfills missing browser features to make the same Dart code work in all browsers like for example jQuery does.

This code could theoretically be put in a library file (like jQuery) but that file would be huge.

To reduce the size Dart uses tree-shaking (actually it’s tree-growing to get rid of all code that is not actually referenced from the main() file (direct or transitive). Also all methods of classes that are not used or functions of libraries that are not used of classes and libraries where other parts are used, can be removed.

This means that for every application the parts of the Dart base library that are actually included in the JS output can and probably will differ.
Therefore there can’t be a default dart.js file to add to index.html in addition to the JS generated from your hand-written application code.

solved how is dart compiled into javascript? [closed]