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

refactor: always use a cache directory #6415

Merged
merged 1 commit into from
Jan 16, 2022
Merged

refactor: always use a cache directory #6415

merged 1 commit into from
Jan 16, 2022

Conversation

ArnaudBarre
Copy link
Member

@ArnaudBarre ArnaudBarre commented Jan 7, 2022

Description

I'm currently working #4120 and I found that it adds some complexity to handle a nullable cacheDir. The only case it can happened is when there is no package.json detected, which seems a niche case. I suggest to use .vite as a cache directory in that case. We could also keep the default of node_modules/.vite but it makes less sense in that case.

Additional context

While looking for usage of cacheDir, I found that the caching of the certificate was dropped in #5514. I adding it back except if there was a reason to remove it (cc @patak-dev)

Note: This could technically be a breaking change for people using a global installation of Vite in projects that don't use a package manager.

patak-dev
patak-dev previously approved these changes Jan 7, 2022
Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

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

This looks good to me, and good catch about the certificate

@patak-dev patak-dev dismissed their stale review January 7, 2022 14:54

see comment

@patak-dev
Copy link
Member

@ArnaudBarre after a discussion with @dominikg, looks like global usage of vite may also be affected by this change.

Would you split this PR in two so we can merge the cache dir fix before releasing 2.8? Thanks!

@ArnaudBarre
Copy link
Member Author

Let me know about the decision for this change.

Another option as suggested by @gluck is to allow to disable caching. This would be easy (adding | false) to the cacheDir option and updating some messages. But it would start to conflict with server.force (and would keep adding a bit of complexity each time a new feature need to handle file system caching)

Copy link
Member

@Shinigami92 Shinigami92 left a comment

Choose a reason for hiding this comment

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

Code LGTM

@patak-dev
Copy link
Member

I'm leaning towards allowing to disable caching. We're only going to be able to discuss this in the next team meeting (next Friday), I'll bring the topic there.

@patak-dev
Copy link
Member

@ArnaudBarre @dominikg we talked about this PR in the last team meeting, and we concluded that it is a good idea to always have a cache. The DX in Vite is heavily damaged without it, and we don't have a real use case at hand for justifying the complexity of allowing Vite to run without write access during dev. Vite can also be safely run globally if the cache is held at the root of the Vite project. @ArnaudBarre would you resolve the conflicts and confirm that this looks good to you?

@Shinigami92
Copy link
Member

Just to be clear, this should land in a minor release due to this potential breaking change:
https://github.com/vitejs/vite/pull/6415/files#diff-db0f5f8dbaa7b2beda67cfc9f12bc0d22dedbbc7ed3d1935b3fdd5a3a7991350R125
Potentially this could be access from outside

@patak-dev
Copy link
Member

What do you mean by "potentially this could be access from outside"?

The idea is to merge it now that we are in the 2.8 beta period, so it will be included as part of a minor 👍🏼

@patak-dev patak-dev added this to the 2.8 milestone Jan 16, 2022
@Shinigami92
Copy link
Member

I just mean it is now a required parameter and typescript would report an error, nothing more
But as you say it is already planned to 2.8, everything is fine 🙂

@patak-dev
Copy link
Member

But resolveHttpsConfig is an internal function, no?

@Shinigami92
Copy link
Member

export async function resolveHttpsConfig
^^^^^^

@patak-dev
Copy link
Member

That function is only imported as an internal utility by other files, or maybe I'm not seeing where it is exported to the user

@patak-dev patak-dev merged commit fb7ba53 into vitejs:main Jan 16, 2022
@Shinigami92
Copy link
Member

@ArnaudBarre ArnaudBarre deleted the non-nullable-cache-dir branch January 18, 2022 22:05
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.

4 participants