接入 hel 碰到的问题(2)

22 阅读1分钟

背景:不想暴露源代码,在默认的模板中会上传 lib 和 lib-js 其中包含了所有的源码。

修改内容如下:

package.json 这里通过 tsc 生成了整个项目的类型文件

-  "types": "lib/entrance/libTypes.ts",
+  "types": "types/components/index.d.ts",

// scripts
-    "build": "npm run check_name && npm run build_dist && npm run build_meta && npm run build_proxy",
+    "build": "npm run build:types && npm run check_name && npm run build_dist && npm run build_meta && npm run build_proxy",
+   "build:types": "tsc --project tsconfig.json",

// files
-    "lib",
-    "src",
+    "types/components",
     "README.md",
-    "tsconfig.json",
-    "scripts"
+    "tsconfig.json"

src/components/index.ts

这里要新增对应组件的导出。

export { Text, Hello, NoMore, PopupEx };

tsconfig.json

tsc 要新增的配置

// compilerOptions
+   "declaration": true,
+   "declarationDir": "./types",
+   "emitDeclarationOnly": true,