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

fix(middleware): fix cache issue for import.meta.env in node_modules #17512

Closed
wants to merge 1 commit into from

Conversation

smeng9
Copy link
Contributor

@smeng9 smeng9 commented Jun 18, 2024

Closes #17505

Copy link

stackblitz bot commented Jun 18, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@smeng9
Copy link
Contributor Author

smeng9 commented Jun 19, 2024

We probably need to check if this PR will affect the performance of vite because it tries to perform the search of the string in all code returned.

We also need to check if import.meta.env is the only variable we should search for. It is possible there are other defined variables that should not be cached.

@ArnaudBarre
Copy link
Member

import.meta.env is Vite specific, I'm not sure we want it to be supported in node_modules

@smeng9
Copy link
Contributor Author

smeng9 commented Jun 29, 2024

I agree that the import.meta.env is vite specific.

However we should still make sure the caches are handled correctly.

@ArnaudBarre
Copy link
Member

No merging this kind of code will mean that we encourage the pattern, which we don't want.
And I'm not sure just disabling cache control is enough, you will probably need something else to ensure the chunk is re-computed.
And an adding extra string.includes on all deps code for eveyone just for a small edge case feel bad too.

What you need is to exclude the deps from pre-bundling to be treated more like user code: https://vitejs.dev/config/dep-optimization-options.html#optimizedeps-exclude

@smeng9
Copy link
Contributor Author

smeng9 commented Jun 29, 2024

This merge request is not optimal. We will apply your workaround for the edge case for now.

@smeng9 smeng9 closed this Jun 29, 2024
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.

If import.meta.env gets injected into files from node_modules deps, the file should not be cached in dev mode
2 participants