You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried using the --minify parameter, but it was not helpful.
The closure compiler could not compress it much.
This dart code:
class BadPerson{
String _name;
int _age;
BadPerson(String name, int age){
this._name = name;
this._age = age;
}
String getName() => _name;
int getAge() => _age;
toString() => "{BadPerson " + _name + " " + _age.toString() + "}";
}
class GoodPerson{
final String name;
final int age;
const GoodPerson(this.name, this.age);
String getName() => name;
int getAge() => age;
toString() => "{GoodPerson " + name + " " + age.toString() + "}";
}
var badPeople = [
new BadPerson('Kimberly', 14),
new BadPerson('Bertha', 22),
new BadPerson('Roberto', 30),
new BadPerson('Gordon', 6),
new BadPerson('Lisa', 27),
new BadPerson('Gaye', 8),
new BadPerson('Marian', 11),
new BadPerson('Julie', 5),
new BadPerson('June', 16),
new BadPerson('John', 6)
];
var goodPeople = [
new GoodPerson('Barbara', 14),
new GoodPerson('Joshua', 24),
new GoodPerson('Bertha', 20),
new GoodPerson('Gary', 15),
new GoodPerson('William', 16),
new GoodPerson('Stanley', 11),
new GoodPerson('Kelli', 30),
new GoodPerson('Joanna', 2),
new GoodPerson('Sylvia', 2),
new GoodPerson('Amber', 29),
new GoodPerson('Charlene', 19)
];
Gets compiled to this javascript:
Isolate.$lazy($, "badPeople", "badPeople", "get$badPeople", function() {
var t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
t1 = new D.BadPerson(null, null);
t1._name = "Kimberly";
t1._age = 14;
t2 = new D.BadPerson(null, null);
t2._name = "Bertha";
t2._age = 22;
t3 = new D.BadPerson(null, null);
t3._name = "Roberto";
t3._age = 30;
t4 = new D.BadPerson(null, null);
t4._name = "Gordon";
t4._age = 6;
t5 = new D.BadPerson(null, null);
t5._name = "Lisa";
t5._age = 27;
t6 = new D.BadPerson(null, null);
t6._name = "Gaye";
t6._age = 8;
t7 = new D.BadPerson(null, null);
t7._name = "Marian";
t7._age = 11;
t8 = new D.BadPerson(null, null);
t8._name = "Julie";
t8._age = 5;
t9 = new D.BadPerson(null, null);
t9._name = "June";
t9._age = 16;
t10 = new D.BadPerson(null, null);
t10._name = "John";
t10._age = 6;
return [t1, t2, t3, t4, t5, t6, t7, t8, t9, t10];
});
Isolate.$lazy($, "goodPeople", "goodPeople", "get$goodPeople", function() {
return [new D.GoodPerson("Barbara", 14), new D.GoodPerson("Joshua", 24), new D.GoodPerson("Bertha", 20), new D.GoodPerson("Gary", 15), new D.GoodPerson("William", 16), new D.GoodPerson("Stanley", 11), new D.GoodPerson("Kelli", 30), new D.GoodPerson("Joanna", 2), new D.GoodPerson("Sylvia", 2), new D.GoodPerson("Amber", 29), new D.GoodPerson("Charlene", 19)];
});
What is the expected output? What do you see instead?
The BadPerson class is just as simple as the GoodPerson class.
I would expect them to convert to somewhat similar javascript.
This can make a huge filesize difference when large arrays of Person objects are constructed.
Simply using final and const changed my .js filesize from 3 MB to 1 MB.
What version of the product are you using? On what operating system?
Dart 1.0.0.3_r30188 on Windows 7, 64bit
Please provide any additional information below.
In attachment you'll find a simple example which clearly shows compilation to javascript generates much larger files while there doesn't seem to be any need for it.
Isolate.$lazy($, "badPeople", "badPeople", "get$badPeople", function() {
return [new V.BadPerson("Kimberly", 14), new V.BadPerson("Bertha", 22), new V.BadPerson("Roberto", 30), new V.BadPerson("Gordon", 6), new V.BadPerson("Lisa", 27), new V.BadPerson("Gaye", 8), new V.BadPerson("Marian", 11), new V.BadPerson("Julie", 5), new V.BadPerson("June", 16), new V.BadPerson("John", 6)];
});
Isolate.$lazy($, "goodPeople", "goodPeople", "get$goodPeople", function() {
return [new V.GoodPerson("Barbara", 14), new V.GoodPerson("Joshua", 24), new V.GoodPerson("Bertha", 20), new V.GoodPerson("Gary", 15), new V.GoodPerson("William", 16), new V.GoodPerson("Stanley", 11), new V.GoodPerson("Kelli", 30), new V.GoodPerson("Joanna", 2), new V.GoodPerson("Sylvia", 2), new V.GoodPerson("Amber", 29), new V.GoodPerson("Charlene", 19)];
});
Added Duplicate label. Marked as being merged into #9757.
This issue was originally filed by k.nei...@gmail.com
What steps will reproduce the problem?
When running:
dart2js --out=bugreport.js example.dart
java -jar compiler.jar --js bugreport.js --js_output_file bugreport.min.js --warning_level QUIET --language_in ECMASCRIPT5
I tried using the --minify parameter, but it was not helpful.
The closure compiler could not compress it much.
This dart code:
class BadPerson{
String _name;
int _age;
BadPerson(String name, int age){
this._name = name;
this._age = age;
}
String getName() => _name;
int getAge() => _age;
toString() => "{BadPerson " + _name + " " + _age.toString() + "}";
}
class GoodPerson{
final String name;
final int age;
const GoodPerson(this.name, this.age);
String getName() => name;
int getAge() => age;
toString() => "{GoodPerson " + name + " " + age.toString() + "}";
}
var badPeople = [
new BadPerson('Kimberly', 14),
new BadPerson('Bertha', 22),
new BadPerson('Roberto', 30),
new BadPerson('Gordon', 6),
new BadPerson('Lisa', 27),
new BadPerson('Gaye', 8),
new BadPerson('Marian', 11),
new BadPerson('Julie', 5),
new BadPerson('June', 16),
new BadPerson('John', 6)
];
var goodPeople = [
new GoodPerson('Barbara', 14),
new GoodPerson('Joshua', 24),
new GoodPerson('Bertha', 20),
new GoodPerson('Gary', 15),
new GoodPerson('William', 16),
new GoodPerson('Stanley', 11),
new GoodPerson('Kelli', 30),
new GoodPerson('Joanna', 2),
new GoodPerson('Sylvia', 2),
new GoodPerson('Amber', 29),
new GoodPerson('Charlene', 19)
];
Gets compiled to this javascript:
Isolate.$lazy($, "badPeople", "badPeople", "get$badPeople", function() {
var t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
t1 = new D.BadPerson(null, null);
t1._name = "Kimberly";
t1._age = 14;
t2 = new D.BadPerson(null, null);
t2._name = "Bertha";
t2._age = 22;
t3 = new D.BadPerson(null, null);
t3._name = "Roberto";
t3._age = 30;
t4 = new D.BadPerson(null, null);
t4._name = "Gordon";
t4._age = 6;
t5 = new D.BadPerson(null, null);
t5._name = "Lisa";
t5._age = 27;
t6 = new D.BadPerson(null, null);
t6._name = "Gaye";
t6._age = 8;
t7 = new D.BadPerson(null, null);
t7._name = "Marian";
t7._age = 11;
t8 = new D.BadPerson(null, null);
t8._name = "Julie";
t8._age = 5;
t9 = new D.BadPerson(null, null);
t9._name = "June";
t9._age = 16;
t10 = new D.BadPerson(null, null);
t10._name = "John";
t10._age = 6;
return [t1, t2, t3, t4, t5, t6, t7, t8, t9, t10];
});
Isolate.$lazy($, "goodPeople", "goodPeople", "get$goodPeople", function() {
return [new D.GoodPerson("Barbara", 14), new D.GoodPerson("Joshua", 24), new D.GoodPerson("Bertha", 20), new D.GoodPerson("Gary", 15), new D.GoodPerson("William", 16), new D.GoodPerson("Stanley", 11), new D.GoodPerson("Kelli", 30), new D.GoodPerson("Joanna", 2), new D.GoodPerson("Sylvia", 2), new D.GoodPerson("Amber", 29), new D.GoodPerson("Charlene", 19)];
});
What is the expected output? What do you see instead?
The BadPerson class is just as simple as the GoodPerson class.
I would expect them to convert to somewhat similar javascript.
This can make a huge filesize difference when large arrays of Person objects are constructed.
Simply using final and const changed my .js filesize from 3 MB to 1 MB.
What version of the product are you using? On what operating system?
Dart 1.0.0.3_r30188 on Windows 7, 64bit
Please provide any additional information below.
In attachment you'll find a simple example which clearly shows compilation to javascript generates much larger files while there doesn't seem to be any need for it.
Attachment:
bugreport.7z (2.60 MB)
The text was updated successfully, but these errors were encountered: