Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project reference isn't working if rootDir is set #868

Closed
alfaproject opened this issue Nov 10, 2018 · 3 comments
Closed

Project reference isn't working if rootDir is set #868

alfaproject opened this issue Nov 10, 2018 · 3 comments

Comments

@alfaproject
Copy link

Expected Behaviour

A project reference that has a rootDir set should work properly

Actual Behaviour

'lambda-common' has outDir set to ./dist and rootDir set to ./src and 'lambda-graphql' references 'lambda-common':

Error: Could not find output JavaScript file for input ../lambda-common/src/index.ts (looked at ../lambda-common/dist/src/index.js).
The input file is part of a project reference located at ../lambda-common/tsconfig.json, so ts-loader is looking for the project’s pre-built output on disk. Try running `tsc --build` to build project references.
    at successLoader (/lambda-graphql/node_modules/ts-loader/dist/index.js:46:19)
    at Object.loader (/lambda-gaming/lambda-graphql/node_modules/ts-loader/dist/index.js:22:12)

ts-loader is looking for dist/src/index.js instead of dist/index.js

Steps to Reproduce the Problem

Create a project reference to a project that sets rootDir to some child folder like ./src, compile with tsc -b and then attempt to use ts-loader on the parent project.

@johnnyreilly
Copy link
Member

Question: are you running on Windows? If so you may be bumping on a known issue:

outDir Windows problemo. At the moment, composite projects built using the outDir compiler option cannot be consumed using ts-loader on Windows. If you try to, ts-loader throws a "has not been built from source file" error. We don't know why yet; it's possible there's a bug in tsc. It's more likely there's a bug in ts-loader. Hopefully it's going to get solved at some point. (Hey, maybe you're the one to solve it!) Either way, we didn't want to hold back from releasing. So if you're building on Windows then avoid building composite projects using outDir.

See https://github.com/TypeStrong/ts-loader/blob/master/README.md#projectreferences-boolean-defaultfalse

cc @andrewbranch

@alfaproject
Copy link
Author

No, I'm running on macOS, but I don't think the issue is in outDir. The problem seems to be in rootDir.

As you can see in my example, outDir is being worked correctly, but rootDir is not being taken into consideration.

@johnnyreilly
Copy link
Member

Hmmm. If you could create a repro repo that could help someone getting started looking into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants