-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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(resolve): separate package cache per environment #18319
base: main
Are you sure you want to change the base?
Conversation
Run & review this pull request in StackBlitz Codeflow. |
@@ -64,6 +65,7 @@ export class PartialEnvironment { | |||
this.name = name | |||
this._topLevelConfig = topLevelConfig | |||
this._options = options | |||
const packageCache: PackageCache = new Map() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is going to far. The PackageCache has two mixed caches:
a. The path -> PackageData
cache
b. the resolved cache in each PackageData
(the getResolvedCache
/setResolvedCache
pair)
We still need (a) to be per-config and not per-environment. This cache doesn't depend on environment-specific options. We need to make only (b) per-environment.
What I was thinking is that PackageCache
will remain as-is, the cache from (b) is removed from PackageData
. And a new ResolvedCache
is created per-environment that will expose resolvedCache.get(packageData, key)
. This cache is passed to the resolve plugin that is the only place where it is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC making (b) per-environment is not enough. It also needs to be separated whether it's a resolve for require
or import
. Otherwise, #16631 would be still broken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing something. I would expect the PackageData
(without the Resolved Cache part) would be the same for both in that case 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Splitting entire PackageData
seems redundant. Let me iterate a bit more.
Should we go with #18302 for now? I can follow up separately with your idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC making (b) per-environment is not enough. It also needs to be separated whether it's a resolve for
require
orimport
. Otherwise, #16631 would be still broken.
For this, I was thinking we still need to expand isRequire
as a cache key, which we aren't doing. But, for other flags conditions, mainFields, ...
, we can assume those are static per environment, so we don't need to include it as cache key, which was the heavy part of #18302
Description
Alternative approach #18302 (comment)
This PR separates
PackageCache
per environment usingenvironment.config
proxy. I replacedconfig.packageCache
withenvironment.config.packageCache
through the code base (seems straight-forward exceptwatchPackageDataPlugin
).