dart2js

Getting error converting dart2js on polymer project

北慕城南 提交于 2019-12-05 23:23:29
Unsupported operation: Can't use ownerName in reflection because it is not included in a @MirrorsUsed annotation. ownerName is just an published attribute on the polymer element. I understand there are a few things out there (on web, not on here) like this but none have a solid answer... I also get this below it: NoSuchMethodError : method not found: 'Symbol("title")' Anyone got any ideas. Been wrestling with this for 3 hours and ready to dump polymer. Though It was fun in dartium, if it cannot convert to JS I see no real use in it. import 'package:polymer/polymer.dart'; import 'package:google

How to deploy a Dart Polymer app to Javascript using dart2js

こ雲淡風輕ζ 提交于 2019-12-04 10:20:31
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="example-polymer.html"> <script type="application/dart">export 'package:polymer/init.dart';</script> <script

How to exclude debug code

一个人想着一个人 提交于 2019-12-02 01:39:42
问题 Let's say I have simple logger: void main() { var logger = new MyLogger(); logger.log("hello Dart"); } I want this code to run in the dev mode (VM checked mode) but i don't want it in my production code. And i want it to be "tree shaked" away with the dart2js compiler. Is there some standard way? 回答1: You could embed the code in an assert . Assertions are ignored in production code and I'm sure not built to JS when pub build is run in release mode. class X { X() { print('x created'); } void

How to exclude debug code

£可爱£侵袭症+ 提交于 2019-12-02 01:30:11
Let's say I have simple logger: void main() { var logger = new MyLogger(); logger.log("hello Dart"); } I want this code to run in the dev mode (VM checked mode) but i don't want it in my production code. And i want it to be "tree shaked" away with the dart2js compiler. Is there some standard way? Günter Zöchbauer You could embed the code in an assert . Assertions are ignored in production code and I'm sure not built to JS when pub build is run in release mode. class X { X() { print('x created'); } void log(String m) { print(m); } } bool log(String m) { new X()..log(m); return true; } void main

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

牧云@^-^@ 提交于 2019-12-01 05:33:13
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. 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: [--enable-experimental-mirrors] 来源: https://stackoverflow.com/questions/27720721/how-to-enable-enable

How to call a Dart function from Javascript?

拈花ヽ惹草 提交于 2019-11-29 14:16:51
I would like to call a Dart function from Javascript. I would like to compile a Dart script containing a Dart function using dart2js (version 1.1.3) and then load the generated .js file into a Javascript environment and call that function from Javascript. Something along the lines of calling myHyperSuperMegaFunction below from Javascript. import 'dart:js' as js; int myHyperSuperMegaFunction(int a, int b) { return a + b; } main() { js.context['myHyperSuperMegaFunction'] = new js.JsFunction.withThis(myHyperSuperMegaFunction); } I tried compiling the above with dart2js and loading the generated

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

你。 提交于 2019-11-29 08:20:56
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 in Dartium. When I compile it to javascript however it gives an error Uncaught NoSuchMethodError :

How to call a Dart function from Javascript?

这一生的挚爱 提交于 2019-11-28 08:11:19
问题 I would like to call a Dart function from Javascript. I would like to compile a Dart script containing a Dart function using dart2js (version 1.1.3) and then load the generated .js file into a Javascript environment and call that function from Javascript. Something along the lines of calling myHyperSuperMegaFunction below from Javascript. import 'dart:js' as js; int myHyperSuperMegaFunction(int a, int b) { return a + b; } main() { js.context['myHyperSuperMegaFunction'] = new js.JsFunction

How to achieve precompiler directive like functionality

爱⌒轻易说出口 提交于 2019-11-26 12:31:41
问题 I\'m developing an angular app, and it\'s recommended to use generated code for a lot of things running in production, namely template caches, expression caches, and a static DI injector. There\'s currently no nice way to switch between different build configurations, so I\'m using the pattern recommended here: In lib/main.dart you can see initializer-prod.dart file being imported, which has initializer-dev.dart counterpart. Switching between those two file will allow you to switch between