# ts2abc组件 - [ts2abc组件](#ts2abc组件) - [简介](#简介) - [目录](#目录) - [编译构建](#编译构建) - [使用说明](#使用说明) - [相关仓](#相关仓) ## 简介 ts2abc组件是方舟运行时子系统的前端工具,支持将JavaScript文件转换为方舟字节码文件。 更多信息请参考:[方舟运行时子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/ARK-Runtime-Subsystem-zh.md) ## 目录 ``` /ark/ts2abc/ ├── test262 # test262测试配置和运行脚本 ├── testTs # 系统测试目录 ├── ts2panda ├── doc # 文档 ├── scripts # 依赖的脚本 ├── src # 源码存放目录 ├── templates # ruby模板文件 ├── tests # UT单元测试目录 ├── tools # ts2abc提供的工具 └── ts2abc # abc文件生成相关 ``` ## 编译构建 ts2abc组件采用命令行交互方式,支持将JavaScript代码转换为方舟字节码文件,使其能够在方舟运行时上运行。支持Windows/Linux/MacOS平台。方舟前端工具在linux平台上可通过全量编译或指定编译前端工具链获取。 ``` $ ./build.sh --product-name Hi3516DV300 --build-target ark_ts2abc_build ``` ### 使用说明 安装`node`和`npm` 使用ts2abc组件将JavaScript文件转换为方舟字节码文件 ``` $ cd out/hi3516dv300/clang_x64/ark/ark/build $ npm install $ node --expose-gc src/index.js [options] file.js ``` 当不输入任何option参数时,默认生成方舟二进制文件。

选项

缩写

描述

取值范围

默认值

--modules

-m

按照module模式编译

-

-

--debug-log

-l

使能log信息

-

-

--dump-assembly

-a

输出为汇编文件

-

-

--debug

-d

携带debug信息

-

-

--show-statistics

-s

显示字节码相关的统计信息

-

-

--output

-o

输出文件路径

-

-

--timeout

-t

超时门限

-

-

--opt-log-level

-

指定编译优化log等级

['debug', 'info', 'error', 'fatal']

error

--opt-level

-

指定编译优化等级

-

1

--help

-h

帮助提示

-

-

--bc-version

-v

输出当前字节码版本

-

-

--bc-min-version

-

输出当前支持的最低字节码版本

-

-

--included-files

-i

编译依赖的文件列表

-

-

--record-type

-p

是否记录类型信息

-

true

--dts-type-record

-q

记录.d.ts文件的类型信息

-

false

--debug-type

-g

打印记录的类型信息

-

false

--output-type

-

设置输出类型

-

false

更多使用说明请参考:[方舟运行时使用指南](https://gitee.com/openharmony/ark_js_runtime/blob/master/docs/ARK-Runtime-Usage-Guide-zh.md) ## 相关仓 [ark\_runtime\_core](https://gitee.com/openharmony/ark_runtime_core) [ark\_js\_runtime](https://gitee.com/openharmony/ark_js_runtime) **[ark\_ts2abc](https://gitee.com/openharmony/ark_ts2abc)**