upgrade enhanced-resolve

This commit is contained in:
Ivan Kopeykin 2020-06-17 14:22:37 +03:00
parent e58c64912b
commit 8174145782
8 changed files with 528 additions and 202 deletions

45
declarations.d.ts vendored
View File

@ -339,51 +339,6 @@ declare module "webpack-sources" {
} }
} }
declare module "enhanced-resolve" {
type ResolveFunction = (
path: string,
request: string,
resolveContext: ResolveContext,
callback: (
err?: NodeJS.ErrnoException,
result?: string,
additionalInfo?: Object
) => void
) => void;
export function create(options: any): ResolveFunction;
interface WriteOnlySet<T> {
add(item: T): void;
}
interface ResolveContext {
log?: (message: string) => void;
fileDependencies?: WriteOnlySet<string>;
contextDependencies?: WriteOnlySet<string>;
missingDependencies?: WriteOnlySet<string>;
stack?: Set<string>;
}
export class Resolver {
resolve(
context: Object,
path: string,
request: string,
resolveContext: ResolveContext,
callback: (
err?: NodeJS.ErrnoException,
result?: string,
additionalInfo?: Object
) => void
): void;
}
export class ResolverFactory {
static createResolver(options: TODO): Resolver;
}
}
type TODO = any; type TODO = any;
type RecursiveArrayOrRecord<T> = type RecursiveArrayOrRecord<T> =

View File

@ -74,6 +74,10 @@ const stringifyLoadersAndResource = (loaders, resource) => {
return str + resource; return str + resource;
}; };
/**
* @param {string} resultString resultString
* @returns {{loader: string, options: string|undefined}} parsed loader request
*/
const identToLoaderRequest = resultString => { const identToLoaderRequest = resultString => {
const idx = resultString.indexOf("?"); const idx = resultString.indexOf("?");
if (idx >= 0) { if (idx >= 0) {

View File

@ -9,10 +9,11 @@ const Factory = require("enhanced-resolve").ResolverFactory;
const { HookMap, SyncHook, SyncWaterfallHook } = require("tapable"); const { HookMap, SyncHook, SyncWaterfallHook } = require("tapable");
const { cachedCleverMerge } = require("./util/cleverMerge"); const { cachedCleverMerge } = require("./util/cleverMerge");
/** @typedef {import("enhanced-resolve").ResolveOptions} ResolveOptions */
/** @typedef {import("enhanced-resolve").Resolver} Resolver */ /** @typedef {import("enhanced-resolve").Resolver} Resolver */
/** @typedef {import("../declarations/WebpackOptions").ResolveOptions} ResolveOptions */ /** @typedef {import("../declarations/WebpackOptions").ResolveOptions} WebpackResolveOptions */
/** @typedef {ResolveOptions & {dependencyType?: string}} ResolveOptionsWithDependencyType */ /** @typedef {WebpackResolveOptions & {dependencyType?: string}} ResolveOptionsWithDependencyType */
/** /**
* @typedef {Object} WithOptions * @typedef {Object} WithOptions
* @property {function(Object): ResolverWithOptions} withOptions create a resolver with additional/different options * @property {function(Object): ResolverWithOptions} withOptions create a resolver with additional/different options
@ -82,10 +83,10 @@ module.exports = class ResolverFactory {
_create(type, enhancedResolveOptions) { _create(type, enhancedResolveOptions) {
/** @type {ResolveOptionsWithDependencyType} */ /** @type {ResolveOptionsWithDependencyType} */
const originalResolveOptions = { ...enhancedResolveOptions }; const originalResolveOptions = { ...enhancedResolveOptions };
/** @type {ResolveOptions} */
const resolveOptions = this.hooks.resolveOptions const resolveOptions = /** @type {ResolveOptions} */ (this.hooks.resolveOptions
.for(type) .for(type)
.call(enhancedResolveOptions); .call(enhancedResolveOptions));
const resolver = /** @type {ResolverWithOptions} */ (Factory.createResolver( const resolver = /** @type {ResolverWithOptions} */ (Factory.createResolver(
resolveOptions resolveOptions
)); ));

View File

@ -24,7 +24,6 @@ const {
getRequiredVersionFromDescriptionFile getRequiredVersionFromDescriptionFile
} = require("./utils"); } = require("./utils");
/** @typedef {import("enhanced-resolve").ResolveContext} ResolveContext */
/** @typedef {import("../../declarations/plugins/sharing/ConsumeSharedPlugin").ConsumeSharedPluginOptions} ConsumeSharedPluginOptions */ /** @typedef {import("../../declarations/plugins/sharing/ConsumeSharedPlugin").ConsumeSharedPluginOptions} ConsumeSharedPluginOptions */
/** @typedef {import("../../declarations/plugins/sharing/ConsumeSharedPlugin").ConsumesConfig} ConsumesConfig */ /** @typedef {import("../../declarations/plugins/sharing/ConsumeSharedPlugin").ConsumesConfig} ConsumesConfig */
/** @typedef {import("../Compiler")} Compiler */ /** @typedef {import("../Compiler")} Compiler */

View File

@ -57,7 +57,8 @@ exports.resolveMatchedConfigs = (compilation, configs) => {
request, request,
resolveContext, resolveContext,
(err, result) => { (err, result) => {
if (err) { if (err || result === false) {
err = err || new Error(`Can't resolve ${request}`);
compilation.errors.push( compilation.errors.push(
new ModuleNotFoundError(null, err, { new ModuleNotFoundError(null, err, {
name: `shared module ${request}` name: `shared module ${request}`

View File

@ -12,7 +12,7 @@
"@webassemblyjs/wasm-parser": "1.9.0", "@webassemblyjs/wasm-parser": "1.9.0",
"acorn": "^7.0.0", "acorn": "^7.0.0",
"chrome-trace-event": "^1.0.2", "chrome-trace-event": "^1.0.2",
"enhanced-resolve": "5.0.0-beta.6", "enhanced-resolve": "5.0.0-beta.7",
"eslint-scope": "^5.0.0", "eslint-scope": "^5.0.0",
"events": "^3.0.0", "events": "^3.0.0",
"glob-to-regexp": "^0.4.1", "glob-to-regexp": "^0.4.1",

656
types.d.ts vendored
View File

@ -65,13 +65,16 @@ import { default as ValidationError } from "schema-utils/declarations/Validation
import { import {
AsArray, AsArray,
AsyncParallelHook, AsyncParallelHook,
AsyncSeriesBailHook, AsyncSeriesBailHook as AsyncSeriesBailHookImportTapableClass_1,
AsyncSeriesHook, AsyncSeriesBailHook as AsyncSeriesBailHookImportTapableClass_2,
AsyncSeriesHook as AsyncSeriesHookImportTapableClass_1,
AsyncSeriesHook as AsyncSeriesHookImportTapableClass_2,
AsyncSeriesWaterfallHook, AsyncSeriesWaterfallHook,
HookMap, HookMap,
MultiHook, MultiHook,
SyncBailHook, SyncBailHook,
SyncHook, SyncHook as SyncHookImportTapableClass_1,
SyncHook as SyncHookImportTapableClass_2,
SyncWaterfallHook SyncWaterfallHook
} from "tapable"; } from "tapable";
@ -226,11 +229,11 @@ declare abstract class AsyncDependenciesBlock extends DependenciesBlock {
} }
declare abstract class AsyncQueue<T, K, R> { declare abstract class AsyncQueue<T, K, R> {
hooks: { hooks: {
beforeAdd: AsyncSeriesHook<[T]>; beforeAdd: AsyncSeriesHookImportTapableClass_1<[T]>;
added: SyncHook<[T], void>; added: SyncHookImportTapableClass_1<[T], void>;
beforeStart: AsyncSeriesHook<[T]>; beforeStart: AsyncSeriesHookImportTapableClass_1<[T]>;
started: SyncHook<[T], void>; started: SyncHookImportTapableClass_1<[T], void>;
result: SyncHook<[T, Error, R], void>; result: SyncHookImportTapableClass_1<[T, Error, R], void>;
}; };
add(item: T, callback: CallbackFunction<R>): void; add(item: T, callback: CallbackFunction<R>): void;
invalidate(item: T): void; invalidate(item: T): void;
@ -385,13 +388,13 @@ declare abstract class ByTypeGenerator extends Generator {
declare class Cache { declare class Cache {
constructor(); constructor();
hooks: { hooks: {
get: AsyncSeriesBailHook< get: AsyncSeriesBailHookImportTapableClass_1<
[string, Etag, ((result: any, stats: CallbackCache<void>) => void)[]], [string, Etag, ((result: any, stats: CallbackCache<void>) => void)[]],
any any
>; >;
store: AsyncParallelHook<[string, Etag, any]>; store: AsyncParallelHook<[string, Etag, any]>;
storeBuildDependencies: AsyncParallelHook<[Iterable<string>]>; storeBuildDependencies: AsyncParallelHook<[Iterable<string>]>;
beginIdle: SyncHook<[], void>; beginIdle: SyncHookImportTapableClass_1<[], void>;
endIdle: AsyncParallelHook<[]>; endIdle: AsyncParallelHook<[]>;
shutdown: AsyncParallelHook<[]>; shutdown: AsyncParallelHook<[]>;
}; };
@ -856,12 +859,12 @@ declare class Compilation {
*/ */
constructor(compiler: Compiler); constructor(compiler: Compiler);
hooks: Readonly<{ hooks: Readonly<{
buildModule: SyncHook<[Module], void>; buildModule: SyncHookImportTapableClass_1<[Module], void>;
rebuildModule: SyncHook<[Module], void>; rebuildModule: SyncHookImportTapableClass_1<[Module], void>;
failedModule: SyncHook<[Module, WebpackError], void>; failedModule: SyncHookImportTapableClass_1<[Module, WebpackError], void>;
succeedModule: SyncHook<[Module], void>; succeedModule: SyncHookImportTapableClass_1<[Module], void>;
stillValidModule: SyncHook<[Module], void>; stillValidModule: SyncHookImportTapableClass_1<[Module], void>;
addEntry: SyncHook< addEntry: SyncHookImportTapableClass_1<
[ [
Dependency, Dependency,
{ name: string } & Pick< { name: string } & Pick<
@ -871,7 +874,7 @@ declare class Compilation {
], ],
void void
>; >;
failedEntry: SyncHook< failedEntry: SyncHookImportTapableClass_1<
[ [
Dependency, Dependency,
{ name: string } & Pick< { name: string } & Pick<
@ -882,7 +885,7 @@ declare class Compilation {
], ],
void void
>; >;
succeedEntry: SyncHook< succeedEntry: SyncHookImportTapableClass_1<
[ [
Dependency, Dependency,
{ name: string } & Pick< { name: string } & Pick<
@ -896,108 +899,159 @@ declare class Compilation {
dependencyReferencedExports: SyncWaterfallHook< dependencyReferencedExports: SyncWaterfallHook<
[(string[] | ReferencedExport)[], Dependency] [(string[] | ReferencedExport)[], Dependency]
>; >;
finishModules: AsyncSeriesHook<[Iterable<Module>]>; finishModules: AsyncSeriesHookImportTapableClass_1<[Iterable<Module>]>;
finishRebuildingModule: AsyncSeriesHook<[Module]>; finishRebuildingModule: AsyncSeriesHookImportTapableClass_1<[Module]>;
unseal: SyncHook<[], void>; unseal: SyncHookImportTapableClass_1<[], void>;
seal: SyncHook<[], void>; seal: SyncHookImportTapableClass_1<[], void>;
beforeChunks: SyncHook<[], void>; beforeChunks: SyncHookImportTapableClass_1<[], void>;
afterChunks: SyncHook<[Iterable<Chunk>], void>; afterChunks: SyncHookImportTapableClass_1<[Iterable<Chunk>], void>;
optimizeDependencies: SyncBailHook<[Iterable<Module>], any>; optimizeDependencies: SyncBailHook<[Iterable<Module>], any>;
afterOptimizeDependencies: SyncHook<[Iterable<Module>], void>; afterOptimizeDependencies: SyncHookImportTapableClass_1<
optimize: SyncHook<[], void>; [Iterable<Module>],
void
>;
optimize: SyncHookImportTapableClass_1<[], void>;
optimizeModules: SyncBailHook<[Iterable<Module>], any>; optimizeModules: SyncBailHook<[Iterable<Module>], any>;
afterOptimizeModules: SyncHook<[Iterable<Module>], void>; afterOptimizeModules: SyncHookImportTapableClass_1<
[Iterable<Module>],
void
>;
optimizeChunks: SyncBailHook<[Iterable<Chunk>, ChunkGroup[]], any>; optimizeChunks: SyncBailHook<[Iterable<Chunk>, ChunkGroup[]], any>;
afterOptimizeChunks: SyncHook<[Iterable<Chunk>, ChunkGroup[]], void>; afterOptimizeChunks: SyncHookImportTapableClass_1<
optimizeTree: AsyncSeriesHook<[Iterable<Chunk>, Iterable<Module>]>; [Iterable<Chunk>, ChunkGroup[]],
afterOptimizeTree: SyncHook<[Iterable<Chunk>, Iterable<Module>], void>; void
optimizeChunkModules: AsyncSeriesBailHook< >;
optimizeTree: AsyncSeriesHookImportTapableClass_1<
[Iterable<Chunk>, Iterable<Module>]
>;
afterOptimizeTree: SyncHookImportTapableClass_1<
[Iterable<Chunk>, Iterable<Module>],
void
>;
optimizeChunkModules: AsyncSeriesBailHookImportTapableClass_1<
[Iterable<Chunk>, Iterable<Module>], [Iterable<Chunk>, Iterable<Module>],
any any
>; >;
afterOptimizeChunkModules: SyncHook< afterOptimizeChunkModules: SyncHookImportTapableClass_1<
[Iterable<Chunk>, Iterable<Module>], [Iterable<Chunk>, Iterable<Module>],
void void
>; >;
shouldRecord: SyncBailHook<[], boolean>; shouldRecord: SyncBailHook<[], boolean>;
additionalChunkRuntimeRequirements: SyncHook<[Chunk, Set<string>], void>; additionalChunkRuntimeRequirements: SyncHookImportTapableClass_1<
[Chunk, Set<string>],
void
>;
runtimeRequirementInChunk: HookMap<SyncBailHook<[Chunk, Set<string>], any>>; runtimeRequirementInChunk: HookMap<SyncBailHook<[Chunk, Set<string>], any>>;
additionalModuleRuntimeRequirements: SyncHook<[Module, Set<string>], void>; additionalModuleRuntimeRequirements: SyncHookImportTapableClass_1<
[Module, Set<string>],
void
>;
runtimeRequirementInModule: HookMap< runtimeRequirementInModule: HookMap<
SyncBailHook<[Module, Set<string>], any> SyncBailHook<[Module, Set<string>], any>
>; >;
additionalTreeRuntimeRequirements: SyncHook<[Chunk, Set<string>], void>; additionalTreeRuntimeRequirements: SyncHookImportTapableClass_1<
[Chunk, Set<string>],
void
>;
runtimeRequirementInTree: HookMap<SyncBailHook<[Chunk, Set<string>], any>>; runtimeRequirementInTree: HookMap<SyncBailHook<[Chunk, Set<string>], any>>;
runtimeModule: SyncHook<[RuntimeModule, Chunk], void>; runtimeModule: SyncHookImportTapableClass_1<[RuntimeModule, Chunk], void>;
reviveModules: SyncHook<[Iterable<Module>, any], void>; reviveModules: SyncHookImportTapableClass_1<[Iterable<Module>, any], void>;
beforeModuleIds: SyncHook<[Iterable<Module>], void>; beforeModuleIds: SyncHookImportTapableClass_1<[Iterable<Module>], void>;
moduleIds: SyncHook<[Iterable<Module>], void>; moduleIds: SyncHookImportTapableClass_1<[Iterable<Module>], void>;
optimizeModuleIds: SyncHook<[Iterable<Module>], void>; optimizeModuleIds: SyncHookImportTapableClass_1<[Iterable<Module>], void>;
afterOptimizeModuleIds: SyncHook<[Iterable<Module>], void>; afterOptimizeModuleIds: SyncHookImportTapableClass_1<
reviveChunks: SyncHook<[Iterable<Chunk>, any], void>; [Iterable<Module>],
beforeChunkIds: SyncHook<[Iterable<Chunk>], void>; void
chunkIds: SyncHook<[Iterable<Chunk>], void>; >;
optimizeChunkIds: SyncHook<[Iterable<Chunk>], void>; reviveChunks: SyncHookImportTapableClass_1<[Iterable<Chunk>, any], void>;
afterOptimizeChunkIds: SyncHook<[Iterable<Chunk>], void>; beforeChunkIds: SyncHookImportTapableClass_1<[Iterable<Chunk>], void>;
recordModules: SyncHook<[Iterable<Module>, any], void>; chunkIds: SyncHookImportTapableClass_1<[Iterable<Chunk>], void>;
recordChunks: SyncHook<[Iterable<Chunk>, any], void>; optimizeChunkIds: SyncHookImportTapableClass_1<[Iterable<Chunk>], void>;
optimizeCodeGeneration: SyncHook<[Iterable<Module>], void>; afterOptimizeChunkIds: SyncHookImportTapableClass_1<
beforeModuleHash: SyncHook<[], void>; [Iterable<Chunk>],
afterModuleHash: SyncHook<[], void>; void
beforeCodeGeneration: SyncHook<[], void>; >;
afterCodeGeneration: SyncHook<[], void>; recordModules: SyncHookImportTapableClass_1<[Iterable<Module>, any], void>;
beforeRuntimeRequirements: SyncHook<[], void>; recordChunks: SyncHookImportTapableClass_1<[Iterable<Chunk>, any], void>;
afterRuntimeRequirements: SyncHook<[], void>; optimizeCodeGeneration: SyncHookImportTapableClass_1<
beforeHash: SyncHook<[], void>; [Iterable<Module>],
contentHash: SyncHook<[Chunk], void>; void
afterHash: SyncHook<[], void>; >;
recordHash: SyncHook<[any], void>; beforeModuleHash: SyncHookImportTapableClass_1<[], void>;
record: SyncHook<[Compilation, any], void>; afterModuleHash: SyncHookImportTapableClass_1<[], void>;
beforeModuleAssets: SyncHook<[], void>; beforeCodeGeneration: SyncHookImportTapableClass_1<[], void>;
afterCodeGeneration: SyncHookImportTapableClass_1<[], void>;
beforeRuntimeRequirements: SyncHookImportTapableClass_1<[], void>;
afterRuntimeRequirements: SyncHookImportTapableClass_1<[], void>;
beforeHash: SyncHookImportTapableClass_1<[], void>;
contentHash: SyncHookImportTapableClass_1<[Chunk], void>;
afterHash: SyncHookImportTapableClass_1<[], void>;
recordHash: SyncHookImportTapableClass_1<[any], void>;
record: SyncHookImportTapableClass_1<[Compilation, any], void>;
beforeModuleAssets: SyncHookImportTapableClass_1<[], void>;
shouldGenerateChunkAssets: SyncBailHook<[], boolean>; shouldGenerateChunkAssets: SyncBailHook<[], boolean>;
beforeChunkAssets: SyncHook<[], void>; beforeChunkAssets: SyncHookImportTapableClass_1<[], void>;
additionalChunkAssets: Pick< additionalChunkAssets: Pick<
AsyncSeriesHook<[Set<Chunk>]>, AsyncSeriesHookImportTapableClass_1<[Set<Chunk>]>,
"tap" | "tapAsync" | "tapPromise" | "name" "tap" | "tapAsync" | "tapPromise" | "name"
> & > &
FakeHookMarker; FakeHookMarker;
additionalAssets: Pick< additionalAssets: Pick<
AsyncSeriesHook<[]>, AsyncSeriesHookImportTapableClass_1<[]>,
"tap" | "tapAsync" | "tapPromise" | "name" "tap" | "tapAsync" | "tapPromise" | "name"
> & > &
FakeHookMarker; FakeHookMarker;
optimizeChunkAssets: Pick< optimizeChunkAssets: Pick<
AsyncSeriesHook<[Set<Chunk>]>, AsyncSeriesHookImportTapableClass_1<[Set<Chunk>]>,
"tap" | "tapAsync" | "tapPromise" | "name" "tap" | "tapAsync" | "tapPromise" | "name"
> & > &
FakeHookMarker; FakeHookMarker;
afterOptimizeChunkAssets: Pick< afterOptimizeChunkAssets: Pick<
AsyncSeriesHook<[Set<Chunk>]>, AsyncSeriesHookImportTapableClass_1<[Set<Chunk>]>,
"tap" | "tapAsync" | "tapPromise" | "name" "tap" | "tapAsync" | "tapPromise" | "name"
> & > &
FakeHookMarker; FakeHookMarker;
optimizeAssets: AsyncSeriesHook<[Record<string, Source>]>; optimizeAssets: AsyncSeriesHookImportTapableClass_1<
afterOptimizeAssets: SyncHook<[Record<string, Source>], void>; [Record<string, Source>]
processAssets: AsyncSeriesHook<[Record<string, Source>]>; >;
afterProcessAssets: SyncHook<[Record<string, Source>], void>; afterOptimizeAssets: SyncHookImportTapableClass_1<
[Record<string, Source>],
void
>;
processAssets: AsyncSeriesHookImportTapableClass_1<
[Record<string, Source>]
>;
afterProcessAssets: SyncHookImportTapableClass_1<
[Record<string, Source>],
void
>;
needAdditionalSeal: SyncBailHook<[], boolean>; needAdditionalSeal: SyncBailHook<[], boolean>;
afterSeal: AsyncSeriesHook<[]>; afterSeal: AsyncSeriesHookImportTapableClass_1<[]>;
renderManifest: SyncWaterfallHook< renderManifest: SyncWaterfallHook<
[RenderManifestEntry[], RenderManifestOptions] [RenderManifestEntry[], RenderManifestOptions]
>; >;
fullHash: SyncHook<[Hash], void>; fullHash: SyncHookImportTapableClass_1<[Hash], void>;
chunkHash: SyncHook<[Chunk, Hash, ChunkHashContext], void>; chunkHash: SyncHookImportTapableClass_1<
moduleAsset: SyncHook<[Module, string], void>; [Chunk, Hash, ChunkHashContext],
chunkAsset: SyncHook<[Chunk, string], void>; void
>;
moduleAsset: SyncHookImportTapableClass_1<[Module, string], void>;
chunkAsset: SyncHookImportTapableClass_1<[Chunk, string], void>;
assetPath: SyncWaterfallHook<[string, any, AssetInfo]>; assetPath: SyncWaterfallHook<[string, any, AssetInfo]>;
needAdditionalPass: SyncBailHook<[], boolean>; needAdditionalPass: SyncBailHook<[], boolean>;
childCompiler: SyncHook<[Compiler, string, number], void>; childCompiler: SyncHookImportTapableClass_1<
[Compiler, string, number],
void
>;
log: SyncBailHook<[string, LogEntry], true>; log: SyncBailHook<[string, LogEntry], true>;
statsPreset: HookMap<SyncHook<[any, any], void>>; statsPreset: HookMap<SyncHookImportTapableClass_1<[any, any], void>>;
statsNormalize: SyncHook<[any, any], void>; statsNormalize: SyncHookImportTapableClass_1<[any, any], void>;
statsFactory: SyncHook<[StatsFactory, any], void>; statsFactory: SyncHookImportTapableClass_1<[StatsFactory, any], void>;
statsPrinter: SyncHook<[StatsPrinter, any], void>; statsPrinter: SyncHookImportTapableClass_1<[StatsPrinter, any], void>;
readonly normalModuleLoader: SyncHook<[any, NormalModule], void>; readonly normalModuleLoader: SyncHookImportTapableClass_1<
[any, NormalModule],
void
>;
}>; }>;
name: string; name: string;
compiler: Compiler; compiler: Compiler;
@ -1293,7 +1347,10 @@ declare interface CompilationHooksJavascriptModulesPlugin {
renderMain: SyncWaterfallHook<[Source, RenderContextObject]>; renderMain: SyncWaterfallHook<[Source, RenderContextObject]>;
render: SyncWaterfallHook<[Source, RenderContextObject]>; render: SyncWaterfallHook<[Source, RenderContextObject]>;
renderRequire: SyncWaterfallHook<[string, RenderBootstrapContext]>; renderRequire: SyncWaterfallHook<[string, RenderBootstrapContext]>;
chunkHash: SyncHook<[Chunk, Hash, ChunkHashContext], void>; chunkHash: SyncHookImportTapableClass_1<
[Chunk, Hash, ChunkHashContext],
void
>;
} }
declare interface CompilationParams { declare interface CompilationParams {
normalModuleFactory: NormalModuleFactory; normalModuleFactory: NormalModuleFactory;
@ -1302,34 +1359,48 @@ declare interface CompilationParams {
declare class Compiler { declare class Compiler {
constructor(context: string); constructor(context: string);
hooks: Readonly<{ hooks: Readonly<{
initialize: SyncHook<[], void>; initialize: SyncHookImportTapableClass_1<[], void>;
shouldEmit: SyncBailHook<[Compilation], boolean>; shouldEmit: SyncBailHook<[Compilation], boolean>;
done: AsyncSeriesHook<[Stats]>; done: AsyncSeriesHookImportTapableClass_1<[Stats]>;
afterDone: SyncHook<[Stats], void>; afterDone: SyncHookImportTapableClass_1<[Stats], void>;
additionalPass: AsyncSeriesHook<[]>; additionalPass: AsyncSeriesHookImportTapableClass_1<[]>;
beforeRun: AsyncSeriesHook<[Compiler]>; beforeRun: AsyncSeriesHookImportTapableClass_1<[Compiler]>;
run: AsyncSeriesHook<[Compiler]>; run: AsyncSeriesHookImportTapableClass_1<[Compiler]>;
emit: AsyncSeriesHook<[Compilation]>; emit: AsyncSeriesHookImportTapableClass_1<[Compilation]>;
assetEmitted: AsyncSeriesHook<[string, AssetEmittedInfo]>; assetEmitted: AsyncSeriesHookImportTapableClass_1<
afterEmit: AsyncSeriesHook<[Compilation]>; [string, AssetEmittedInfo]
thisCompilation: SyncHook<[Compilation, CompilationParams], void>; >;
compilation: SyncHook<[Compilation, CompilationParams], void>; afterEmit: AsyncSeriesHookImportTapableClass_1<[Compilation]>;
normalModuleFactory: SyncHook<[NormalModuleFactory], void>; thisCompilation: SyncHookImportTapableClass_1<
contextModuleFactory: SyncHook<[ContextModuleFactory], void>; [Compilation, CompilationParams],
beforeCompile: AsyncSeriesHook<[CompilationParams]>; void
compile: SyncHook<[CompilationParams], void>; >;
compilation: SyncHookImportTapableClass_1<
[Compilation, CompilationParams],
void
>;
normalModuleFactory: SyncHookImportTapableClass_1<
[NormalModuleFactory],
void
>;
contextModuleFactory: SyncHookImportTapableClass_1<
[ContextModuleFactory],
void
>;
beforeCompile: AsyncSeriesHookImportTapableClass_1<[CompilationParams]>;
compile: SyncHookImportTapableClass_1<[CompilationParams], void>;
make: AsyncParallelHook<[Compilation]>; make: AsyncParallelHook<[Compilation]>;
finishMake: AsyncParallelHook<[Compilation]>; finishMake: AsyncParallelHook<[Compilation]>;
afterCompile: AsyncSeriesHook<[Compilation]>; afterCompile: AsyncSeriesHookImportTapableClass_1<[Compilation]>;
watchRun: AsyncSeriesHook<[Compiler]>; watchRun: AsyncSeriesHookImportTapableClass_1<[Compiler]>;
failed: SyncHook<[Error], void>; failed: SyncHookImportTapableClass_1<[Error], void>;
invalid: SyncHook<[string, string], void>; invalid: SyncHookImportTapableClass_1<[string, string], void>;
watchClose: SyncHook<[], void>; watchClose: SyncHookImportTapableClass_1<[], void>;
infrastructureLog: SyncBailHook<[string, string, any[]], true>; infrastructureLog: SyncBailHook<[string, string, any[]], true>;
environment: SyncHook<[], void>; environment: SyncHookImportTapableClass_1<[], void>;
afterEnvironment: SyncHook<[], void>; afterEnvironment: SyncHookImportTapableClass_1<[], void>;
afterPlugins: SyncHook<[Compiler], void>; afterPlugins: SyncHookImportTapableClass_1<[Compiler], void>;
afterResolvers: SyncHook<[Compiler], void>; afterResolvers: SyncHookImportTapableClass_1<[Compiler], void>;
entryOption: SyncBailHook<[string, EntryNormalized], boolean>; entryOption: SyncBailHook<[string, EntryNormalized], boolean>;
}>; }>;
name: string; name: string;
@ -1525,12 +1596,12 @@ declare interface Configuration {
/** /**
* Options for the resolver. * Options for the resolver.
*/ */
resolve?: ResolveOptions; resolve?: ResolveOptionsWebpackOptions;
/** /**
* Options for the resolver when resolving loaders. * Options for the resolver when resolving loaders.
*/ */
resolveLoader?: ResolveOptions; resolveLoader?: ResolveOptionsWebpackOptions;
/** /**
* Stats options object or preset name. * Stats options object or preset name.
@ -2664,6 +2735,24 @@ declare interface FileCacheOptions {
*/ */
version?: string; version?: string;
} }
declare interface FileSystem {
readFile: (
arg0: string,
arg1: (arg0: PossibleFileSystemError & Error, arg1: string | Buffer) => void
) => void;
readJson?: (
arg0: string,
arg1: (arg0: PossibleFileSystemError & Error, arg1?: any) => void
) => void;
readlink: (
arg0: string,
arg1: (arg0: PossibleFileSystemError & Error, arg1: string | Buffer) => void
) => void;
stat: (
arg0: string,
arg1: (arg0: PossibleFileSystemError & Error, arg1: FileSystemStats) => void
) => void;
}
declare abstract class FileSystemInfo { declare abstract class FileSystemInfo {
fs: InputFileSystem; fs: InputFileSystem;
logger: WebpackLogger; logger: WebpackLogger;
@ -2730,6 +2819,10 @@ declare interface FileSystemInfoEntry {
timestamp?: number; timestamp?: number;
timestampHash?: string; timestampHash?: string;
} }
declare interface FileSystemStats {
isDirectory: () => boolean;
isFile: () => boolean;
}
type Filename = string | ((pathData: PathData, assetInfo: AssetInfo) => string); type Filename = string | ((pathData: PathData, assetInfo: AssetInfo) => string);
type FilterItemTypes = string | RegExp | ((value: string) => boolean); type FilterItemTypes = string | RegExp | ((value: string) => boolean);
type FilterTypes = type FilterTypes =
@ -4241,11 +4334,11 @@ declare abstract class ModuleTemplate {
declare class MultiCompiler { declare class MultiCompiler {
constructor(compilers: Compiler[] | Record<string, Compiler>); constructor(compilers: Compiler[] | Record<string, Compiler>);
hooks: Readonly<{ hooks: Readonly<{
done: SyncHook<[MultiStats], void>; done: SyncHookImportTapableClass_1<[MultiStats], void>;
invalid: MultiHook<SyncHook<[string, string], void>>; invalid: MultiHook<SyncHookImportTapableClass_1<[string, string], void>>;
run: MultiHook<AsyncSeriesHook<[Compiler]>>; run: MultiHook<AsyncSeriesHookImportTapableClass_1<[Compiler]>>;
watchClose: SyncHook<[], void>; watchClose: SyncHookImportTapableClass_1<[], void>;
watchRun: MultiHook<AsyncSeriesHook<[Compiler]>>; watchRun: MultiHook<AsyncSeriesHookImportTapableClass_1<[Compiler]>>;
infrastructureLog: MultiHook<SyncBailHook<[string, string, any[]], true>>; infrastructureLog: MultiHook<SyncBailHook<[string, string, any[]], true>>;
}>; }>;
compilers: Compiler[]; compilers: Compiler[];
@ -4464,20 +4557,23 @@ declare class NormalModule extends Module {
static deserialize(context?: any): NormalModule; static deserialize(context?: any): NormalModule;
} }
declare interface NormalModuleCompilationHooks { declare interface NormalModuleCompilationHooks {
loader: SyncHook<[any, NormalModule], void>; loader: SyncHookImportTapableClass_1<[any, NormalModule], void>;
} }
declare abstract class NormalModuleFactory extends ModuleFactory { declare abstract class NormalModuleFactory extends ModuleFactory {
hooks: Readonly<{ hooks: Readonly<{
resolve: AsyncSeriesBailHook<[ResolveData], any>; resolve: AsyncSeriesBailHookImportTapableClass_1<[ResolveData], any>;
factorize: AsyncSeriesBailHook<[ResolveData], any>; factorize: AsyncSeriesBailHookImportTapableClass_1<[ResolveData], any>;
beforeResolve: AsyncSeriesBailHook<[ResolveData], any>; beforeResolve: AsyncSeriesBailHookImportTapableClass_1<[ResolveData], any>;
afterResolve: AsyncSeriesBailHook<[ResolveData], any>; afterResolve: AsyncSeriesBailHookImportTapableClass_1<[ResolveData], any>;
createModule: AsyncSeriesBailHook<[any, ResolveData], any>; createModule: AsyncSeriesBailHookImportTapableClass_1<
[any, ResolveData],
any
>;
module: SyncWaterfallHook<[Module, any, ResolveData]>; module: SyncWaterfallHook<[Module, any, ResolveData]>;
createParser: HookMap<SyncBailHook<any, any>>; createParser: HookMap<SyncBailHook<any, any>>;
parser: HookMap<SyncHook<any, void>>; parser: HookMap<SyncHookImportTapableClass_1<any, void>>;
createGenerator: HookMap<SyncBailHook<any, any>>; createGenerator: HookMap<SyncBailHook<any, any>>;
generator: HookMap<SyncHook<any, void>>; generator: HookMap<SyncHookImportTapableClass_1<any, void>>;
}>; }>;
resolverFactory: ResolverFactory; resolverFactory: ResolverFactory;
ruleSet: RuleSet; ruleSet: RuleSet;
@ -5282,6 +5378,14 @@ declare interface OutputNormalized {
*/ */
webassemblyModuleFilename?: string; webassemblyModuleFilename?: string;
} }
declare interface ParsedIdentifier {
request: string;
query: string;
fragment: string;
directory: boolean;
module: boolean;
file: boolean;
}
declare class Parser { declare class Parser {
constructor(); constructor();
parse( parse(
@ -5339,6 +5443,15 @@ declare interface PerformanceOptions {
declare interface Plugin { declare interface Plugin {
apply: () => void; apply: () => void;
} }
declare interface PnpApiImpl {
resolveToUnqualified: (arg0: string, arg1: string, arg2?: any) => string;
}
declare interface PossibleFileSystemError {
code?: string;
errno?: number;
path?: string;
syscall?: string;
}
declare class PrefetchPlugin { declare class PrefetchPlugin {
constructor(context?: any, request?: any); constructor(context?: any, request?: any);
context: any; context: any;
@ -5754,12 +5867,32 @@ declare interface ResolveBuildDependenciesResult {
missing: Set<string>; missing: Set<string>;
}; };
} }
/**
* Resolve context
*/
declare interface ResolveContext { declare interface ResolveContext {
log?: (message: string) => void; contextDependencies?: { add: (T?: any) => void };
fileDependencies?: WriteOnlySet<string>;
contextDependencies?: WriteOnlySet<string>; /**
missingDependencies?: WriteOnlySet<string>; * files that was found on file system
*/
fileDependencies?: { add: (T?: any) => void };
/**
* dependencies that was not found on file system
*/
missingDependencies?: { add: (T?: any) => void };
/**
* set of hooks' calls. For instance, `resolve → parsedResolve → describedResolve`,
*/
stack?: Set<string>; stack?: Set<string>;
/**
* log function
*/
log?: (arg0: string) => void;
} }
declare interface ResolveData { declare interface ResolveData {
contextInfo: ModuleFactoryCreateDataContextInfo; contextInfo: ModuleFactoryCreateDataContextInfo;
@ -5772,11 +5905,53 @@ declare interface ResolveData {
missingDependencies: LazySet<string>; missingDependencies: LazySet<string>;
contextDependencies: LazySet<string>; contextDependencies: LazySet<string>;
} }
declare interface ResolveOptionsTypes {
alias: {
/**
* New request.
*/
alias: string | false | string[];
/**
* Request to be redirected.
*/
name: string;
/**
* Redirect only exact matching request.
*/
onlyModule?: boolean;
}[];
aliasFields: Set<LibraryExport>;
cachePredicate: (arg0: ResolveRequest) => boolean;
cacheWithContext: boolean;
/**
* A list of exports field condition names.
*/
conditionNames: Set<string>;
descriptionFiles: string[];
enforceExtension: boolean;
exportsFields: Set<LibraryExport>;
extensions: Set<string>;
fileSystem: FileSystem;
unsafeCache: any;
symlinks: boolean;
resolver?: Resolver;
modules: LibraryExport[];
mainFields: { name: string[]; forceRelative: boolean }[];
mainFiles: Set<string>;
plugins: (
| { apply: (arg0: Resolver) => void }
| ((this: Resolver, arg1: Resolver) => void)
)[];
pnpApi: PnpApiImpl;
resolveToContext: boolean;
restrictions: Set<string | RegExp>;
}
/** /**
* Options object for resolving requests. * Options object for resolving requests.
*/ */
declare interface ResolveOptions { declare interface ResolveOptionsWebpackOptions {
/** /**
* Redirect module requests. * Redirect module requests.
*/ */
@ -5805,7 +5980,7 @@ declare interface ResolveOptions {
/** /**
* Extra resolve options per dependency category. Typical categories are "commonjs", "amd", "esm". * Extra resolve options per dependency category. Typical categories are "commonjs", "amd", "esm".
*/ */
byDependency?: { [index: string]: ResolveOptions }; byDependency?: { [index: string]: ResolveOptionsWebpackOptions };
/** /**
* Enable caching of successfully resolved requests (cache entries are revalidated). * Enable caching of successfully resolved requests (cache entries are revalidated).
@ -5909,18 +6084,84 @@ declare interface ResolvePluginInstance {
*/ */
apply: (resolver?: any) => void; apply: (resolver?: any) => void;
} }
declare interface ResolveRequest {
path: DevTool;
request?: string;
query?: string;
fragment?: string;
directory?: boolean;
module?: boolean;
descriptionFilePath?: string;
descriptionFileRoot?: string;
descriptionFileData?: any;
relativePath?: string;
ignoreSymlinks?: boolean;
}
declare abstract class Resolver { declare abstract class Resolver {
fileSystem: FileSystem;
options: ResolveOptionsTypes;
hooks: {
resolveStep: SyncHookImportTapableClass_2<
[
AsyncSeriesBailHookImportTapableClass_2<
[ResolveRequest, ResolveContext],
ResolveRequest
>,
ResolveRequest
],
void
>;
noResolve: SyncHookImportTapableClass_2<[ResolveRequest, Error], void>;
resolve: AsyncSeriesBailHookImportTapableClass_2<
[ResolveRequest, ResolveContext],
ResolveRequest
>;
result: AsyncSeriesHookImportTapableClass_2<
[ResolveRequest, ResolveContext]
>;
};
ensureHook(
name:
| string
| AsyncSeriesBailHookImportTapableClass_2<
[ResolveRequest, ResolveContext],
ResolveRequest
>
): AsyncSeriesBailHookImportTapableClass_2<
[ResolveRequest, ResolveContext],
ResolveRequest
>;
getHook(
name:
| string
| AsyncSeriesBailHookImportTapableClass_2<
[ResolveRequest, ResolveContext],
ResolveRequest
>
): AsyncSeriesBailHookImportTapableClass_2<
[ResolveRequest, ResolveContext],
ResolveRequest
>;
resolveSync(context: any, path: string, request: string): DevTool;
resolve( resolve(
context: Object, context: any,
path: string, path: string,
request: string, request: string,
resolveContext: ResolveContext, resolveContext: ResolveContext,
callback: ( callback: (arg0: Error, arg1: DevTool, arg2: ResolveRequest) => void
err: NodeJS.ErrnoException,
result: string,
additionalInfo: Object
) => void
): void; ): void;
doResolve(
hook?: any,
request?: any,
message?: any,
resolveContext?: any,
callback?: any
): any;
parse(identifier: string): ParsedIdentifier;
isModule(path?: any): boolean;
isDirectory(path: string): boolean;
join(path?: any, request?: any): string;
normalize(path?: any): string;
} }
declare interface ResolverCache { declare interface ResolverCache {
direct: WeakMap<any, Resolver & WithOptions>; direct: WeakMap<any, Resolver & WithOptions>;
@ -5958,7 +6199,7 @@ declare abstract class ResolverFactory {
/** /**
* Extra resolve options per dependency category. Typical categories are "commonjs", "amd", "esm". * Extra resolve options per dependency category. Typical categories are "commonjs", "amd", "esm".
*/ */
byDependency?: { [index: string]: ResolveOptions }; byDependency?: { [index: string]: ResolveOptionsWebpackOptions };
/** /**
* Enable caching of successfully resolved requests (cache entries are revalidated). * Enable caching of successfully resolved requests (cache entries are revalidated).
*/ */
@ -6037,10 +6278,10 @@ declare abstract class ResolverFactory {
> >
>; >;
resolver: HookMap< resolver: HookMap<
SyncHook< SyncHookImportTapableClass_1<
[ [
Resolver, Resolver,
ResolveOptions, UserResolveOptions,
{ {
/** /**
* Redirect module requests. * Redirect module requests.
@ -6068,7 +6309,7 @@ declare abstract class ResolverFactory {
/** /**
* Extra resolve options per dependency category. Typical categories are "commonjs", "amd", "esm". * Extra resolve options per dependency category. Typical categories are "commonjs", "amd", "esm".
*/ */
byDependency?: { [index: string]: ResolveOptions }; byDependency?: { [index: string]: ResolveOptionsWebpackOptions };
/** /**
* Enable caching of successfully resolved requests (cache entries are revalidated). * Enable caching of successfully resolved requests (cache entries are revalidated).
*/ */
@ -6178,7 +6419,7 @@ declare abstract class ResolverFactory {
/** /**
* Extra resolve options per dependency category. Typical categories are "commonjs", "amd", "esm". * Extra resolve options per dependency category. Typical categories are "commonjs", "amd", "esm".
*/ */
byDependency?: { [index: string]: ResolveOptions }; byDependency?: { [index: string]: ResolveOptionsWebpackOptions };
/** /**
* Enable caching of successfully resolved requests (cache entries are revalidated). * Enable caching of successfully resolved requests (cache entries are revalidated).
*/ */
@ -6368,7 +6609,7 @@ declare interface RuleSetRule {
/** /**
* Options for the resolver. * Options for the resolver.
*/ */
resolve?: ResolveOptions; resolve?: ResolveOptionsWebpackOptions;
/** /**
* Match the resource path of the module. * Match the resource path of the module.
@ -7595,6 +7836,134 @@ declare interface UpdateHashContext {
*/ */
compilation: Compilation; compilation: Compilation;
} }
declare interface UserResolveOptions {
/**
* A list of module alias configurations or an object which maps key to value
*/
alias?:
| { [index: string]: string | false | string[] }
| {
/**
* New request.
*/
alias: string | false | string[];
/**
* Request to be redirected.
*/
name: string;
/**
* Redirect only exact matching request.
*/
onlyModule?: boolean;
}[];
/**
* A list of alias fields in description files
*/
aliasFields?: LibraryExport[];
/**
* A function which decides whether a request should be cached or not. An object is passed with at least `path` and `request` properties.
*/
cachePredicate?: (arg0: ResolveRequest) => boolean;
/**
* Whether or not the unsafeCache should include request context as part of the cache key.
*/
cacheWithContext?: boolean;
/**
* A list of description files to read from
*/
descriptionFiles?: string[];
/**
* A list of exports field condition names.
*/
conditionNames?: string[];
/**
* Enforce that a extension from extensions must be used
*/
enforceExtension?: boolean;
/**
* A list of exports fields in description files
*/
exportsFields?: LibraryExport[];
/**
* A list of extensions which should be tried for files
*/
extensions?: string[];
/**
* The file system which should be used
*/
fileSystem: FileSystem;
/**
* Use this cache object to unsafely cache the successful requests
*/
unsafeCache?: any;
/**
* Resolve symlinks to their symlinked location
*/
symlinks?: boolean;
/**
* A prepared Resolver to which the plugins are attached
*/
resolver?: Resolver;
/**
* A list of directories to resolve modules from, can be absolute path or folder name
*/
modules?: LibraryExport;
/**
* A list of main fields in description files
*/
mainFields?: (
| string
| string[]
| { name: LibraryExport; forceRelative: boolean }
)[];
/**
* A list of main files in directories
*/
mainFiles?: string[];
/**
* A list of additional resolve plugins which should be applied
*/
plugins?: (
| { apply: (arg0: Resolver) => void }
| ((this: Resolver, arg1: Resolver) => void)
)[];
/**
* A PnP API that should be used - null is "never", undefined is "auto"
*/
pnpApi?: PnpApiImpl;
/**
* Resolve to a context instead of a file
*/
resolveToContext?: boolean;
/**
* A list of resolve restrictions
*/
restrictions?: (string | RegExp)[];
/**
* Use only the sync constiants of the file system calls
*/
useSyncFileSystemCalls?: boolean;
}
declare abstract class VariableInfo { declare abstract class VariableInfo {
declaredScope: ScopeInfo; declaredScope: ScopeInfo;
freeName: string | true; freeName: string | true;
@ -7862,12 +8231,12 @@ declare interface WebpackOptionsNormalized {
/** /**
* Options for the resolver. * Options for the resolver.
*/ */
resolve: ResolveOptions; resolve: ResolveOptionsWebpackOptions;
/** /**
* Options for the resolver when resolving loaders. * Options for the resolver when resolving loaders.
*/ */
resolveLoader: ResolveOptions; resolveLoader: ResolveOptionsWebpackOptions;
/** /**
* Stats options object or preset name. * Stats options object or preset name.
@ -7910,9 +8279,6 @@ declare interface WithOptions {
*/ */
withOptions: (arg0?: any) => Resolver & WithOptions; withOptions: (arg0?: any) => Resolver & WithOptions;
} }
declare interface WriteOnlySet<T> {
add(item: T): void;
}
type __TypeWebpackOptions = (data: {}) => type __TypeWebpackOptions = (data: {}) =>
| string | string
| { | {
@ -8271,7 +8637,7 @@ declare namespace exports {
EntryNormalized, EntryNormalized,
LibraryOptions, LibraryOptions,
ModuleOptions, ModuleOptions,
ResolveOptions, ResolveOptionsWebpackOptions as ResolveOptions,
RuleSetRule, RuleSetRule,
Configuration, Configuration,
WebpackOptionsNormalized, WebpackOptionsNormalized,

View File

@ -2419,10 +2419,10 @@ end-of-stream@^1.1.0:
dependencies: dependencies:
once "^1.4.0" once "^1.4.0"
enhanced-resolve@5.0.0-beta.6: enhanced-resolve@5.0.0-beta.7:
version "5.0.0-beta.6" version "5.0.0-beta.7"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.0.0-beta.6.tgz#1606b86002f34e4eb82e5299df06722efafa6fb4" resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.0.0-beta.7.tgz#174f085396ac8edc734253f5b6aa9a05cb0d73b2"
integrity sha512-4LMyFuW56kf7DCOGDVbphVU1JDEaKaiLR/Wlw/SMzCqjS+Lib+3tgRbzuRBr+6QFM8OLQFD1S3N2sIL5kQk8Tg== integrity sha512-4r9mhIEedx7IsNgutSPyFtD0hKukbknr8Fuee36IXg9dYcAeDLb7l6LzBAeiDBgUKeFv+OgMSkCyp/SGCZ5Xag==
dependencies: dependencies:
graceful-fs "^4.2.0" graceful-fs "^4.2.0"
tapable "^2.0.0-beta.10" tapable "^2.0.0-beta.10"