-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Watch mode unresponsive to monorepo dependency changes #2532
Comments
Just realized that vite's build watch uses rollup's watch mode, not the vite dev server which vitest uses. I changed packageb to be a web app that the vitest dev server can serve, and confirmed that rebuilding the dependency as in case 1 (using |
This should be fixed in 0.31.2. |
Thanks for the update @sheremet-va - could you point me to the commit/PR in that release that resolves this (since my related PR is still open)? |
|
The issue is not fully resolved yet. I was able to remove the deps inline, but watchExclude still needs to be cleared (as mentioned earlier, easy to work around) and tests to not rerun on a dependency vite build (which is what my PR addresses) |
Updated Stackblitz: https://stackblitz.com/edit/vitest-dev-vitest-g1bmwe |
This is expected behavior.
I left comments in PR. |
Thanks - I'll revisit the PR once I have some available cycles |
On the other hand, it should also be removed from exclude at this point. We are moving away from treating named folders differently. |
I'm not sure what the situation is right now, but vitest does not respond to rebuilds in the case of a workspace package being rebuilt. I think, ideally, there would be a way to just have vitest directly access the source of the workspace package instead of needing to look at the built package at all. |
Just FYI I haven't dived into the full detail here (was snooping through existing issues to get help on something else!) but using an |
@ahayes91 thanks for the suggestion! It seems like it should work, but it is now just a bit more doubling up of code, and not having a single source of truth... |
Describe the bug
I'm attempting to use Vitest in a monorepo, and noticed there are issues getting vitest to re-run tests in watch mode when in-repo dependencies change. I've identified a few specific limitations (if these should be split out into separate issues, let me know):
**/dist/**
needs to be excluded fromwatchExclude
. This is fine, however I'd expect the default behavior to be smart enough to handle a monorepo where packages are built separately and imported into the package being testeddeps.inline
has to be set to true for changes to be picked up. Again, this is a reasonable workaround, but since vite "just works" for HMR and watch mode to work correctly, I wouldn't expect it to be necessary for vitest.awaitWriteFinish
andatomic
) as that seemed like it could affect this, but there was no change in behavior.Reproduction
Reproduce via https://stackblitz.com/edit/vitest-dev-vitest-fttlzd (ensure you have two terminals available). Stop any watch processes and reset file states between tests.
turbo run --cwd packages/packageb build:watch
in one terminalturbo run --cwd packages/packagea build
in the other terminalturbo run --cwd packages/packageb test
in one terminalturbo run --cwd packages/packageb test
in one terminalturbo run --cwd packages/packagea build
in the other terminaldeps: { inline: true },
(and/orwatchExclude: [],
) in packages/packageb/vite.config.tsturbo run --cwd packages/packageb test
in one terminalAlso note that if you run test 3 then 2 without stopping the test watcher, 2 will also fail to update.
System Info
The text was updated successfully, but these errors were encountered: