最近开始使用edBuild,发现它简单,快捷,易于上机。
当我在没有监视的情况下运行我的esBuild build命令时,我可以看到类型文件是成功创建的-- .d.ts文件。
当手表运行时,不会生成这些文件。
package.json:
"scripts": {
"ts-types": " tsc --emitDeclarationOnly --outDir dist",
"build": " node ./esbuild.js && npm run ts-types",
"postbuild": "npm run ts-types"
}esbuild.js
.build({
entryPoints: ['/index.ts'],
outdir: 'dist',
format: 'cjs',
watch: {
onRebuild(err, result) {
if(err) log('error')
else log('succes')
}
}
})
.then(result => {
log('succes')
})
.catch(() => process.exit(1));如何在更改时运行、监视和重新创建.d.ts文件?
发布于 2022-07-13 13:32:01
ESBuild不支持生成类型声明。
您正在使用tsc实际生成类型声明。
您应该能够从运行此操作的内部节点启动进程。与此类似的是:
const {exec} = require('child_process');
...
.build({
entryPoints: ['/index.ts'],
outdir: 'dist',
format: 'cjs',
watch: {
onRebuild(err, result) {
if(err) log('error')
else {
exec("npm run ts-types");
}
}
}
})
.then(result => {
log('succes')
})
.catch(() => process.exit(1));https://stackoverflow.com/questions/72965551
复制相似问题