Dart officially provides JavaScript language support through the Dart web platform but for projects not using the web platform, there's unofficial support through a project called JSParser.
Due to my unfamiliarity with the language combined with sparse documentation, I'm not sure how to use this JSParser library. The example looks like this:
import 'package:parsejs/parsejs.dart';
void main() {
new File('test.js').readAsString().then((String code) {
Program ast = parsejs(code, filename: 'test.js')
// Use the AST for something
})
}
After installing the ParseJS library, the above code compiles just fine. But how do I interact with "the AST"? The IDE's code hinting doesn't seem to help either.
Looking back on the history of this project, it seems to have exchanged hands multiple times however all seem to be missing an example of what is done with the ast object afterward.
- 2014 - 2017: Managed by asgerf/parsejs.dart
- 2019 - 2019: Managed by anuragvohraec/parsejs.dart
- 2020 - 2020: Forked by ELEOS-MAP/parsejs.dart
- 2019 - 2019: A fork from a fork by anuragvohraec/dartJSEngine
Steps I've done:
- Installed
flutter - Installed and configured IntelliJ to use the flutter runtime I've installed
- Installed the beta Desktop support for flutter
- Installed the library and try to run the example
Are these libraries too old or am I just using them wrong? How would I know? I'm on Dart 2.11