Roman
Roman

Reputation: 2175

Turn off dart2js during pub build

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

Upvotes: 2

Views: 437

Answers (2)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657416

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 useDart2JS to 'false'.

see also https://code.google.com/p/dart/source/browse/branches/bleeding_edge/dart/sdk/lib/_internal/pub/lib/src/barback/build_environment.dart#56

I haven't tried it myself but I think this should work.

Or exclude the web directory for the dart2js transformer in pubspec.yaml

transformers:
- $dart2js:
    $exclude: web

Upvotes: 1

Roman
Roman

Reputation: 2175

The answer from https://code.google.com/p/dart/issues/detail?id=17484#c4

> First of all, during your iteration loop, you should consider using "pub serve" rather than "pub build". It will only compile dart2js outputs when they're requested, so you can easily test your Dart output without waiting for useless JS. Unfortunately it won't automatically reload your transformer yet, but even so it should still be faster.

> If you really want to use "pub build", you can run it with "--mode debug" to get it to generate JS, and then add "{$dart2js: {$exclude: web}}" as a transformer to effectively disable dart2js.

see also documentation https://www.dartlang.org/tools/pub/assets-and-transformers.html#exclude-assets

Upvotes: 3

Related Questions