Skip to content

When monorepo like packages are linked through symlink and are not built editor cant resolve modules #34723

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

Closed
sheetalkamat opened this issue Oct 24, 2019 · 4 comments · Fixed by #34743
Labels
Fix Available A PR has been opened for this issue

Comments

@sheetalkamat
Copy link
Member

@sheetalkamat - I am trying this out and noticed that it doesn't work in the case of things that are imported from the outDir rather than the src (in the case of a monorepo):

image

For a quick way to verify this, I prepared a monorepo for you to check it out:

https://github.com/kenotron/TypeScriptMonoRepo/tree/ts3.7

Things work okay if you do "yarn && yarn build", but if I understand this feature, it is meant to address the case where you can start editing in VS Code with Intellisense even before having to build something because we're traversing source rather than output.

Originally posted by @kenotron in #32028 (comment)

@sheetalkamat
Copy link
Member Author

Have investigated this and currently we are not handling symlinks.. If the resolution happens to be looking at the output path for the referenced project, we make sure that the answer to fileExists and directory Exits is true so that the resolution uses the output file even when its not present.
In case of symlinks those paths are different eg. its looking for outDir in "c:/temp/TypeScriptMonoRepo/node_modules/b/lib" instead of "c:/temp/TypeScriptMonoRepo/packages/b/lib". If resolution had asked for the later we would answer yes and resolution will succeed and we will use source file instead.

@kenotron
Copy link
Member

How hard is it to provide a flag here to traverse symlinks? I think this would enable a lot of monorepos to use this feature directly without resorting to the hack of the main field being src/index.ts

@kiprasmel
Copy link

This applies to yarn workspaces (since symlinks are used under the cover) and it would be extremely useful to have them supported. Currently we still have to build manually..

@kenotron
Copy link
Member

kenotron commented Oct 25, 2019

@sarpik - the only workaround I see currently is to use the main field to point to a single entry point index. I currently have to create a script to change this at pre-publish time

Update: nevermind, @sheetalkamat actually has a good fix for this and I've verified that this WORKS

@sheetalkamat sheetalkamat added the Fix Available A PR has been opened for this issue label Oct 25, 2019
typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this issue Oct 28, 2019
Component commits:
06fda26 Fix incorrect outDir usage instead of out

66f1a79 Handle symlinks of packages in mono repo like packages Fixes microsoft#34723
@sheetalkamat sheetalkamat added this to the TypeScript 3.7.2 milestone Oct 28, 2019
DanielRosenwasser pushed a commit that referenced this issue Oct 28, 2019
Component commits:
06fda26 Fix incorrect outDir usage instead of out

66f1a79 Handle symlinks of packages in mono repo like packages Fixes #34723
sheetalkamat added a commit that referenced this issue Oct 29, 2019
…os to use source files instead of output d.ts from project reference (#34743)

* Fix incorrect outDir usage instead of out

* Handle symlinks of packages in mono repo like packages
Fixes #34723

* Added clarified comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Available A PR has been opened for this issue
Projects
None yet
3 participants