0

I set my node.js server in typescript this way:

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

Some files in /src get some configuration from package.json for example. This makes the transpiler creates this hierarchy in dist:

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

My tsconfig.json is as follows:

{
    "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"
    ]
}

I wonder if it is possible to exclude some dependencies from the dist folder as the relative path stays the same between /src and /dist

Thanks in advance.

cartman
  • 189
  • 1
  • 2
  • 17
  • Could you please post your `tsconfig.json` file? And I suspect that if your source files are relying on values in your `package.json`, it will need to go in the `/dist` directory so that the client can access it. – joshwilsonvu Jul 02 '19 at 13:46
  • I edited my question with tsconfig. The client doesn't access it as this is the server. Those values are just used during the server launch – cartman Jul 02 '19 at 14:00

1 Answers1

0

I finally resolved my issue by using const { propertyA, propertyB } = require("../package.json"); Someone could please explain why the transpiler doesn't copy the file in this case?

cartman
  • 189
  • 1
  • 2
  • 17