简体   繁体   English

有什么方法可以改善 Dart (dart2js) 编译时间?

[英]Is there any way to improve Dart (dart2js) compile times?

I'm trying to move from TypeScript to Dart.我正在尝试从 TypeScript 转移到 Dart。 TypeScript compiles almost immediately - Dart takes more than 5 seconds to compile a Hello World program! TypeScript 几乎可以立即编译——Dart 编译一个 Hello World 程序需要 5 秒以上的时间! Am I missing something?我错过了什么吗? Are there any possible ways to improve that?有什么可能的方法来改善吗?

TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. TypeScript 是 JavaScript 的类型化超集,可编译为纯 JavaScript。
So it (ts compiler) translates from a higher level programming language to a lower level programming language.因此它(ts 编译器)从更高级别的编程语言转换为更低级别的编程语言。

Dart is an open-source, scalable programming language, with robust libraries and runtimes. Dart 是一种开源、可扩展的编程语言,具有强大的库和运行时。
So it (dart2js compiler) is a source-to-source compiler (transpiler) that takes the source code of a program written in one programming language as its input and produces the equivalent source code in another programming language.因此它(dart2js 编译器)是一种源到源编译器(transpiler),它以一种编程语言编写的程序的源代码作为输入,并生成另一种编程语言中的等效源代码。

I think that explains everything.我认为这可以解释一切。

This is usually not much of an issue when developing with Dart because Dartium, a Chromium derivative executes Dart directly.在使用 Dart 进行开发时,这通常不是什么大问题,因为 Dartium(一种 Chromium 衍生产品)直接执行 Dart。

Only for testing compatibility with other browsers and for deployment it is necessary to build to JavaScript.仅为了测试与其他浏览器的兼容性和部署,才需要构建到 JavaScript。

pub serve a Dart development web server does dart-to-js compilation on-the-fly with a lot of caching which usually improves transpilation times for reloads (after some warmup time) if you need JS during development with non-Dartium browsers. pub serve a Dart 开发 Web 服务器即时执行 dart-to-js 编译,并带有大量缓存,如果您在非 Dartium 浏览器的开发过程中需要 JS,这通常会提高重新加载的转换时间(经过一些预热时间)。

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

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