dart_to_js_transpiler 1.0.0

Dart to JavaScript Transpiler [Beta] #

Usage #

  • Add package to your dependencies
  • Using decorators from this library mark classes and methods you're willing to expose as JS interface
    • Methods of the class that is not marked as exposed will be ignored
    • Only public methods can be exposed to JS
  • Using Entrypoint decorator mark the main function
  • Run pub run build_runner build
  • Add grinder and cli_pkg to your dependencies
  • Following the example create a tool folder in the root of the project, create grind.dart file inside.
  • Create package folder in the root of the project, create package.json file following the template example
    • You can use djt-codegen lib to create templated JS files with .d.ts exports as wel
  • Run pub run grinder copy-schema to create a JS build
    • cd ./build/npm and run yarn && yarn codegen in order yo create interfaces
  • Your Dart library is now available as the NPM package.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dart_to_js_transpiler: ^1.0.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:dart_to_js_transpiler/builder.dart';
import 'package:dart_to_js_transpiler/grinder/tool.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
95
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
50
Overall:
Weighted score of the above. [more]
39
Learn more about scoring.

We analyzed this package on Jul 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13

Analysis suggestions

Package not compatible with SDK flutter

Because it is not compatible with any of the supported runtimes: flutter-native, flutter-web

Package not compatible with runtime flutter-native on android

Because of the import of dart:mirrors via the import chain package:dart_to_js_transpiler/builder.dartpackage:dart_to_js_transpiler/grinder/tool.dartpackage:grinder/grinder.dartpackage:grinder/src/grinder.dartpackage:grinder/src/singleton.dartpackage:grinder/src/utils.dartdart:mirrors

Package not compatible with runtime flutter-native on ios

Because of the import of dart:mirrors via the import chain package:dart_to_js_transpiler/builder.dartpackage:dart_to_js_transpiler/grinder/tool.dartpackage:grinder/grinder.dartpackage:grinder/src/grinder.dartpackage:grinder/src/singleton.dartpackage:grinder/src/utils.dartdart:mirrors

Package not compatible with runtime flutter-native on linux

Because of the import of dart:mirrors via the import chain package:dart_to_js_transpiler/builder.dartpackage:dart_to_js_transpiler/grinder/tool.dartpackage:grinder/grinder.dartpackage:grinder/src/grinder.dartpackage:grinder/src/singleton.dartpackage:grinder/src/utils.dartdart:mirrors

Package not compatible with runtime flutter-native on macos

Because of the import of dart:mirrors via the import chain package:dart_to_js_transpiler/builder.dartpackage:dart_to_js_transpiler/grinder/tool.dartpackage:grinder/grinder.dartpackage:grinder/src/grinder.dartpackage:grinder/src/singleton.dartpackage:grinder/src/utils.dartdart:mirrors

Package not compatible with runtime flutter-native on windows

Because of the import of dart:mirrors via the import chain package:dart_to_js_transpiler/builder.dartpackage:dart_to_js_transpiler/grinder/tool.dartpackage:grinder/grinder.dartpackage:grinder/src/grinder.dartpackage:grinder/src/singleton.dartpackage:grinder/src/utils.dartdart:mirrors

Package not compatible with runtime flutter-web on web

Because of the import of dart:mirrors via the import chain package:dart_to_js_transpiler/builder.dartpackage:dart_to_js_transpiler/grinder/tool.dartpackage:grinder/grinder.dartpackage:grinder/src/grinder.dartpackage:grinder/src/singleton.dartpackage:grinder/src/utils.dartdart:mirrors

Package not compatible with runtime native-aot

Because of the import of dart:mirrors via the import chain package:dart_to_js_transpiler/builder.dartpackage:dart_to_js_transpiler/grinder/tool.dartpackage:grinder/grinder.dartpackage:grinder/src/grinder.dartpackage:grinder/src/singleton.dartpackage:grinder/src/utils.dartdart:mirrors

Package not compatible with runtime web

Because of the import of dart:mirrors via the import chain package:dart_to_js_transpiler/builder.dartpackage:dart_to_js_transpiler/grinder/tool.dartpackage:grinder/grinder.dartpackage:grinder/src/grinder.dartpackage:grinder/src/singleton.dartpackage:grinder/src/utils.dartdart:mirrors

Health issues and suggestions

Document public APIs. (-1 points)

14 out of 14 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/src/exports_generator.dart. (-2.96 points)

Analysis of lib/src/exports_generator.dart reported 6 hints, including:

line 24 col 28: Unnecessary new keyword.

line 34 col 26: Unnecessary new keyword.

line 35 col 26: Unnecessary new keyword.

line 41 col 11: Unnecessary new keyword.

line 44 col 31: Unnecessary new keyword.

Fix lib/src/schema_generator.dart. (-1 points)

Analysis of lib/src/schema_generator.dart reported 2 hints:

line 20 col 28: Unnecessary new keyword.

line 34 col 11: Unnecessary new keyword.

Format lib/builder.dart.

Run dartfmt to format lib/builder.dart.

Format lib/src/decorators.dart.

Run dartfmt to format lib/src/decorators.dart.

Format lib/src/expose_generator.dart.

Run dartfmt to format lib/src/expose_generator.dart.

Maintenance issues and suggestions

Provide a file named CHANGELOG.md. (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and dart_to_js_transpiler.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
analyzer ^0.39.8 0.39.11
build >=0.12.0 <2.0.0 1.3.0
code_builder ^3.2.1 3.3.0
grinder ^0.8.4 0.8.5
node_interop ^1.0.3 1.1.1
source_gen ^0.9.5 0.9.5
Transitive dependencies
_fe_analyzer_shared 5.0.0
args 1.6.0
async 2.4.1
built_collection 4.3.2
built_value 7.1.0
charcode 1.1.3
cli_util 0.2.0
collection 1.14.13
convert 2.1.1
crypto 2.1.5
csslib 0.16.1
dart_style 1.3.6
fixnum 0.10.11
glob 1.2.0
html 0.14.0+3
js 0.6.2
logging 0.11.4
matcher 0.12.8
meta 1.1.8
node_io 1.1.1
package_config 1.9.3
path 1.7.0
pedantic 1.9.0 1.9.1
pub_semver 1.4.4
quiver 2.1.3
source_span 1.7.0
stack_trace 1.9.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.2.0
watcher 0.9.7+15
yaml 2.2.1
Dev dependencies
build_config ^0.4.2
build_runner ^1.10.0
build_test ^0.10.0
test ^1.0.0