A pub transformer that rewrites Dart script tags to JavaScript script tags, eliminating 404s and speeding up initial loads. Useful when building for deployment.
A traditional Dart application is deployed with HTML that looks something like this:
<script async type="application/dart" src="test.dart"></script>
<script async src="packages/browser/dart.js"></script>
This is a performance problem for initial startup, because:
With this transformer, you can address the above issues, speed up the load time of your apps, and make happier users.
Add the transformer to your pubspec.yaml:
transformers:
- dart_to_js_script_rewriter
(Assuming you already added this package to your pubspec.yaml file.)
When run in "release" mode, this transformer does two things:
dart.js
.For example, this code:
<script async type="application/dart" src="test.dart"></script>
<script async src="packages/browser/dart.js"></script>
is turned into this code:
<script async src="test.dart.js"></script>
This transformer only runs when pub is running in release mode.
This transformer only makes sense when you want to build your app for a production deployment. You probably do not want to run this transformer during the normal develop/reload cycles.
Pub can run in different modes, which have different semantics. The debug mode, for example, can disable minification. The release mode can turn on optimizations.
By default, pub serve
runs in debug mode. By default, pub build
runs in release mode.
See the pub docs for more on modes.
Please use the issue tracker.
Add this to your package's pubspec.yaml file:
dependencies:
dart_to_js_script_rewriter: ^0.1.0+3
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.
Now in your Dart code, you can use:
import 'package:dart_to_js_script_rewriter/dart_to_js_script_rewriter.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
1.0.3 | Jun 15, 2017 |
|
|
1.0.2 | Sep 26, 2016 |
|
|
1.0.1 | Feb 25, 2016 |
|
|
0.1.0+4 | Sep 26, 2015 |
|
|
0.1.0+3 | Aug 16, 2015 |
|
|
0.1.0+1 | Feb 7, 2015 |
|
|
0.1.0 | Feb 7, 2015 |
|
|
0.0.2 | Sep 11, 2014 |
|
|
0.0.1+3 | Sep 11, 2014 |
|
|
0.0.1+2 | May 1, 2014 |
|
|
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
75
|
Health:
Code health derived from static analysis.
[more]
|
--
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
--
|
Overall:
Weighted score of the above.
[more]
|
37
|
This package version is not analyzed, because it is more than two years old. Check the latest stable version for its analysis.
Running dartdoc
failed. (-10 points)
Make sure dartdoc
runs without any issues.