在 Node.JS 项目中,项目根目录中有两个目录包含 .ts 文件 -
src
和 test
。 src/index.js 导入 module-alias/register。每个被测试/导入模块别名/注册的文件。
这是我的 tsconfig.json:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"sourceMap": true,
"outDir": "./dist",
"strict": true,
"strictNullChecks": true,
"strictPropertyInitialization": false,
"resolveJsonModule": true,
"moduleResolution": "node",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"@/*": [ "./src/*" ],
}
},
"include": ["test/**/*", "src/**/*", "test"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
我的 package.json 中的节点级模块别名:
"_moduleAliases": {
"@": "./src"
},
每当我执行
rm -rf dist && yarn tsc
操作时,都会创建 dist
目录,其中包含两个子目录 - src
和 test
。我只想要编译后的 (.js) src
内容,而不是 src 目录本身。至于test目录,我根本就不要了