Open munificent opened 11 years ago
This also presupposes a way to invoke functions/create classes in the isolate. [mirrorSystemOf] may accomplish this.
Right, I'm assuming mirrorSystemOf() will cover this and work as advertised. If it doesn't, we'll file more bugs. :)
Marked this as being blocked by #12614.
Added Area-Library label.
Currently, if you spawn an isolate in the standalone VM given a URL to a Dart library with no main(), you get:
in ShutdownIsolate: Unable to resolve function 'main' in library 'file:///.../plugin.dart'.
And the app terminates.
For plug-ins, the typical pattern is to load code dynamically and then use reflection/mirrors to determine what to invoke instead of relying on a fixed entrypoint. To get around this in the dev server, we currently procedurally create a temporary Dart script that has a no-op main() method and imports the real library. Then we save that to a temp directory and use that URL to spawn the isolate. That's obviously pretty gross.
Instead, I'm thinking something like:
SendPort spawnIsolate(String url, {bool invokeMain: true});
If invokeMain is false, it just loads the isolate without calling main() (whether or not it's there).
Note that I only need this to work in the standalone VM, so my need isn't gated on dart2js or Dartium support for it.