Dart: #byojsl - Bring Your Own JavaScript Library
There’s a lot of JavaScript libraries. It’d be nice if you could use them seamlessly from Dart, while maintaining Dart’s developer-friendly ergonomics.
At the Dart Summit in April, Dan and I talked about our plans for the future of JavaScript interop: the hashtag-able #byojsl
– Bring Your Own JavaScript Library.
With the latest preview release of Dart 1.13 – 1.13.0-dev.7, you can now play with this feature.
Check out the example in the source code.
Nice, huh?
Creating the Dart interop libraries using @Js()
annotations allows dart2js
to create very efficient Javascript connections to the source library. The interop libraries also give the users of the interop library the developer experience you expect from Dart code: completions, warnings, errors, etc.
If you want to try it out
- Download the latest dev release of the Dart SDK - dartlang.org/downloads/archive
- The package is published at pub.dartlang.org/packages/js.
- Make sure you specify the right constraint in
pubspec.yaml
–js: ^0.6.0-beta
We’ll have proper documentation on the site when 1.13 is ready for release. In the mean time, we’d love feedback as we prepare for the final release.