Dart:如何设置在命令行上运行的前导文件?

时间:2014-11-18 07:05:35

标签: eclipse dart server-side

我使用带有dart插件的eclipse,当我运行“ pub build ”时,我得到了下面的结果。
我已经使用Tomcat将构建的目录移动到VPS,客户端代码运行正常。

如何运行服务器端代码(TreeFilesystemServer.dart)? 因为我有一些服务器端代码,结果说我可能会提供前导文件 我必须提供序言文件吗?前导文件是什么意思?

提前致谢!

1.My project framework.
Main
--web
  --allyEdit
    --TreeFilesystemServer.dart  <=(this is a server side code)
  --Main.css
  --Main.dart  <=(this is the entry point of client )
  --Main.html
--pubspec.lock
--pubspec.yaml


2.Below is the message when I run pub build.
[Info from Dart2JS]:  
Compiling allyEdit_dart|web/allyEdit/TreeFilesystemServer.dart...  
[Warning from Dart2JS on allyEdit_dart|web/allyEdit/TreeFilesystemServer.dart]:  

When run on the command-line, the compiled output might require a preamble file located in:
<sdk>/lib/_internal/lib/preambles.  

[Info from Dart2JS]:  
Took 0:00:04.534259 to compile allyEdit_dart|web/allyEdit/TreeFilesystemServer.dart.  
Built 1649 files to "build".

1 个答案:

答案 0 :(得分:1)

dart2js编译输出的“前导文件”是一个javascript文件,它建立了一个与浏览器类似的JS环境,因此dart2js输出可以在浏览器之外运行。

Dart项目的测试可以在浏览器,基于v8的“d8”独立JavaScript shell和“jsshell”中运行,它是Mozilla JS引擎的独立版本。 对于后两个,编译的代码需要在编译的脚本之前执行“前导文件”。 dart2js前导文件位于sdk / lib / _internal / compiler / js_lib / preambles中 - 它们最近被移动到这里,因此一些较旧的引用可能指向不同的位置。

如果您只在浏览器中运行dart2js编译代码,则无需提供前导文件。 如果要在d8中测试输出,则需要d8前导文件(设置用于打印的挂钩并模拟定时器)。