dart2js

Compiled AngularDart fails with error in dynamic_injector

无人久伴 提交于 2019-12-23 02:18:30
问题 I have been trying to make AngularDart work but I always get exceptions for undefined objects. @MirrorsUsed( targets: const [ 'angular.core', 'angular.core.dom', 'angular.core.parser', 'angular.routing', 'angular.core.zone', 'di.di', 'di.dynamic_injector', NodeTreeSanitizer, DynamicParser, DynamicParserBackend, Injector ], metaTargets: const [ NgInjectableService, NgComponent, NgDirective, NgController, NgFilter, NgAttr, NgOneWay, NgOneWayOneTime, NgTwoWay, NgCallback, NgZone ], override: '*'

How to deploy a Dart Polymer app to Javascript using dart2js

南楼画角 提交于 2019-12-21 19:46:23
问题 I got a problem while deploying Dart code using Polymer to Javascript. I've created a polymer application with DartEditor and made a simple example. This example works in Dartium but when I try to build it as a Polymer App (in Javascript) and launch it, the app fails. How am I supposed to convert a Dart Polymer app to Javascript ? Here's the example code I made that fails : example.html : <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Example</title> <link rel="import" href=

how to enable --enable-experimental-mirrors in dart build?

瘦欲@ 提交于 2019-12-19 08:08:17
问题 My build of my projects are failing because they rely on mirrors and dart build out put tells me to use --enable-experimental-mirrors to try to use mirrors in dart2js code as it is. so if I run pub build --enable-experimental-mirrors all I get is Could not find an option named "enable-experimental-mirrors" . Any hints much appreciated. 回答1: I haven't tried this myself yet but maybe you can pass it as a command line option in the transformer config transformers: - $dart2js: commandLineOptions:

how to enable --enable-experimental-mirrors in dart build?

拥有回忆 提交于 2019-12-19 08:08:09
问题 My build of my projects are failing because they rely on mirrors and dart build out put tells me to use --enable-experimental-mirrors to try to use mirrors in dart2js code as it is. so if I run pub build --enable-experimental-mirrors all I get is Could not find an option named "enable-experimental-mirrors" . Any hints much appreciated. 回答1: I haven't tried this myself yet but maybe you can pass it as a command line option in the transformer config transformers: - $dart2js: commandLineOptions:

js interop compiled with dart2js error - Uncaught NoSuchMethodError : method not found:

有些话、适合烂在心里 提交于 2019-12-18 05:15:10
问题 I generated a sample Polymer web project. Added following js file. jslib.js function testfunction() { alert("test"); } in clickcounter.dart I added dependency import 'package:js/js.dart' as js; and changed increment() function void increment() { js.context.testfunction(); count++; } In clickcounter.html added js file import <script src="jslib.js" type="text/javascript"></script> And in main html file added <script src="packages/browser/interop.js"></script> It works correctly when in executed

Dart chrome extension: Listen to chrome api events

£可爱£侵袭症+ 提交于 2019-12-13 14:41:34
问题 To better describe my problem i have created a small example of a chrome extension written in Dart. You can see the code or download the extension on Gist. The problem This example is running fine in Dartium, but when compiled to javascript a typeerror occurs: Uncaught TypeError: undefined is not a function for the line: context['chrome']['runtime']['onMessage'].callMethod('addListener', [onMessageListener]); How far i already am As you may see in the example the functions alert() or console

Turn off dart2js during pub build

匆匆过客 提交于 2019-12-11 01:28:29
问题 I am writing a custom transformer for pub build . I would like to turn off compilation of dart files to js during debugging of the transformer to save time. Is it possible? Currently, my simplified pubspec.yaml is name: my_proj dependencies: polymer: any transformers: - my_proj 回答1: There is no option for pub build only for pub serve --no-dart2js . You could temporary modify the file dart/sdk/lib/_internal/pub/lib/src/barback/build_environment.dart in your dart install directory and set

Get variable from JavaScript into Dart

僤鯓⒐⒋嵵緔 提交于 2019-12-10 20:33:42
问题 I have a JavaScript library being imported in my HTML Documents head. How can I access objects from this library? Thank you. 回答1: The interop with JavaScript is desribed in article 'Using JavaScript from Dart: The js Library' In short, you have to: //import the JS interop lib import 'package:js/js.dart' as js; // access the JS context for the page var context = js.context; // then use context to access JS object var canvas = query('#map_canvas'); var googlemaps = js.context.google.maps; //

Chrome content scripts in Dart

别说谁变了你拦得住时间么 提交于 2019-12-07 00:12:42
Is it possible to use dart for chrome extension content scripts? The following does not seem to call anything in main() import 'dart:html'; import 'package:js/js.dart' as js; void main() { js.context.alert('Hello from Dart via JavaScript'); window.console.log("START!!!"); window.alert("alert"); } manifest.json... "content_scripts": [ { "matches": [ "http://docs.google.com/*", "https://docs.google.com/*" ], "js": [ "packages/browser/dart.js", "packages/browser/interop.js", "packages/js/dart_interop.js", "out.js" ], "run_at" : "document_idle", "all_frames" : false } ], I'm not familiar with

dart vm works but dart2js fails

我的未来我决定 提交于 2019-12-06 09:46:29
问题 I am doing polymer dart. Everything works fine with dart vm but when I try to deploy it, it fails (compilation was okay.) When I run the built js version. It gave me the error Uncaught TypeError: Cannot call method 'shL' of null I tried to trace the compiled js code, and it seems like due to query an element that is not yet in the document (it is in the html file but somehow only the head of the document is loaded at that time.) Since it's the compiled version, it's really hard to trace which