Danny Tuppeny
Danny Tuppeny

Reputation: 42333

How can I run dart2js dynamically in a Dart server web app?

I want to compile dart code to JS on-the-fly without invoking dart2js 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)

Upvotes: 1

Views: 133

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657048

https://try-dart-lang.appspot.com/ does this. The source is available. Its basically dart2js run through dart2js. Not sure if this is the right repository https://github.com/peter-ahe-google/orphan-try
I guess Peter would be ok with pinging him about more information.

The project was replaced by pub.dartlang.org which uses a service running on the server https://github.com/dart-lang/dart-services where source is posted to for dart2js translation.

Upvotes: 1

Related Questions