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

Clean cache on every test run to make sure linked dependencies are up to date #7699

Merged
merged 9 commits into from
Feb 28, 2025

Conversation

pachhaibipin
Copy link
Contributor

@pachhaibipin pachhaibipin commented Feb 12, 2025

PR Description

Fixes:

  • Added optimizeDeps: { force: true, } to vitest config so as to force dependency pre-bundling, ignoring previously cached optimized dependencies.
  • By default, linked packages not inside node_modules are not pre-bundled. Used optimizeDeps.include option on vitest config to enforce pre-bundling of peer Dependencies.

@pachhaibipin pachhaibipin changed the title Bp/clear vite cache Clean cache on every test run to make sure linked dependencies are up to date Feb 12, 2025
@pachhaibipin pachhaibipin marked this pull request as ready for review February 12, 2025 22:32
@aruniverse
Copy link
Member

It's not easily apparent how your changes you made resolves the issue. Can you add links to your PR description to the vitest config and explain how it works/ how it's fixed now

@anmolshres98
Copy link
Contributor

From my experience, this configuration breaks debugging sometimes. Could you check to verify this change doesn't affect debugging. Thanks

@MichaelSwigerAtBentley
Copy link
Contributor

MichaelSwigerAtBentley commented Feb 13, 2025

From my experience, this configuration breaks debugging sometimes. Could you check to verify this change doesn't affect debugging. Thanks

Curious about this, in what way does it break?

I helped Bipin recreate the issue of tests failing because the vite cache was outdated, here is some details:

If you add a new class and export it from a repo barrel file then use that class in another repo's tests, the compiler will be totally happy and rebuild just fine, but if you do not run rush install --purge the vite cache will not be updated. It can end up using an older version of the package from the vite cache without the class you added, so when tests are ran a syntax error will be thrown at run time as it cant find the class you added in the outdated cached package.

Copy link
Contributor

@hl662 hl662 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anmolshres98 's issue with debugging is not related to the issue this PR is tackling. They were more pointing out how HMR/watch mode for vite doesn't watch for linked workspace deps in apps, like DTA and DPTA. I've created a separate issue for that, as an enhancement anyone can tackle, but it should not block this PR from going in, which we were able to reproduce the problem and verify the problem disappeared with this PR's change via @MichaelSwigerAtBentley

Copy link
Contributor

mergify bot commented Feb 25, 2025

This pull request is now in conflicts. Could you fix it @pachhaibipin? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

@pachhaibipin pachhaibipin merged commit 52e2075 into master Feb 28, 2025
16 checks passed
@pachhaibipin pachhaibipin deleted the bp/clear-vite-cache branch February 28, 2025 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clear out vite's cache across vitest-enabled packages
8 participants