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

Invalidate cache on env var dependency #4264

Closed
ranisalt opened this issue Mar 4, 2020 · 0 comments · Fixed by #5112
Closed

Invalidate cache on env var dependency #4264

ranisalt opened this issue Mar 4, 2020 · 0 comments · Fixed by #5112

Comments

@ranisalt
Copy link
Contributor

ranisalt commented Mar 4, 2020

🙋 feature request

I have a configuration file that depends on env vars to select a couple values used throughout the system.

🤔 Expected Behavior

A file should be recompiled if it depends on environment variables that changed from the previous compilation.

😯 Current Behavior

If a file depends on environment variables that change, any file that depends on it will receive an outdated cached version and possibly the wrong values if they depend on that env var.

💁 Possible Solution

Maybe the cache should smartly tag which environment variables are used and store alongside the cached build, I think this is workable with a proxy to process.env

🔦 Context

I select the API endpoint to my requests depending on the environment, e.g. process.env.ENDPOINT === 'staging' ? 'staging.example.com' : 'example.com, and also a couple more values that depend on endpoint and build mode.

I can't use .env files since it is a monorepo and Parcel does not read them from workspaces (#4110) so I have been using cross-env to set them.

💻 Examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants