typescript - tsc 对 yarn add ssh:// 不起作用
问题描述
我创建了一个反应库,我正在尝试将它安装在另一个项目中yarn add ssh://<ssh-repo-address>
。该库已成功安装在node_modules文件夹中,但yarn build
在脚本中执行的命令prepare
不会创建 lib(build) 文件夹。如果我yarn build
在安装 lib 后直接在node_modules/my-lib中运行命令,则会创建lib文件夹。这可以通过 tsc 实现吗?
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"outDir": "lib/esm",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"declaration": true,
"declarationDir": "lib/esm",
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react"
},
"include": [
"src"
],
"exclude": [
"**/*.spec.?s",
"**/*.test.?s",
"**/*.stories.?s",
"**/*.stories.?sx",
]
}
包.json
{
...
"devDependencies": {
"@babel/core": "^7.15.5",
"@storybook/addon-actions": "^6.3.9",
"@storybook/addon-essentials": "^6.3.9",
"@storybook/addon-links": "^6.3.9",
"@storybook/react": "^6.3.9",
"@types/react": "^17.0.27",
"babel-loader": "^8.2.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"typescript": "^4.4.3"
},
"peerDependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"scripts": {
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"build": "yarn build:esm && yarn build:cjs",
"build:esm": "tsc",
"build:cjs": "tsc --module commonjs --outDir lib/cjs",
"prepare": "yarn build"
},
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
"types": "./lib/esm/index.d.ts"
}
输出yarn add ssh://<ssh-repo-address>
:
解决方案
推荐阅读
- apache-spark-sql - 我必须加入旧 DF 和新 DF,然后删除重复项,用更新的记录替换当前记录,并用旧 DF(DataFrame)添加新记录
- mongodb - 如何在 $lookup 字段中使用索引?
- python - 为什么不能以这种方式使用类attr?
- azure - Azure 可用性集与可用区
- angular - 动态列表上的角度禁用按钮
- node.js - 在不更改时间的情况下转换 TimeZone 日期对象
- go - golang 中的深度复制数据结构
- typo3 - 为另一个插件创建带有附加查询参数的重定向
- mysql - 具有多列条件的 SQL 分组
- php - 是否可以将两个 INSERT 语句放在一个 SQL 查询中