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

preserveSymlinks: Changes to target module are not propagated to symlink modules #30447

Open
aleclarson opened this issue Mar 16, 2019 · 5 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@aleclarson
Copy link

TypeScript Version: 3.4.0-dev.20190316

Search Terms:

  • preserveSymlinks, symlink, watch, change

Description:

I'm not familiar with how preserveSymlinks works internally, but it appears that symlink modules are not notified of changes to their target path.

My scenario is the following: I'm linking from node_modules/foo to a package that exists outside my project's root directory. When I update foo/src/index.ts, my project is not aware until I restart the TS server.

Related Issues: None.

@sheetalkamat
Copy link
Member

That would be intended behavior with --preserveSymlinks wherein we only look at the symlink and its change and not the target.

@aleclarson
Copy link
Author

That's frankly not good enough. The current behavior makes it much harder to iterate on packages when using a yarn link workflow. I'll assume Microsoft doesn't care about symlinks (most big companies don't for some reason) until this is fixed.

@aleclarson
Copy link
Author

Also, cross-package refactors are not possible when using symlinks.

@RyanCavanaugh RyanCavanaugh added Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript labels Apr 18, 2019
@ChristianIvicevic
Copy link

This is an issue I just came across myself in a workflow wherein I am using yarn workspaces in a monorepo. I am referencing a linked sub-package and ts-node had issues verifying my files since there was no declaration file. Hence I enabled preserveSymlinks and just recently noticed the issue that my main package isn't picking up any changes. Surprisingly enough, running tsc --watch and importing the generated output files made the parent aware of changes but I dislike this workflow since I do not want to transpile the library and rather import it directly.

@jacksteamdev
Copy link

jacksteamdev commented Jan 13, 2021

YMMV with different build tools. I'm using preserveSymlinks in a yarn workspace monorepo with success. Both ts-node-dev and webpack pick up changes to symlinked sub-packages.

Just make sure that main in the package.json of the linked sub-package points to the correct ts file. Webpack may also require additional configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

5 participants