简体   繁体   English

dart2js和dart2dart构建

[英]dart2js and dart2dart on build

I am trying to build but I have this situation 我正在尝试建造,但我有这种情况

  1. Files in bin are server files and don't need to be compiled to js. bin中的文件是服务器文件,不需要编译为js。
  2. Server files us async/await while client files don't. 服务器文件async/await我们,而客户端文件没有。 The server is run with the --enable-async VM option. 服务器使用--enable-async VM选项运行。
  3. Client files should be treeshaked/minified JS. 客户端文件应为树状/最小化的JS。
  4. Client files should ALSO be treeshaked/minified (if possible) to Dart. 客户端文件还应该被树形化/最小化(如果可能)到Dart。

Currently I include this in my pubspec.yaml 目前,我将其包含在我的pubspec.yaml中

- $dart2js:
    $exclude: bin

because I get an error for using async on the server. 因为我在服务器上使用async时遇到错误。 If I include the async_await transformer I get even more errors (in fact I had to role back to using then on the client). 如果包含async_await转换器, async_await出现更多错误(实际上,我不得不回到客户端上使用then角色)。

The real question is how to get efficient server and client dart files, and get efficient client js files out of the build process. 真正的问题是如何从构建过程中获取有效的服务器和客户端dart文件,以及获取有效的客户端js文件。

You can use snapshots for server side code. 您可以将快照用于服务器端代码。 This packs everything into one file and speeds up app startup. 它将所有内容打包到一个文件中,并加快了应用程序的启动速度。

See https://www.dartlang.org/articles/snapshots/ for more details. 有关更多详细信息,请参见https://www.dartlang.org/articles/snapshots/

I don't have an answer for the other points. 对于其他问题,我没有答案。

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

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