2
votes

I'm using enumerators (experimental) in my project. Pub Build (Generate JS) in my Dart Editor does not work due to the enums. In my console, this command:

dart2js file.dart --enable-enum

does work, but it is inconvinient to do it through the console. Is there any way to add arguments to the default command in Dart Editor (--enable-enums) so it'd allow it to compile into JS?

Running it by default in Dartium works and when copying and pasting the server url (http://localhost:8080/index.html), the dart2js is triggered and it starts working (after average compilation time).

EDIT: Yes, I have enums enabled in my editor.

EDIT2: To enable enums in dart2js, I have this transformer in pubspec.yaml:

transformers:
- $dart2js:
    commandLineOptions: [--enable-enum]

However, I get this error in a file, which uses enums:

Directive not allowed here.
part of thing;
^^^^^^^^^^^^^^^^
[Info from Dart2JS]:

It's weird that it works in the console with the same arguments and not in the editor.

I have filled a bug report here.

1
Is your enum defined in a part file? Is dart2js the last transformer in your pubspec.yaml transformer section? - Günter Zöchbauer
Yes. The enum is defined in a part, but dart2js transformer is the only one, is it's the last one. - Vilda
Why are you using --enable-enums (plural) on command line and --enable-enum (singular) in the pubspec.yaml transformer config. I think it should be the same (singular on both) code.google.com/p/dart/issues/detail?id=21823#c3 - Günter Zöchbauer
That seems to work. Thanks. - Vilda

1 Answers

2
votes

As of 2016, the enumerators are fully implemented.