2021-07-29

Why is the Typescript compiler compiling outside of my package?

I have a monorepo with several packages and one library shared among them:

root/
  one/
  two/
  three/
  shared-lib/
    package.json
    tsconfig.json

tsconfig.json:

{
  "compilerOptions": {
    "rootDir": "src",
    "outDir": "build",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "moduleResolution": "node",
    "declaration": true,
    "declarationMap": true,
    "skipLibCheck": true,
    "target": "es5",
    "module": "esnext",
    "jsx": "react"
  },
  "include": [
    "src"
  ],
  "exclude": [
    "**/node_modules/**",
    "node_modules",
    "build"
  ]
}

When I try to compile my library, I get errors in packages one, two, and three.

$ cd root/shared-lib
$ yarn run tsc -p tsconfig.json

../one/some/module/up/in/here:14:25 - error TS2307: Cannot find module ...

Why am I seeing those errors here? Why is tsc trying to compile stuff outside of the package I told it to compile?



from Recent Questions - Stack Overflow https://ift.tt/3BL1qWl
https://ift.tt/eA8V8J

No comments:

Post a Comment