moltar / projen-turborepo

Projen project type for Turborepo monorepo setup.
https://npm.im/projen-turborepo
MIT License
26 stars 2 forks source link

dependency project path always points to src #13

Open miekassu opened 2 years ago

miekassu commented 2 years ago

when projen generates paths to project tsconfig.ts it based speficied package dependencies, it always points path to src

like:

    "paths": {
      "@nordft/core-prismic": [
        "../../packages/core-prismic/src"
      ],
      "@nordft/core-ui": [
        "../../packages/core-ui/src"
      ]
    }

this throws an error:

Type error: File '/Users/kasperhamalainen/Code/nordft/nordft-monorepo/packages/core-ui/src/index.ts' is not under 'rootDir' '/Users/kasperhamalainen/Code/nordft/nordft-monorepo/apps/nordft-core-frontend'. 'rootDir' is expected to contain all source files.

instead of, this works:

    "paths": {
      "@nordft/core-prismic": [
        "../../packages/core-prismic/*"
      ],
      "@nordft/core-ui": [
        "../../packages/core-ui/*"
      ]
    }

l ooks like projen generated ../src directory in path, no matter what would have been configured in dependency package tsconfig.ts, like outDit or rootDir.

any ideas?

moltar commented 2 years ago

This package indeed hard-codes src as the dir where the source code lives. Because this is what is, I think, is also hard-coded in the projen TypeScript project type. But if you know of a way to get this value from the projen TypeScript type, we don't have to hard-code.

So your project does not put source files into the src/* dir, is that it?

miekassu commented 2 years ago

yes, source files lives under src/*, but build files are in different folder, for example in lib. This is defined in sub-project tsconfig.

I tested, defining lib path works:

    "paths": {
      "@nordft/core-prismic": [
        "../../packages/core-prismic/lib"
      ],
      "@nordft/core-ui": [
        "../../packages/core-ui/lib"
      ]
    }

so in this case, during build, parent project is looking for the sub-project build files, instead of source files. why this, I'm not sure?

to specify, libraries are imported correctly, when I'm running project (nextjs) locally and dependencies are resolved in runtime. it only fails when I build.

moltar commented 2 years ago

Could you please create a small repro project with a breakage?

You can use this demo to get started from to make it easier: https://github.com/moltar/projen-turborepo-test

miekassu commented 2 years ago

here you go https://github.com/miekassu/projen-turborepo-test

moltar commented 2 years ago

I don't think that fixed the issue :/