transpile .ts源文件没有依赖配置文件



我在typeScript中设置了我的node.js服务器:

/src
  /...
/dist
/node_modules
  /...
/tsconfig.json
/..other conf and typings files

/src中的某些文件从package.json中获取一些配置。这使得转板器在dist中创建此层次结构:

/dist
  /src
    /...js files
  /package.json

我的tsconfig.json如下:

{
    "compilerOptions": {
        "module": "commonjs",
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "target": "es6",
        "noImplicitAny": true,
        "moduleResolution": "node",
        "sourceMap": true,
        "outDir": "dist",
        "resolveJsonModule": true
    },
    "include": [
        "src/**/*",
        "typings-custom/**/*.ts"
    ],
    "exclude": [
        "./package.json"
    ]
}

我想知道是否可以从DIST文件夹中排除某些依赖项,因为相对路径在/src和/dist

之间保持相同

预先感谢。

我最终通过使用const {properta,propertyb} = require(" ../package.json"(解决了我的问题。有人可以解释为什么在这种情况下,转板器不复制文件?

最新更新