编译typescript
准备鸿蒙全套代码,进入third_party/typescript/目录,执行如下命令:
npm install -g gulp
npm install
npm run gulp LKG
npm pack
cp *.tgz build_package/
拷贝到typescript代码目录下的build_package目录。
编译工具链
npm install
npm run build
npm run compile
默认编译的工程为compiler目录下sample工程。
ArkTs编译流程
以一个文件编译为例。为了更好更快搞清楚ArkTs编译过程中如何进行特殊的语法校验支持,通过VsCode断点编译单个文件的流程。在设置断点Debug之前,我们需要做如下前置准备:
- 去掉ArkTs compiler工程中的uglify配置,修改为如下配置:
"scripts": { "lint": "eslint --fix ./src --ext .ts", "build": "./node_modules/.bin/babel ./src --out-dir lib --extensions .ts", "create": "node ./lib/create.js --env projectName", "compile": "npm run build && webpack --config webpack.config.js --env buildMode=debug projectName", "test": "npm run build && mocha -r mocha-context/register test/test.js && mocha -r mocha-context/register test/test.js --partialUpdate", "generateDeclarations": "node ./build_declarations_file.js ../../../interface/sdk-js/api/@internal/component/ets ./declarations ./lib", "postinstall": "node npm-install.js", "fastbuild": "rollup -c rollup.config.js" },
- 添加调试配置
- 设置断点
- 开始调试