简体   繁体   English

在发布过程中关闭dart2js

[英]Turn off dart2js during pub build

I am writing a custom transformer for pub build . 我正在为pub build编写自定义转换器。 I would like to turn off compilation of dart files to js during debugging of the transformer to save time. 我想在调试变压器时关闭dart文件到js的编译,以节省时间。 Is it possible? 可能吗?

Currently, my simplified pubspec.yaml is 目前,我的简化pubspec.yaml

name: my_proj
dependencies:
    polymer: any
transformers:
    - my_proj

The answer from https://code.google.com/p/dart/issues/detail?id=17484#c4 来自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. 它只会在需要时编译dart2js输出,因此您可以轻松测试Dart输出,而无需等待无用的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. >如果您确实要使用“ pub build”,则可以使用“ --mode debug”运行它以生成JS,然后将“ {{dart2js:{$ exclude:web}}}”作为转换器添加到有效地禁用dart2js。

see also documentation https://www.dartlang.org/tools/pub/assets-and-transformers.html#exclude-assets 另请参阅文档https://www.dartlang.org/tools/pub/assets-and-transformers.html#exclude-assets

There is no option for pub build only for pub serve --no-dart2js . 仅用于pub serve --no-dart2js pub build没有选项。

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'. dart/sdk/lib/_internal/pub/lib/src/barback/build_environment.dart安装目录中的dart/sdk/lib/_internal/pub/lib/src/barback/build_environment.dart并将useDart2JS设置为“ 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 另请参阅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 或在pubspec.yaml排除dart2js转换器的Web目录

transformers:
- $dart2js:
    $exclude: web

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM