TL;DR: Generally speaking, though, we don't recommend using dartdevc to export functionality written in Dart to use it from JavaScript. The best we have at this time is to use JS-interop to export your APIs instead.
Our focus with dartdevc is to create a good experience for fast iteration during development. Its output is unstable and not meant to be used as an input to a larger JavaScript application. This is for many reasons. In part, because we are not optimizing the output for deployment. In some cases the code produced by dartdevc can be many times slower than the code produced by dart2js (our production compiler). Another reason is that we may break you accidentally, since this is not a supported pattern. For example, we currently have logic to emit multiple formats (es6, amd, etc), but we have plans to consolidate into a single module format. Given some constraints we have with support for hot-reload in flutter, this format is unlikely going to be node's.
Our recommended approach for interoperability with JavaScript is to use the `package:js` APIs. Those APIs were designed with the idea of importing JavaScript, rather than exporting Dart, but it is still possible to use it to export code. To do so, you will need to define a `main` method that declares how you want to export code from your library. For instance, you can declare some global names where your library will be expose members like this:
@JS()
library foo;
import 'package:my_math/my_math.dart' as mymath;
import 'package:js/js.dart';
@JS('mathMin') // will be available on self.mathMin in JavaScript.
external set mathMinFunction(Function v);
main() {
mathMinFunction = allowInterop(mymath.min);
}
With this approach, it will be possible to compile and optimize the code with our production compiler (dart2js). You'll also be in control of how Dart code is exposed, so you will be guarded from breaking changes in how our compilers represent code internally.
Hope this helps!
Cheers,
Siggi