mirror of https://github.com/webpack/webpack.git
rework how byDependency applied
remove dependencyType parameter for resolver factory add dependencyType option in enhanced resolve options
This commit is contained in:
parent
2f7510abd2
commit
d2a08e3cc8
|
@ -10,14 +10,19 @@ const { AsyncSeriesWaterfallHook, SyncWaterfallHook } = require("tapable");
|
|||
const ContextModule = require("./ContextModule");
|
||||
const ModuleFactory = require("./ModuleFactory");
|
||||
const ContextElementDependency = require("./dependencies/ContextElementDependency");
|
||||
const { cachedSetProperty } = require("./util/cleverMerge");
|
||||
const { join } = require("./util/fs");
|
||||
|
||||
/** @typedef {import("./Module")} Module */
|
||||
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
|
||||
/** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
|
||||
/** @typedef {import("./ResolverFactory")} ResolverFactory */
|
||||
/** @typedef {import("./dependencies/ContextDependency")} ContextDependency */
|
||||
|
||||
module.exports = class ContextModuleFactory extends ModuleFactory {
|
||||
/**
|
||||
* @param {ResolverFactory} resolverFactory resolverFactory
|
||||
*/
|
||||
constructor(resolverFactory) {
|
||||
super();
|
||||
this.hooks = Object.freeze({
|
||||
|
@ -109,8 +114,15 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
|
|||
|
||||
const contextResolver = this.resolverFactory.get(
|
||||
"context",
|
||||
resolveOptions || undefined,
|
||||
dependencies.length > 0 ? dependencies[0].category : undefined
|
||||
resolveOptions
|
||||
? dependencies.length > 0
|
||||
? cachedSetProperty(
|
||||
resolveOptions,
|
||||
"dependencyType",
|
||||
dependencies[0].category
|
||||
)
|
||||
: resolveOptions
|
||||
: undefined
|
||||
);
|
||||
const loaderResolver = this.resolverFactory.get("loader");
|
||||
|
||||
|
|
|
@ -22,13 +22,16 @@ const BasicMatcherRulePlugin = require("./rules/BasicMatcherRulePlugin");
|
|||
const RuleSetCompiler = require("./rules/RuleSetCompiler");
|
||||
const UseEffectRulePlugin = require("./rules/UseEffectRulePlugin");
|
||||
const LazySet = require("./util/LazySet");
|
||||
const { cachedCleverMerge } = require("./util/cleverMerge");
|
||||
const { cachedCleverMerge, cachedSetProperty } = require("./util/cleverMerge");
|
||||
const { join } = require("./util/fs");
|
||||
|
||||
/** @typedef {import("../declarations/WebpackOptions").ModuleOptions} ModuleOptions */
|
||||
/** @typedef {import("./Generator")} Generator */
|
||||
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
|
||||
/** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
|
||||
/** @typedef {import("./ResolverFactory")} ResolverFactory */
|
||||
/** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */
|
||||
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
||||
|
||||
/**
|
||||
* @typedef {Object} ResolveData
|
||||
|
@ -126,6 +129,13 @@ const ruleSetCompiler = new RuleSetCompiler([
|
|||
]);
|
||||
|
||||
class NormalModuleFactory extends ModuleFactory {
|
||||
/**
|
||||
* @param {Object} param params
|
||||
* @param {string=} param.context context
|
||||
* @param {InputFileSystem} param.fs file system
|
||||
* @param {ResolverFactory} param.resolverFactory resolverFactory
|
||||
* @param {ModuleOptions} param.options options
|
||||
*/
|
||||
constructor({ context, fs, resolverFactory, options }) {
|
||||
super();
|
||||
this.hooks = Object.freeze({
|
||||
|
@ -246,8 +256,15 @@ class NormalModuleFactory extends ModuleFactory {
|
|||
const loaderResolver = this.getResolver("loader");
|
||||
const normalResolver = this.getResolver(
|
||||
"normal",
|
||||
resolveOptions,
|
||||
dependencies.length > 0 ? dependencies[0].category : undefined
|
||||
resolveOptions
|
||||
? dependencies.length > 0
|
||||
? cachedSetProperty(
|
||||
resolveOptions,
|
||||
"dependencyType",
|
||||
dependencies[0].category
|
||||
)
|
||||
: resolveOptions
|
||||
: undefined
|
||||
);
|
||||
|
||||
/** @type {string} */
|
||||
|
@ -690,12 +707,8 @@ class NormalModuleFactory extends ModuleFactory {
|
|||
return generator;
|
||||
}
|
||||
|
||||
getResolver(type, resolveOptions, category) {
|
||||
return this.resolverFactory.get(
|
||||
type,
|
||||
resolveOptions || EMPTY_OBJECT,
|
||||
category
|
||||
);
|
||||
getResolver(type, resolveOptions) {
|
||||
return this.resolverFactory.get(type, resolveOptions || EMPTY_OBJECT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,9 @@ const { HookMap, SyncHook, SyncWaterfallHook } = require("tapable");
|
|||
const { cachedCleverMerge } = require("./util/cleverMerge");
|
||||
|
||||
/** @typedef {import("enhanced-resolve").Resolver} Resolver */
|
||||
/** @typedef {import("../declarations/WebpackOptions").ResolveOptions} ResolveOptions */
|
||||
|
||||
/** @typedef {ResolveOptions & {dependencyType?: string}} EnhancedResolveOptions */
|
||||
/**
|
||||
* @typedef {Object} WithOptions
|
||||
* @property {function(Object): ResolverWithOptions} withOptions create a resolver with additional/different options
|
||||
|
@ -29,19 +31,13 @@ const EMPTY_RESOLVE_OPTIONS = {};
|
|||
module.exports = class ResolverFactory {
|
||||
constructor() {
|
||||
this.hooks = Object.freeze({
|
||||
/** @type {HookMap<SyncWaterfallHook<[Object, string]>>} */
|
||||
/** @type {HookMap<SyncWaterfallHook<[EnhancedResolveOptions]>>} */
|
||||
resolveOptions: new HookMap(
|
||||
() => new SyncWaterfallHook(["resolveOptions", "dependencyType"])
|
||||
() => new SyncWaterfallHook(["resolveOptions"])
|
||||
),
|
||||
/** @type {HookMap<SyncHook<[Resolver, Object, Object, string]>>} */
|
||||
/** @type {HookMap<SyncHook<[Resolver, ResolveOptions, EnhancedResolveOptions]>>} */
|
||||
resolver: new HookMap(
|
||||
() =>
|
||||
new SyncHook([
|
||||
"resolver",
|
||||
"resolveOptions",
|
||||
"userResolveOptions",
|
||||
"dependencyType"
|
||||
])
|
||||
() => new SyncHook(["resolver", "resolveOptions", "userResolveOptions"])
|
||||
)
|
||||
});
|
||||
/** @type {Map<string, ResolverCache>} */
|
||||
|
@ -50,23 +46,17 @@ module.exports = class ResolverFactory {
|
|||
|
||||
/**
|
||||
* @param {string} type type of resolver
|
||||
* @param {Object=} resolveOptions options
|
||||
* @param {string=} dependencyType dependency type if any
|
||||
* @param {EnhancedResolveOptions=} resolveOptions options
|
||||
* @returns {ResolverWithOptions} the resolver
|
||||
*/
|
||||
get(
|
||||
type,
|
||||
resolveOptions = EMPTY_RESOLVE_OPTIONS,
|
||||
dependencyType = "unknown"
|
||||
) {
|
||||
const typedCacheId = `${type}-${dependencyType}`;
|
||||
let typedCaches = this.cache.get(typedCacheId);
|
||||
get(type, resolveOptions = EMPTY_RESOLVE_OPTIONS) {
|
||||
let typedCaches = this.cache.get(type);
|
||||
if (!typedCaches) {
|
||||
typedCaches = {
|
||||
direct: new WeakMap(),
|
||||
stringified: new Map()
|
||||
};
|
||||
this.cache.set(typedCacheId, typedCaches);
|
||||
this.cache.set(type, typedCaches);
|
||||
}
|
||||
const cachedResolver = typedCaches.direct.get(resolveOptions);
|
||||
if (cachedResolver) {
|
||||
|
@ -78,7 +68,7 @@ module.exports = class ResolverFactory {
|
|||
typedCaches.direct.set(resolveOptions, resolver);
|
||||
return resolver;
|
||||
}
|
||||
const newResolver = this._create(type, resolveOptions, dependencyType);
|
||||
const newResolver = this._create(type, resolveOptions);
|
||||
typedCaches.direct.set(resolveOptions, newResolver);
|
||||
typedCaches.stringified.set(ident, newResolver);
|
||||
return newResolver;
|
||||
|
@ -86,15 +76,16 @@ module.exports = class ResolverFactory {
|
|||
|
||||
/**
|
||||
* @param {string} type type of resolver
|
||||
* @param {Object} resolveOptions options
|
||||
* @param {string} dependencyType dependency type if any
|
||||
* @param {EnhancedResolveOptions} enhancedResolveOptions options
|
||||
* @returns {ResolverWithOptions} the resolver
|
||||
*/
|
||||
_create(type, resolveOptions, dependencyType) {
|
||||
const originalResolveOptions = { ...resolveOptions };
|
||||
resolveOptions = this.hooks.resolveOptions
|
||||
_create(type, enhancedResolveOptions) {
|
||||
/** @type {EnhancedResolveOptions} */
|
||||
const originalResolveOptions = { ...enhancedResolveOptions };
|
||||
/** @type {ResolveOptions} */
|
||||
const resolveOptions = this.hooks.resolveOptions
|
||||
.for(type)
|
||||
.call(resolveOptions, dependencyType);
|
||||
.call(enhancedResolveOptions);
|
||||
const resolver = /** @type {ResolverWithOptions} */ (Factory.createResolver(
|
||||
resolveOptions
|
||||
));
|
||||
|
@ -107,13 +98,13 @@ module.exports = class ResolverFactory {
|
|||
const cacheEntry = childCache.get(options);
|
||||
if (cacheEntry !== undefined) return cacheEntry;
|
||||
const mergedOptions = cachedCleverMerge(originalResolveOptions, options);
|
||||
const resolver = this.get(type, mergedOptions, dependencyType);
|
||||
const resolver = this.get(type, mergedOptions);
|
||||
childCache.set(options, resolver);
|
||||
return resolver;
|
||||
};
|
||||
this.hooks.resolver
|
||||
.for(type)
|
||||
.call(resolver, resolveOptions, originalResolveOptions, dependencyType);
|
||||
.call(resolver, resolveOptions, originalResolveOptions);
|
||||
return resolver;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -46,18 +46,31 @@ const DefaultStatsPrinterPlugin = require("./stats/DefaultStatsPrinterPlugin");
|
|||
|
||||
const { cachedCleverMerge, DELETE } = require("./util/cleverMerge");
|
||||
|
||||
/** @typedef {import("../declarations/WebpackOptions").ResolveOptions} ResolveOptions */
|
||||
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
|
||||
/** @typedef {import("./Compiler")} Compiler */
|
||||
/** @typedef {import("./ResolverFactory").EnhancedResolveOptions} EnhancedResolveOptions */
|
||||
|
||||
// need to be hoisted on module level for caching identity
|
||||
const noByDependency = {
|
||||
byDependency: DELETE
|
||||
byDependency: DELETE,
|
||||
dependencyType: DELETE
|
||||
};
|
||||
|
||||
const applyByDependency = (options, depType) => {
|
||||
if (!options.byDependency) return options;
|
||||
const depDependentOptions = options.byDependency[depType];
|
||||
options = cachedCleverMerge(options, noByDependency);
|
||||
/**
|
||||
* @param {EnhancedResolveOptions} enhancedResolveOptions enhanced options
|
||||
* @returns {ResolveOptions} merged options
|
||||
*/
|
||||
const applyByDependency = enhancedResolveOptions => {
|
||||
if (!enhancedResolveOptions.byDependency) return enhancedResolveOptions;
|
||||
const options = /** @type {ResolveOptions} */ (cachedCleverMerge(
|
||||
enhancedResolveOptions,
|
||||
noByDependency
|
||||
));
|
||||
if (!enhancedResolveOptions.dependencyType) return options;
|
||||
|
||||
const depDependentOptions =
|
||||
enhancedResolveOptions.byDependency[enhancedResolveOptions.dependencyType];
|
||||
if (!depDependentOptions) return options;
|
||||
return cachedCleverMerge(options, depDependentOptions);
|
||||
};
|
||||
|
@ -608,35 +621,32 @@ class WebpackOptionsApply extends OptionsApply {
|
|||
}
|
||||
compiler.resolverFactory.hooks.resolveOptions
|
||||
.for("normal")
|
||||
.tap("WebpackOptionsApply", (resolveOptions, dependencyType) => {
|
||||
.tap("WebpackOptionsApply", resolveOptions => {
|
||||
return {
|
||||
fileSystem: compiler.inputFileSystem,
|
||||
...applyByDependency(
|
||||
cachedCleverMerge(options.resolve, resolveOptions),
|
||||
dependencyType
|
||||
cachedCleverMerge(options.resolve, resolveOptions)
|
||||
)
|
||||
};
|
||||
});
|
||||
compiler.resolverFactory.hooks.resolveOptions
|
||||
.for("context")
|
||||
.tap("WebpackOptionsApply", (resolveOptions, dependencyType) => {
|
||||
.tap("WebpackOptionsApply", resolveOptions => {
|
||||
return {
|
||||
fileSystem: compiler.inputFileSystem,
|
||||
resolveToContext: true,
|
||||
...applyByDependency(
|
||||
cachedCleverMerge(options.resolve, resolveOptions),
|
||||
dependencyType
|
||||
cachedCleverMerge(options.resolve, resolveOptions)
|
||||
)
|
||||
};
|
||||
});
|
||||
compiler.resolverFactory.hooks.resolveOptions
|
||||
.for("loader")
|
||||
.tap("WebpackOptionsApply", (resolveOptions, dependencyType) => {
|
||||
.tap("WebpackOptionsApply", resolveOptions => {
|
||||
return {
|
||||
fileSystem: compiler.inputFileSystem,
|
||||
...applyByDependency(
|
||||
cachedCleverMerge(options.resolveLoader, resolveOptions),
|
||||
dependencyType
|
||||
cachedCleverMerge(options.resolveLoader, resolveOptions)
|
||||
)
|
||||
};
|
||||
});
|
||||
|
|
|
@ -201,10 +201,9 @@ class ResolverCachePlugin {
|
|||
* @param {Resolver} resolver the resolver
|
||||
* @param {Object} options resolve options
|
||||
* @param {Object} userOptions resolve options passed by the user
|
||||
* @param {string} category category
|
||||
* @returns {void}
|
||||
*/
|
||||
(resolver, options, userOptions, category) => {
|
||||
(resolver, options, userOptions) => {
|
||||
if (options.cache !== true) return;
|
||||
const optionsIdent = objectToString(userOptions, false);
|
||||
const cacheWithContext =
|
||||
|
@ -220,7 +219,7 @@ class ResolverCachePlugin {
|
|||
if (request._ResolverCachePluginCacheMiss || !fileSystemInfo) {
|
||||
return callback();
|
||||
}
|
||||
const identifier = `/resolve/${type}${category}${optionsIdent}${objectToString(
|
||||
const identifier = `/resolve/${type}${optionsIdent}${objectToString(
|
||||
request,
|
||||
!cacheWithContext
|
||||
)}`;
|
||||
|
|
|
@ -21,8 +21,11 @@ const { parseRequiredVersion, isRequiredVersion } = require("./utils");
|
|||
/** @typedef {import("../../declarations/plugins/sharing/ConsumeSharedPlugin").ConsumeSharedPluginOptions} ConsumeSharedPluginOptions */
|
||||
/** @typedef {import("../../declarations/plugins/sharing/ConsumeSharedPlugin").ConsumesConfig} ConsumesConfig */
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
/** @typedef {import("../ResolverFactory").EnhancedResolveOptions} EnhancedResolveOptions */
|
||||
/** @typedef {import("./ConsumeSharedModule").ConsumeOptions} ConsumeOptions */
|
||||
|
||||
/** @type {EnhancedResolveOptions} */
|
||||
const RESOLVE_OPTIONS = { dependencyType: "esm" };
|
||||
const PLUGIN_NAME = "ConsumeSharedPlugin";
|
||||
|
||||
class ConsumeSharedPlugin {
|
||||
|
@ -114,8 +117,7 @@ class ConsumeSharedPlugin {
|
|||
};
|
||||
const resolver = compilation.resolverFactory.get(
|
||||
"normal",
|
||||
undefined,
|
||||
"esm"
|
||||
RESOLVE_OPTIONS
|
||||
);
|
||||
/**
|
||||
* @param {string} request imported request
|
||||
|
|
|
@ -17,6 +17,7 @@ const { parseVersion } = require("./utils");
|
|||
|
||||
/** @typedef {import("../../declarations/plugins/sharing/ProvideSharedPlugin").ProvideSharedPluginOptions} ProvideSharedPluginOptions */
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
/** @typedef {import("../ResolverFactory").EnhancedResolveOptions} EnhancedResolveOptions */
|
||||
|
||||
/**
|
||||
* @typedef {Object} ProvideOptions
|
||||
|
@ -26,6 +27,9 @@ const { parseVersion } = require("./utils");
|
|||
* @property {boolean} eager
|
||||
*/
|
||||
|
||||
/** @type {EnhancedResolveOptions} */
|
||||
const RESOLVE_OPTIONS = { dependencyType: "esm" };
|
||||
|
||||
class ProvideSharedPlugin {
|
||||
/**
|
||||
* @param {ProvideSharedPluginOptions} options options
|
||||
|
@ -111,8 +115,7 @@ class ProvideSharedPlugin {
|
|||
};
|
||||
const resolver = compiler.resolverFactory.get(
|
||||
"normal",
|
||||
undefined,
|
||||
"esm"
|
||||
RESOLVE_OPTIONS
|
||||
);
|
||||
resolver.resolve(
|
||||
{},
|
||||
|
|
|
@ -5,7 +5,10 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/** @type {WeakMap<object, WeakMap<object, object>>} */
|
||||
const mergeCache = new WeakMap();
|
||||
/** @type {WeakMap<object, Map<string, Map<string|number|boolean, object>>>} */
|
||||
const setPropertyCache = new WeakMap();
|
||||
const DELETE = Symbol("DELETE");
|
||||
|
||||
/**
|
||||
|
@ -34,6 +37,40 @@ const cachedCleverMerge = (first, second) => {
|
|||
return newMerge;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {object} obj object
|
||||
* @param {string} property property
|
||||
* @param {string|number|boolean} value assignment value
|
||||
* @returns {object} new object
|
||||
*/
|
||||
const cachedSetProperty = (obj, property, value) => {
|
||||
let mapByProperty = setPropertyCache.get(obj);
|
||||
|
||||
if (mapByProperty === undefined) {
|
||||
mapByProperty = new Map();
|
||||
setPropertyCache.set(obj, mapByProperty);
|
||||
}
|
||||
|
||||
let mapByValue = mapByProperty.get(property);
|
||||
|
||||
if (mapByValue === undefined) {
|
||||
mapByValue = new Map();
|
||||
mapByProperty.set(property, mapByValue);
|
||||
}
|
||||
|
||||
let result = mapByValue.get(value);
|
||||
|
||||
if (result) return result;
|
||||
|
||||
result = {
|
||||
...obj,
|
||||
[property]: value
|
||||
};
|
||||
mapByValue.set(value, result);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Merges two objects. Objects are deeply clever merged.
|
||||
* Arrays might reference the old value with "..."
|
||||
|
@ -91,6 +128,7 @@ const cleverMerge = (first, second) => {
|
|||
return newObject;
|
||||
};
|
||||
|
||||
exports.cachedSetProperty = cachedSetProperty;
|
||||
exports.cachedCleverMerge = cachedCleverMerge;
|
||||
exports.cleverMerge = cleverMerge;
|
||||
exports.DELETE = DELETE;
|
||||
|
|
|
@ -2240,7 +2240,7 @@
|
|||
"type": "array",
|
||||
"items": {
|
||||
"description": "Resolve restriction.",
|
||||
"oneOf": [
|
||||
"anyOf": [
|
||||
{
|
||||
"instanceof": "RegExp",
|
||||
"tsType": "RegExp"
|
||||
|
|
|
@ -3183,6 +3183,38 @@ Object {
|
|||
"multiple": false,
|
||||
"simpleType": "boolean",
|
||||
},
|
||||
"resolve-loader-restrictions": Object {
|
||||
"configs": Array [
|
||||
Object {
|
||||
"description": "Resolve restriction.",
|
||||
"multiple": true,
|
||||
"path": "resolveLoader.restrictions[]",
|
||||
"type": "RegExp",
|
||||
},
|
||||
Object {
|
||||
"description": "Resolve restriction.",
|
||||
"multiple": true,
|
||||
"path": "resolveLoader.restrictions[]",
|
||||
"type": "string",
|
||||
},
|
||||
],
|
||||
"description": "Resolve restriction.",
|
||||
"multiple": true,
|
||||
"simpleType": "string",
|
||||
},
|
||||
"resolve-loader-restrictions-reset": Object {
|
||||
"configs": Array [
|
||||
Object {
|
||||
"description": "Clear all items provided in configuration. A list of resolve restrictions.",
|
||||
"multiple": false,
|
||||
"path": "resolveLoader.restrictions",
|
||||
"type": "reset",
|
||||
},
|
||||
],
|
||||
"description": "Clear all items provided in configuration. A list of resolve restrictions.",
|
||||
"multiple": false,
|
||||
"simpleType": "boolean",
|
||||
},
|
||||
"resolve-loader-symlinks": Object {
|
||||
"configs": Array [
|
||||
Object {
|
||||
|
@ -3300,6 +3332,38 @@ Object {
|
|||
"multiple": false,
|
||||
"simpleType": "boolean",
|
||||
},
|
||||
"resolve-restrictions": Object {
|
||||
"configs": Array [
|
||||
Object {
|
||||
"description": "Resolve restriction.",
|
||||
"multiple": true,
|
||||
"path": "resolve.restrictions[]",
|
||||
"type": "RegExp",
|
||||
},
|
||||
Object {
|
||||
"description": "Resolve restriction.",
|
||||
"multiple": true,
|
||||
"path": "resolve.restrictions[]",
|
||||
"type": "string",
|
||||
},
|
||||
],
|
||||
"description": "Resolve restriction.",
|
||||
"multiple": true,
|
||||
"simpleType": "string",
|
||||
},
|
||||
"resolve-restrictions-reset": Object {
|
||||
"configs": Array [
|
||||
Object {
|
||||
"description": "Clear all items provided in configuration. A list of resolve restrictions.",
|
||||
"multiple": false,
|
||||
"path": "resolve.restrictions",
|
||||
"type": "reset",
|
||||
},
|
||||
],
|
||||
"description": "Clear all items provided in configuration. A list of resolve restrictions.",
|
||||
"multiple": false,
|
||||
"simpleType": "boolean",
|
||||
},
|
||||
"resolve-symlinks": Object {
|
||||
"configs": Array [
|
||||
Object {
|
||||
|
|
|
@ -1692,7 +1692,7 @@ declare abstract class ContextModuleFactory extends ModuleFactory {
|
|||
contextModuleFiles: SyncWaterfallHook<[string[]]>;
|
||||
alternatives: AsyncSeriesWaterfallHook<[any[]]>;
|
||||
}>;
|
||||
resolverFactory: any;
|
||||
resolverFactory: ResolverFactory;
|
||||
resolveDependencies(fs?: any, options?: any, callback?: any): any;
|
||||
}
|
||||
declare class ContextReplacementPlugin {
|
||||
|
@ -4428,12 +4428,12 @@ declare abstract class NormalModuleFactory extends ModuleFactory {
|
|||
createGenerator: HookMap<SyncBailHook<any, any>>;
|
||||
generator: HookMap<SyncHook<any, void>>;
|
||||
}>;
|
||||
resolverFactory: any;
|
||||
resolverFactory: ResolverFactory;
|
||||
ruleSet: RuleSet;
|
||||
unsafeCache: boolean;
|
||||
cachePredicate: any;
|
||||
context: any;
|
||||
fs: any;
|
||||
cachePredicate: Function;
|
||||
context: string;
|
||||
fs: InputFileSystem;
|
||||
parserCache: Map<string, WeakMap<any, any>>;
|
||||
generatorCache: Map<string, WeakMap<any, Generator>>;
|
||||
resolveRequestArray(
|
||||
|
@ -4448,7 +4448,7 @@ declare abstract class NormalModuleFactory extends ModuleFactory {
|
|||
createParser(type?: any, parserOptions?: {}): any;
|
||||
getGenerator(type?: any, generatorOptions?: {}): Generator;
|
||||
createGenerator(type?: any, generatorOptions?: {}): any;
|
||||
getResolver(type?: any, resolveOptions?: any, category?: any): any;
|
||||
getResolver(type?: any, resolveOptions?: any): Resolver & WithOptions;
|
||||
}
|
||||
declare class NormalModuleReplacementPlugin {
|
||||
/**
|
||||
|
@ -5862,14 +5862,331 @@ declare interface ResolverCache {
|
|||
}
|
||||
declare abstract class ResolverFactory {
|
||||
hooks: Readonly<{
|
||||
resolveOptions: HookMap<SyncWaterfallHook<[any, string]>>;
|
||||
resolver: HookMap<SyncHook<[Resolver, any, any, string], void>>;
|
||||
resolveOptions: HookMap<
|
||||
SyncWaterfallHook<
|
||||
[
|
||||
{
|
||||
/**
|
||||
* Redirect module requests.
|
||||
*/
|
||||
alias?:
|
||||
| {
|
||||
/**
|
||||
* New request.
|
||||
*/
|
||||
alias: string | false | string[];
|
||||
/**
|
||||
* Request to be redirected.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Redirect only exact matching request.
|
||||
*/
|
||||
onlyModule?: boolean;
|
||||
}[]
|
||||
| { [index: string]: string | false | string[] };
|
||||
/**
|
||||
* Fields in the description file (usually package.json) which are used to redirect requests inside the module.
|
||||
*/
|
||||
aliasFields?: LibraryExport[];
|
||||
/**
|
||||
* Extra resolve options per dependency category. Typical categories are "commonjs", "amd", "esm".
|
||||
*/
|
||||
byDependency?: { [index: string]: ResolveOptions };
|
||||
/**
|
||||
* Enable caching of successfully resolved requests (cache entries are revalidated).
|
||||
*/
|
||||
cache?: boolean;
|
||||
/**
|
||||
* Predicate function to decide which requests should be cached.
|
||||
*/
|
||||
cachePredicate?: Function;
|
||||
/**
|
||||
* Include the context information in the cache identifier when caching.
|
||||
*/
|
||||
cacheWithContext?: boolean;
|
||||
/**
|
||||
* Condition names for exports field entry point.
|
||||
*/
|
||||
conditionNames?: string[];
|
||||
/**
|
||||
* Filenames used to find a description file (like a package.json).
|
||||
*/
|
||||
descriptionFiles?: string[];
|
||||
/**
|
||||
* Enforce using one of the extensions from the extensions option.
|
||||
*/
|
||||
enforceExtension?: boolean;
|
||||
/**
|
||||
* Field names from the description file (usually package.json) which are used to provide entry points of a package.
|
||||
*/
|
||||
exportsFields?: string[];
|
||||
/**
|
||||
* Extensions added to the request when trying to find the file.
|
||||
*/
|
||||
extensions?: string[];
|
||||
/**
|
||||
* Filesystem for the resolver.
|
||||
*/
|
||||
fileSystem?: { [index: string]: any };
|
||||
/**
|
||||
* Field names from the description file (package.json) which are used to find the default entry point.
|
||||
*/
|
||||
mainFields?: LibraryExport[];
|
||||
/**
|
||||
* Filenames used to find the default entry point if there is no description file or main field.
|
||||
*/
|
||||
mainFiles?: string[];
|
||||
/**
|
||||
* Folder names or directory paths where to find modules.
|
||||
*/
|
||||
modules?: string[];
|
||||
/**
|
||||
* Plugins for the resolver.
|
||||
*/
|
||||
plugins?: ResolvePluginInstance[];
|
||||
/**
|
||||
* Custom resolver.
|
||||
*/
|
||||
resolver?: { [index: string]: any };
|
||||
/**
|
||||
* A list of resolve restrictions.
|
||||
*/
|
||||
restrictions?: (string | RegExp)[];
|
||||
/**
|
||||
* Enable resolving symlinks to the original location.
|
||||
*/
|
||||
symlinks?: boolean;
|
||||
/**
|
||||
* Enable caching of successfully resolved requests (cache entries are not revalidated).
|
||||
*/
|
||||
unsafeCache?: boolean | { [index: string]: any };
|
||||
/**
|
||||
* Use synchronous filesystem calls for the resolver.
|
||||
*/
|
||||
useSyncFileSystemCalls?: boolean;
|
||||
dependencyType?: string;
|
||||
}
|
||||
]
|
||||
>
|
||||
>;
|
||||
resolver: HookMap<
|
||||
SyncHook<
|
||||
[
|
||||
Resolver,
|
||||
ResolveOptions,
|
||||
{
|
||||
/**
|
||||
* Redirect module requests.
|
||||
*/
|
||||
alias?:
|
||||
| {
|
||||
/**
|
||||
* New request.
|
||||
*/
|
||||
alias: string | false | string[];
|
||||
/**
|
||||
* Request to be redirected.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Redirect only exact matching request.
|
||||
*/
|
||||
onlyModule?: boolean;
|
||||
}[]
|
||||
| { [index: string]: string | false | string[] };
|
||||
/**
|
||||
* Fields in the description file (usually package.json) which are used to redirect requests inside the module.
|
||||
*/
|
||||
aliasFields?: LibraryExport[];
|
||||
/**
|
||||
* Extra resolve options per dependency category. Typical categories are "commonjs", "amd", "esm".
|
||||
*/
|
||||
byDependency?: { [index: string]: ResolveOptions };
|
||||
/**
|
||||
* Enable caching of successfully resolved requests (cache entries are revalidated).
|
||||
*/
|
||||
cache?: boolean;
|
||||
/**
|
||||
* Predicate function to decide which requests should be cached.
|
||||
*/
|
||||
cachePredicate?: Function;
|
||||
/**
|
||||
* Include the context information in the cache identifier when caching.
|
||||
*/
|
||||
cacheWithContext?: boolean;
|
||||
/**
|
||||
* Condition names for exports field entry point.
|
||||
*/
|
||||
conditionNames?: string[];
|
||||
/**
|
||||
* Filenames used to find a description file (like a package.json).
|
||||
*/
|
||||
descriptionFiles?: string[];
|
||||
/**
|
||||
* Enforce using one of the extensions from the extensions option.
|
||||
*/
|
||||
enforceExtension?: boolean;
|
||||
/**
|
||||
* Field names from the description file (usually package.json) which are used to provide entry points of a package.
|
||||
*/
|
||||
exportsFields?: string[];
|
||||
/**
|
||||
* Extensions added to the request when trying to find the file.
|
||||
*/
|
||||
extensions?: string[];
|
||||
/**
|
||||
* Filesystem for the resolver.
|
||||
*/
|
||||
fileSystem?: { [index: string]: any };
|
||||
/**
|
||||
* Field names from the description file (package.json) which are used to find the default entry point.
|
||||
*/
|
||||
mainFields?: LibraryExport[];
|
||||
/**
|
||||
* Filenames used to find the default entry point if there is no description file or main field.
|
||||
*/
|
||||
mainFiles?: string[];
|
||||
/**
|
||||
* Folder names or directory paths where to find modules.
|
||||
*/
|
||||
modules?: string[];
|
||||
/**
|
||||
* Plugins for the resolver.
|
||||
*/
|
||||
plugins?: ResolvePluginInstance[];
|
||||
/**
|
||||
* Custom resolver.
|
||||
*/
|
||||
resolver?: { [index: string]: any };
|
||||
/**
|
||||
* A list of resolve restrictions.
|
||||
*/
|
||||
restrictions?: (string | RegExp)[];
|
||||
/**
|
||||
* Enable resolving symlinks to the original location.
|
||||
*/
|
||||
symlinks?: boolean;
|
||||
/**
|
||||
* Enable caching of successfully resolved requests (cache entries are not revalidated).
|
||||
*/
|
||||
unsafeCache?: boolean | { [index: string]: any };
|
||||
/**
|
||||
* Use synchronous filesystem calls for the resolver.
|
||||
*/
|
||||
useSyncFileSystemCalls?: boolean;
|
||||
dependencyType?: string;
|
||||
}
|
||||
],
|
||||
void
|
||||
>
|
||||
>;
|
||||
}>;
|
||||
cache: Map<string, ResolverCache>;
|
||||
get(
|
||||
type: string,
|
||||
resolveOptions?: any,
|
||||
dependencyType?: string
|
||||
resolveOptions?: {
|
||||
/**
|
||||
* Redirect module requests.
|
||||
*/
|
||||
alias?:
|
||||
| {
|
||||
/**
|
||||
* New request.
|
||||
*/
|
||||
alias: string | false | string[];
|
||||
/**
|
||||
* Request to be redirected.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Redirect only exact matching request.
|
||||
*/
|
||||
onlyModule?: boolean;
|
||||
}[]
|
||||
| { [index: string]: string | false | string[] };
|
||||
/**
|
||||
* Fields in the description file (usually package.json) which are used to redirect requests inside the module.
|
||||
*/
|
||||
aliasFields?: LibraryExport[];
|
||||
/**
|
||||
* Extra resolve options per dependency category. Typical categories are "commonjs", "amd", "esm".
|
||||
*/
|
||||
byDependency?: { [index: string]: ResolveOptions };
|
||||
/**
|
||||
* Enable caching of successfully resolved requests (cache entries are revalidated).
|
||||
*/
|
||||
cache?: boolean;
|
||||
/**
|
||||
* Predicate function to decide which requests should be cached.
|
||||
*/
|
||||
cachePredicate?: Function;
|
||||
/**
|
||||
* Include the context information in the cache identifier when caching.
|
||||
*/
|
||||
cacheWithContext?: boolean;
|
||||
/**
|
||||
* Condition names for exports field entry point.
|
||||
*/
|
||||
conditionNames?: string[];
|
||||
/**
|
||||
* Filenames used to find a description file (like a package.json).
|
||||
*/
|
||||
descriptionFiles?: string[];
|
||||
/**
|
||||
* Enforce using one of the extensions from the extensions option.
|
||||
*/
|
||||
enforceExtension?: boolean;
|
||||
/**
|
||||
* Field names from the description file (usually package.json) which are used to provide entry points of a package.
|
||||
*/
|
||||
exportsFields?: string[];
|
||||
/**
|
||||
* Extensions added to the request when trying to find the file.
|
||||
*/
|
||||
extensions?: string[];
|
||||
/**
|
||||
* Filesystem for the resolver.
|
||||
*/
|
||||
fileSystem?: { [index: string]: any };
|
||||
/**
|
||||
* Field names from the description file (package.json) which are used to find the default entry point.
|
||||
*/
|
||||
mainFields?: LibraryExport[];
|
||||
/**
|
||||
* Filenames used to find the default entry point if there is no description file or main field.
|
||||
*/
|
||||
mainFiles?: string[];
|
||||
/**
|
||||
* Folder names or directory paths where to find modules.
|
||||
*/
|
||||
modules?: string[];
|
||||
/**
|
||||
* Plugins for the resolver.
|
||||
*/
|
||||
plugins?: ResolvePluginInstance[];
|
||||
/**
|
||||
* Custom resolver.
|
||||
*/
|
||||
resolver?: { [index: string]: any };
|
||||
/**
|
||||
* A list of resolve restrictions.
|
||||
*/
|
||||
restrictions?: (string | RegExp)[];
|
||||
/**
|
||||
* Enable resolving symlinks to the original location.
|
||||
*/
|
||||
symlinks?: boolean;
|
||||
/**
|
||||
* Enable caching of successfully resolved requests (cache entries are not revalidated).
|
||||
*/
|
||||
unsafeCache?: boolean | { [index: string]: any };
|
||||
/**
|
||||
* Use synchronous filesystem calls for the resolver.
|
||||
*/
|
||||
useSyncFileSystemCalls?: boolean;
|
||||
dependencyType?: string;
|
||||
}
|
||||
): Resolver & WithOptions;
|
||||
}
|
||||
declare interface RuleSet {
|
||||
|
|
Loading…
Reference in New Issue