Thanks for the extra info! I hadn't considered the performance gains (I
"experiments" will help with!).
Post by 'Devon Carew' via Dart Miscdart-services does use compiler_unsupported to compile dart -> JS. That
package (compiler_unsupported) is just the source to dart2js. We could
shell out to the dart2js script to compile as well, but using the compiler_unsupported
package lets us run dart2js as a long-running server process. When it
compiles something, all the resources it requires (like the sdk source)
have already been loaded, and the JIT has had plenty of time to work on the
dart2js source. We see a 2x to 2.5x performance improvement over just
shelling out to the command-line script.
Post by Danny TuppenyMost of the examples I found (including dart-services, used by dartpad)
seem to just call the compiler_unsupported package (they don't executing it
as a process, but they're basically calling the same interface). Seems like
this is the most sensible thing for me to do, and lock the version because
the package name suggests the API may be volatile.
Haven't had chance to try it out because of complications getting pub
packages restored (not because of Dart/Pub, just the service I'm trying to
hack Dart support into...), but hoping to get to it over the next few days.
Post by Günter ZöchbauerThis seems to just call out to dart2js command line tool.
Post by 'Harry Terkelsen' via Dart MiscThere is a programmatic API which you can use to call dart2js
dynamically. This is how pub works. You can see how pub calls dart2js
https://github.com/dart-lang/pub/blob/c1405b945c6d818c8cfe78334e8d4b11fd913103/lib/src/dart.dart
Hope that helps!
That does it at build time; I want to do it dynamically at runtime from
Post by 'Harry Terkelsen' via Dart Misca running Dart server app (eg. in Dart code, convert a string of Dart code
into a string or JavaScript).
Gunter pointed out <http://stackoverflow.com/a/36641355/25124> that
the Try Dart app already does this so I'm gonna dig into that to see how it
works when I get chance :)
Doesn't pub already do that? Also what you're probably looking for
would be a dart2js Transformer.
Is it possible to compile dart code to JS on-the-fly without invoking
Post by Danny Tuppenydart2js at the command line? Eg., (written in Dart) read in some dart code
from a file and transform it to JS (must be in memory, filesystem is not
writable)?
I thought maybe dart2js would effectively just be a cli over a pub
package I can call manually, but I can't find any information on doing this
at runtime :(
(note: I know this idea sucks and it'll be very slow; it's just for
something I'm prototyping and will ultimately use dart2js normally, I just
can't address that yet)
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it,
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
Devon Carew
Software Engineer
Google, Inc.
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an