添加js库
- 安装第三方库:
- 包管理器安装:私有库需要发布到verdaccio
yarn add xxx - yarn link安装:首先需要创建一个私有库,不需要发布到verdaccio
# cd到私有库目录,创建连接 cd xxxLib yarn link # 执行连接 cd .. yarn link "xxxLib"
-
在文件 src/worker/common/JSLibrary/index.ts 内添加代码库描述:
import xxx from "myLibrary"; const defaultLibraries = [ ... { accessor: "xxx", lib: xxx, version: "3.17.5", docsURL: "文档地址", name: "xxx", // 在左侧显示的名称 }, ] -
配置自动补全(可选):
- 在文件夹 src/constants/defs/ 下创建 xxx.json 文件
{ "!name": "LIB/xxx", "xxx": { "method or property": { "!doc": "方法或属性描述", "!type": "fn(object)" }, } } - 在文件 src/utils/autocomplete/CodemirrorTernService.ts 内引入
import xxx from "constants/defs/xxx.json"; const DEFS: Def[] = [ ..., xxx ];