Merge pull request #9425 from webpack/bugfix/no-resolve-options

fix #9424
This commit is contained in:
Tobias Koppers 2019-07-17 15:58:03 +02:00 committed by GitHub
commit 4cac06644b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -10,6 +10,8 @@ const { cachedCleverMerge } = require("./util/cleverMerge");
/** @typedef {import("enhanced-resolve").Resolver} Resolver */
const EMTPY_RESOLVE_OPTIONS = {};
module.exports = class ResolverFactory extends Tapable {
constructor() {
super();
@ -40,13 +42,11 @@ module.exports = class ResolverFactory extends Tapable {
return true;
}
});
this.cache1 = new WeakMap();
this.cache2 = new Map();
}
get(type, resolveOptions) {
const cachedResolver = this.cache1.get(resolveOptions);
if (cachedResolver) return cachedResolver();
resolveOptions = resolveOptions || EMTPY_RESOLVE_OPTIONS;
const ident = `${type}|${JSON.stringify(resolveOptions)}`;
const resolver = this.cache2.get(ident);
if (resolver) return resolver;