Questions tagged [dart2js]

The Dart to JavaScript compiler that reads a Dart file and translates it to JavaScript.

The Dart to JavaScript compiler that reads a Draft file and translates it to JavaScript. It generates JavaScript source code from the Draft files. The name of the tool used to compile the code is draft2js. Dart Editor uses dart2js behind the scenes whenever Dart Editor compiles to JavaScript. It produces a file that contains the JavaScript equivalent of the Dart code. It also produces a source map, which can help to debug the JavaScript version of the app more easily.

196 questions
25
votes
3 answers

Should Flutter web use Wasm instead of dart2js

I spotted several articles about Wasm being faster then JS [1, 2] I see the topic has been touched in this old (closed) issues [3, 4] and this seemingly abandoned discussion on google groups [5]; the question is: why flutter web doesn't use Wasm…
Francesco Iapicca
  • 2,618
  • 5
  • 40
  • 85
13
votes
4 answers

How is dart2js code faster than javascript?

I'm trying to better understand dart's effect on performance. On the dart website, their benchmarks show that Dart code compiled to Javascript is faster than just Javascript. How is this possible? I understand how the Dart VM is faster than v8, but…
hkk
  • 2,069
  • 1
  • 23
  • 48
11
votes
2 answers

Which files are generated when executing `dart2js`? and why?

dart2js probably generates .js.map, .js.deps and .precompiled.js. What's the purpose of them? and I donno why dart2js doens't remove them after finishing compile.
Sungguk Lim
  • 6,109
  • 7
  • 43
  • 63
9
votes
2 answers

Can dart produce readable javascript libraries?

Goal I would like to write a javascript library (framework), but need OOP and mixins. Was giving a go to typescript, but it doesn't support mixins (the handbook says it does, but the compiler/specifications has nothing that is mixin…
Izhaki
  • 23,372
  • 9
  • 69
  • 107
8
votes
3 answers

Why is javascript files generated by dart is so huge?

I have the following dart code: $ cat helloworld.dart main() => print('Hello world!'); $ The javascript code generated by the dart compiler for the above code is as follows: $ cat helloworld.dart.app.js function native_ListFactory__new(typeToken,…
Sangeeth Saravanaraj
  • 16,027
  • 21
  • 69
  • 98
8
votes
1 answer

What is a good way to create a dart wrapper for a Javascript API?

suppose I want to create a wrapper for a javascript API such as localStorage that adds some additional functionality like automatically journaling changes and syncing it to a server. Dart already has wrappers for these APIs, what is a good way to…
jz87
  • 9,199
  • 10
  • 37
  • 42
8
votes
7 answers

Is there a way to check if the script is running in the dart vm or dart2js?

Is there a way to check if the script is running in the dart vm or dart2js? Maybe using mirrors API?
Tiago
  • 143
  • 5
7
votes
2 answers

Angular Dart to JavaScript result way too big for production?

Is it right that the minimum / smallest compiled and minified JavaScript size of an AngularDart application (that does nothing) is about 650KB ? That is way too much for mobile applications and even too big for normal applications. Does anybody know…
Christine
  • 3,014
  • 2
  • 24
  • 34
7
votes
1 answer

How to call a Dart function from Javascript?

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…
midinastasurazz
  • 1,317
  • 2
  • 10
  • 12
7
votes
3 answers

Too large JS-file generated

I have this code: // main.dart import "package:angular/angular.dart"; main () => ngBootstrap(); I make dart2js --minify --out=main.dart.js main.dart Then i have main.dart.js with size 2.6 MiB (2,744,320 bytes). It is not normal. What i'm doing…
media-slave24
  • 256
  • 2
  • 7
7
votes
2 answers

How to deploy a Polymer dart application

I have a dart application using Polymer.dart, i replace the dart.js file by the boot.js (in my index.html), an now i want to deploy this application in order to have a working javascript one. But, when i launch the build.dart, i have : Total time…
6
votes
2 answers

Incorrect comparison of two keyCodes in async function after dart2js

I don't understand this behavior of dart2js code. I have this only in async function and only after compiling to JS. e.keyCode is equal 13 KeyCode.ENTER is equal 13 but (e.keyCode == KeyCode.ENTER) is false This is simple code to debugging my…
gooostaw
  • 499
  • 4
  • 8
6
votes
1 answer

Dart to JS: How to debug the generated Javascript errors

Currently, the Javascript generated by dart2Js converter is very unintuitive to debug and doesn't produce intelligible error messages. Is there a specific way that people use to debug Javascript code generated by dart? I would like to get to the…
Ravi Teja Gudapati
  • 2,809
  • 2
  • 13
  • 16
6
votes
1 answer

ReferenceError: DartObject is not defined

My dart2js compiled Chrome Packaged App crashes with Uncaught Error: Instance of 'UnknownJavaScriptObject' and ReferenceError: DartObject is not defined. The full stack trace follows Uncaught Error: Instance of 'UnknownJavaScriptObject'…
user7610
  • 25,267
  • 15
  • 124
  • 150
6
votes
1 answer

Compile dart in the browser

In my application I generate big dart classes. Right now I compile them on the server, which takes CPU time. It would be much better to compile the Dart code within the browser. The code is then loaded via spawnURI. Is it possible to invoke the…
Karsten Becker
  • 502
  • 5
  • 11
1
2 3
13 14