使用包:http / browser_client.dart会导致有关镜像的警告

时间:2015-01-08 20:36:02

标签: dart

在执行import 'package:http/browser_client.dart';

时,在飞镖pub build中执行以下导入会导致警告
****************************************************************
* WARNING: dart:mirrors support in dart2js is experimental,
*          and not recommended.
*          This implementation of mirrors is incomplete,
*          and often greatly increases the size of the generated
*          JavaScript code.
*
* Your app imports dart:mirrors via:
*   index.html_bootstrap.dart => package:myapp => package:http => dart:mirrors
*
* Starting with Dart 1.9, you must use the
* --enable-experimental-mirrors command-line flag to opt-in.
* You can begin using this flag now if mirrors support is critical.
*
* To learn what to do next, please visit:
*    http://dartlang.org/dart2js-reflection
****************************************************************

[Warning from Dart2JS on myapp|web/index.html_bootstrap.dart]:
3 hint(s) suppressed in package:http.
[Dart2JS on myapp|web/index.html_bootstrap.dart]:
5 warning(s) suppressed in package:myapp.
[Warning from Dart2JS]:
web/index.html_bootstrap.dart:
1 methods retained for use by dart:mirrors out of 2361 total methods (0%).
[Info from Dart2JS on myapp|web/index.html_bootstrap.dart]:
packages/http/src/io.dart:9:1:
Import of 'dart:mirrors'.
import 'dart:mirrors';
^^^^^^^^^^^^^^^^^^^^^^

使用该browser_client的代码是:

var client = new BrowserClient();
client.post(url, body: req.toString())...

这是我应该关注的事情,还是这个讨厌的警告之一,除非我停止使用http包,否则不会消失?

更新

查看browser_client.dart,我看到以下评论:

// TODO(nweiz): Move this under src/, re-export from lib/http.dart, and use this
// automatically from [new Client] once we can create an HttpRequest using
// mirrors on dart2js (issue 18541) and dart2js doesn't crash on pkg/collection
// (issue 18535).

更新

运行pub帮助,我看不到这样的标志:

pub help
Pub is a package manager for Dart.

Usage: pub <command> [arguments]

Global options:
-h, --help            Print this usage information.
    --version         Print pub version.
    --[no-]trace      Print debugging information when an error occurs.
    --verbosity       Control output verbosity.

          [all]       Show all output including internal tracing messages.
          [io]        Also show IO operations.
          [normal]    Show errors, warnings, and user messages.
          [solver]    Show steps during version resolution.

-v, --verbose         Shortcut for "--verbosity=all".

Available commands:
  build       Apply transformers to build a package.
  cache       Work with the system cache.
  deps        Print package dependencies.
  downgrade   Downgrade the current package's dependencies to oldest versions.
  get         Get the current package's dependencies.
  global      Work with global packages.
  help        Display help information for Pub.
  publish     Publish the current package to pub.dartlang.org.
  run         Run an executable from a package.
  serve       Run a local web development server.
  upgrade     Upgrade the current package's dependencies to latest versions.
  uploader    Manage uploaders for a package on pub.dartlang.org.
  version     Print pub version.

直接调用它,pub告诉我没有这样的标志:

 pub build --enable-experimental-mirrors
Could not find an option named "enable-experimental-mirrors".

1 个答案:

答案 0 :(得分:4)

当您添加标记时,它会消失:--enable-experimental-mirrors

正如消息所说,镜像当前膨胀的生成JavaScript的大小。这通常会让开发人员意识不到,因为他们正确地期望dart2js正确地处理这个问题。但是,这对于dart2js来说是一个非常重要的问题。虽然正在开发更好的解决方案,但镜像支持被认为是实验性的,此警告用于通知开发人员使用它们时可能遇到的问题。

您可以添加标记以表示您知道镜像问题,并且仍然选择使用它们。