I consider using Dart for my next web project and it has made a very neat impression on me so far. Obviously, Dart code can be converted into JavaScript. However, I wonder if this results in code where functions can be used from other JavaScript files.
Asked
Active
Viewed 83 times
2 Answers
4
It is supported to call Dart functions from JavaScript but only functions that are made available to JavaScript explicitely.
See
When you build Dart to JavaScript minification and tree-shaking make it hard or mostly impossible to call methods because functions might not even be included in the output if the analysis recognized that the function isn't called anywhere and if it actually is included it will have a shortened and cryptic name.
I have seen it mentioned that here are attempts for better support of this use case but there isn't anything available yet.

Community
- 1
- 1

Günter Zöchbauer
- 623,577
- 216
- 2,003
- 1,567
2
If your generated JavaScript is accessible then for sure it will regardless of it is generated using dart or anything else

Umesh Aawte
- 4,590
- 7
- 41
- 51
-
Only theoretically, see my answer. – Günter Zöchbauer Nov 26 '14 at 10:38
-
Having cryptic names of function dose not mean they are not accessible, yes they are hard to use. Here concen is only whether they are accessible or not I guess – Umesh Aawte Nov 26 '14 at 12:03
-
It is also not guaranteed that they get the same name with consecutive builds, so in practice I would say they can't be called, in theory they might (if they were not pruned by tree-shaking). – Günter Zöchbauer Nov 26 '14 at 12:05
-
Yes, this is possible problem case – Umesh Aawte Nov 26 '14 at 12:07