2

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
0xcaff
  • 13,085
  • 5
  • 47
  • 55
Roman
  • 2,145
  • 4
  • 26
  • 33

2 Answers2

3

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

Roman
  • 2,145
  • 4
  • 26
  • 33
1

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
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • I have not found the build_environment.dart file in the dart directory.. I use the lastest DEV version of dart on my computer.. I hope this option will be available for pub built in the future.. – Roman Mar 14 '14 at 06:21
  • 1
    The published Dart SDK seems to have this encoded in a snapshot only (even though the `pub` script used to invoke `pub` references the path `dart-sdk/lib/_internal/pub/` the folder doesn't exist. To make this work you may need to build the SDK from source. Probably not worth the hassle. – Günter Zöchbauer Mar 14 '14 at 07:42