Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does dart support compile to binary code?

Tags:

dart

I want to use Dart as business project which will deploy on a customer's server.

At present I just know upload the whole source code to the server, there is no privacy...

How to do it?

like image 371
Matrix Avatar asked Mar 23 '16 03:03

Matrix


1 Answers

I assume you are talking about Dart server code. Client code is transpiled to JavaScript, tree-shaken, and minified. This is quite some obfuscation.

For server side code you can use snapshots.

https://www.dartlang.org/articles/snapshots/. Snapshots still contain the readable source but everything packed into one file.
See also What is the difference between Dart's snapshots and Java bytecode?

There is ongoing work to create precompiled snapshots.
Normally Dart code is compiled at runtime before a function is executed the first time. For precompiled snapshots Dart source is compiled ahead of time.

Running

dart --gen-precompiled-snapshot

prints

Precompiled snapshots must be generated with dart_bootstrap. Usage: dart [] []

I haven't found a dart_bootstrap command in the SDK.

I guess we will have to wait a bit more until this feature will be made available.

like image 175
Günter Zöchbauer Avatar answered Oct 10 '22 11:10

Günter Zöchbauer