-
Notifications
You must be signed in to change notification settings - Fork 2
Creating a Stub
When using calzone, the Dart file you are compiling/using needs to be a special stub file created special for calzone. A stub file has the following things:
- Your main method must be the following
main(List<String> args) {
var a = new Symbol(args.length.toString());
reflectClass(a).getField(a);
reflectClass(a).invoke(a, []);
currentMirrorSystem().findLibrary(a).getField(a);
}
-
A stub must import "dart:mirrors", with a @MirrorsUsed declaration defining everything you want to keep for compiling into the wrapper.
-
A stub needs a library declaration such as
library calzone.stub;
. -
Corner case: If you have any classes with blank methods (intended to be overridden) that are not abstract, you need to add a mock class to your stub that extends that class, and overrides those methods, and does something inside them that isn't the behavior of the super class's method. This is so dart2js will not strip the methods out.
When using transformers, be sure to read their documentation. They might have extra things that need to go inside your stub file.