-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
Type changes to symlinked module files in a monorepo are not updated after the initial launch #557
Comments
Could you send your webpack setup or create a reproduction repository? I tested symlinks on my local machine and it works for me, but probably it's due to a different configuration/use-case. |
I discovered the way to fix this issue is to use the
This fix does not appear to be consistent. I tried it in my reproduction repo and was not able to have it work 100% of the time. There could be some combination of default Vue CLI/Webpack behavior here (like caching) that might be at play. |
Here's the repoduction repo. https://github.com/J-Rojas/ts-vue-hello-world Steps:Install
Switch to error branch.
Run the serve command. You should see an error for a missing
While running the serve command, switch to the new branch that should add the missing function.
The serve will update, but the function definition will not be picked up. If you kill the serve command and launch again, the error should be gone. |
I also encountered the same problem. Environment
|
@J-Rojas thanks for the reproduction repository! I'm not sure when I will have some time for digging into this issue - I'm going on 2 week vacation in few days. So if not this week, then earliest is in 3 weeks |
I seem to have the same problem, I have shared library written in TypeScript which is build via watch and the output is placed in lib directory. The library is npm link'd into my Webpack application. When the lib directory is changed a rebuild of the app is triggered type changes (like a new function) are not picked up, the app itself can definitely use the function (like, I saw a the output of console.log used in that function) when you ignore the type checking errors. |
having the same issue. in my case it even worse, as the package I'm trying to watch is already "built" and I'm exporting the {
"compilerOptions": {
"paths": {
"@pkg/enums": ["../packages/enums/src"],
},
},
"references": [
{ "path": "../packages/enums/src" }
],
"include": [
"../packages/enums/src",
"src/**/*"
]
} const config = {
resolve : {
'@pkg/enums': path.join(__dirname, '../../', 'packages/enums/src'),
}
} |
I was trying to fix that, but no progress so far :/ I can reproduce the issue, but I'm not sure why it behaves like this... I will try again in few days |
@piotr-oles Thanks. reproducing is 50% of the solution, so that's great news :) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
bump |
Any luck with this? |
moved to vite . works great with monorepo and ts. it listens to changes in each imported package |
Could you test with the latest version? I found some bugs and fixed them :) |
Still not working: "webpack": "5.68.0", ts-config has Project has symlinked node_module that points to |
And your code doesn't use vue, right? |
I am looking at the same code base as @Pantura vue is not used I digged into source code of this plugin, found that on file change, fileWatcherCallbacks is undefined initially callback is assigned properly some debugging output:
|
I missed obvious detail, that callback added with normalized path |
Ok, so we should use realpath here. The issue can be when we delete symlink - then we should invoke fileDeleted, but we will not be able to get realpath. Because of that, I think we would need to store some in-memory cache of mapping from linked modules to absolute paths. |
I wonder if it's appropriate to always use realpath, I think webpack does it by default |
if I use this realPath in createWatcher, typechecking works function createWatcher<TCallback>(watchersMap: Map<string, TCallback[]>, path: string, callback: TCallback) {
const normalizedPath = realFileSystem.realPath(path); why initially watcher gets this "incorrect" path ? ("app/node_modules/redacted/selector.ts") |
I've created a reproducible small example https://github.com/aovchinn/test-fork-ts-checker/tree/main |
@aovchinn I created a PR that should fix that. It fixes the issue in the repo you created :) Thanks for your help! |
Could you check if the newest version works correctly in your case? |
yes, it is working, thanks 👍 |
I'm closing this issue then :) |
Current behavior
Within a monorepo workspace with symlinked packages, changes to files in the symlinked modules are detected, however the types are not dynamically updated during a dev server session.
For example, the following code compiles correctly after the initial launch of webpack.
However incremental changes like the ones below will break.
Expected behavior
Changes to types should be updated dynamically across package boundaries in a monorepo.
Steps to reproduce the issue
See the above example.
Issue reproduction repository
N/A... code above might be enough for a repro.
Environment
The text was updated successfully, but these errors were encountered: