Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile dart in the browser

Tags:

dart

dart2js

In my application I generate big dart classes. Right now I compile them on the server, which takes CPU time. It would be much better to compile the Dart code within the browser. The code is then loaded via spawnURI.

Is it possible to invoke the dart2js compiler from within Dart code in a supported way as it is done in try.dartlang.org or do I need to copy the compiler into my project?

like image 548
Karsten Becker Avatar asked Sep 27 '13 16:09

Karsten Becker


People also ask

Can I compile Dart?

Use the dart compile command to compile a Dart program to a target platform. The output—which you specify using a subcommand—can either include a Dart runtime or be a module (also known as a snapshot). For more information about this and other dart commands, see the Dart command-line tool page.

Can you use Dart for web?

Dart supports the web as one of its core platforms. Dart-to-JavaScript compilers are available both for development (with a quick edit-refresh cycle) and for production (with a focus on code size and speed).

How do I compile and run a Dart file?

To run a Dart console application: Install the Code Runner Extension. Open the Dart code file in Text Editor, then use shortcut Ctrl+Alt+N , or right click the Text Editor and then click Run Code in context menu, the Dart console application will run and the output will be shown in the Output Window.


1 Answers

Compiling Dart to JavaScript will be faster on the server, because you can run dart2js via Dart VM. try.dartlang.org is running in a special version of dart2js, which has not been merged into the main source code.

like image 156
Seth Ladd Avatar answered Sep 29 '22 05:09

Seth Ladd