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

Monrepo with project references fails to compile #26689

Closed
raymondfeng opened this issue Aug 27, 2018 · 8 comments
Closed

Monrepo with project references fails to compile #26689

raymondfeng opened this issue Aug 27, 2018 · 8 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@raymondfeng
Copy link

TypeScript Version: 3.0.1

Search Terms:

Project references

Code

https://github.com/raymondfeng/learn-a/

Please follow the README.md to reproduce the problem.

npm i
npm run build

Expected behavior:

The build should be successful.

Actual behavior:

npm run build

> @ build /Users/rfeng/Projects/demos/learn-a
> tsc -b packages

packages/pkg2/src/index.ts:1:21 - error TS2307: Cannot find module '@ryancavanaugh/pkg1'.

1 import * as p1 from '@ryancavanaugh/pkg1';

Playground Link:

Related Issues:

@raymondfeng
Copy link
Author

@RyanCavanaugh Please help. The project was folked from your demo and the layout was changed to reflect our need. Thanks in advance.

@raymondfeng
Copy link
Author

@RyanCavanaugh Any update?

@raymondfeng
Copy link
Author

I did more experiment and this project layout works - https://github.com/raymondfeng/learn-a/tree/ts.

Please note that I use ts as the rootDir to contain src and test so that dist is NOT under rootDir. But the project layout is not so intuitive.

I guess the issue is related to the fact that outDir ("dist") is under the rootDir (".") and include/exclude in tsconfig.json is not being honored in this case.

@ajafff
Copy link
Contributor

ajafff commented Sep 5, 2018

@raymondfeng see discussion in #26867
Your issue is probably caused by outDir being located inside rootDir

@raymondfeng
Copy link
Author

@ajafff It seems so but my project layout should be legitimate as it works well with normal (without -b) tsc compilation.

@bajtos
Copy link

bajtos commented Sep 6, 2018

Interesting. Maybe we can try to split each package into two sub-projects, one for src and another for test, as described in http://www.typescriptlang.org/docs/handbook/project-references.html#an-example-project?

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Sep 17, 2018
@sheetalkamat
Copy link
Member

@raymondfeng Is this still issue? I cloned your repo and built it and it works.
Note in your repo, the include was inside compilerOptions which I moved out and it seems to work and build without any errors after that.

If this is still an issue, please provide more information

@sheetalkamat sheetalkamat added the Needs More Info The issue still hasn't been fully clarified label Sep 27, 2018
@raymondfeng
Copy link
Author

@sheetalkamat I fixed the tsconfig and upgraded to TypeScript 3.1.1. Everything seems to be work fine now! Thanks a lot. I'll try with a much larger project at https://github.com/strongloop/loopback-next

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

5 participants