From 7cc206974c8253fe15d9bbd6e82d5e74bc2cff62 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 26 Nov 2020 10:49:59 +0100 Subject: [PATCH 1/3] upgrade typescript major version --- .../HarmonyImportSpecifierDependency.js | 1 - package.json | 2 +- types.d.ts | 1411 ++++++----------- yarn.lock | 8 +- 4 files changed, 472 insertions(+), 950 deletions(-) diff --git a/lib/dependencies/HarmonyImportSpecifierDependency.js b/lib/dependencies/HarmonyImportSpecifierDependency.js index 3a0a6d877..e1100fe80 100644 --- a/lib/dependencies/HarmonyImportSpecifierDependency.js +++ b/lib/dependencies/HarmonyImportSpecifierDependency.js @@ -13,7 +13,6 @@ const HarmonyImportDependency = require("./HarmonyImportDependency"); /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ /** @typedef {import("../ChunkGraph")} ChunkGraph */ -/** @typedef {import("../Dependency")} Dependency */ /** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */ /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ diff --git a/package.json b/package.json index e69e7b3ed..9dfde49d4 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,7 @@ "toml": "^3.0.0", "tooling": "webpack/tooling#v1.10.0", "ts-loader": "^8.0.2", - "typescript": "^3.9.7", + "typescript": "^4.2.0-dev.20201130", "url-loader": "^4.1.0", "wast-loader": "^1.9.0", "webassembly-feature": "1.3.0", diff --git a/types.d.ts b/types.d.ts index de6df54e1..4df1c2b6d 100644 --- a/types.d.ts +++ b/types.d.ts @@ -277,17 +277,9 @@ declare abstract class AsyncDependenciesBlock extends DependenciesBlock { preloadOrder?: number; prefetchOrder?: number; name?: string; - entryOptions?: { name?: string } & Pick< - EntryDescriptionNormalized, - | "filename" - | "chunkLoading" - | "dependOn" - | "library" - | "runtime" - | "wasmLoading" - >; + entryOptions?: EntryOptions; }; - loc: SyntheticDependencyLocation | RealDependencyLocation; + loc: DependencyLocation; request: string; parent: DependenciesBlock; chunkName: string; @@ -409,11 +401,7 @@ declare abstract class BasicEvaluatedExpression { postfix: BasicEvaluatedExpression; wrappedInnerExpressions: any; identifier: string; - rootInfo: { - declaredScope: ScopeInfo; - freeName: string | true; - tagInfo: TagInfo; - }; + rootInfo: VariableInfoInterface; getMembers: () => string[]; expression: NodeEstreeIndex; isUnknown(): boolean; @@ -490,6 +478,7 @@ declare abstract class BasicEvaluatedExpression { setSideEffects(sideEffects?: boolean): BasicEvaluatedExpression; setExpression(expression?: any): BasicEvaluatedExpression; } +type BuildMeta = KnownBuildMeta & Record; declare abstract class ByTypeGenerator extends Generator { map: any; } @@ -594,6 +583,15 @@ declare class CachedSource extends Source { getCachedData(): any; } type CallExpression = SimpleCallExpression | NewExpression; +declare interface CallExpressionInfo { + type: "call"; + call: CallExpression; + calleeName: string; + rootInfo: string | VariableInfo; + getCalleeMembers: () => string[]; + name: string; + getMembers: () => string[]; +} declare interface CallbackCache { (err?: WebpackError, result?: T): void; } @@ -615,7 +613,7 @@ declare class Chunk { idNameHints: SortableSet; preventIntegration: boolean; filenameTemplate: string | ((arg0: PathData, arg1: AssetInfo) => string); - runtime: string | SortableSet; + runtime: RuntimeSpec; files: Set; auxiliaryFiles: Set; rendered: boolean; @@ -650,15 +648,7 @@ declare class Chunk { hasRuntime(): boolean; canBeInitial(): boolean; isOnlyInitial(): boolean; - getEntryOptions(): { name?: string } & Pick< - EntryDescriptionNormalized, - | "filename" - | "chunkLoading" - | "dependOn" - | "library" - | "runtime" - | "wasmLoading" - >; + getEntryOptions(): EntryOptions; addGroup(chunkGroup: ChunkGroup): void; removeGroup(chunkGroup: ChunkGroup): void; isInGroup(chunkGroup: ChunkGroup): boolean; @@ -791,31 +781,25 @@ declare class ChunkGraph { setModuleId(module: Module, id: string | number): void; getRuntimeId(runtime: string): string | number; setRuntimeId(runtime: string, id: string | number): void; - hasModuleHashes( - module: Module, - runtime: string | SortableSet - ): boolean; - getModuleHash(module: Module, runtime: string | SortableSet): string; - getRenderedModuleHash( - module: Module, - runtime: string | SortableSet - ): string; + hasModuleHashes(module: Module, runtime: RuntimeSpec): boolean; + getModuleHash(module: Module, runtime: RuntimeSpec): string; + getRenderedModuleHash(module: Module, runtime: RuntimeSpec): string; setModuleHashes( module: Module, - runtime: string | SortableSet, + runtime: RuntimeSpec, hash: string, renderedHash: string ): void; addModuleRuntimeRequirements( module: Module, - runtime: string | SortableSet, + runtime: RuntimeSpec, items: Set ): void; addChunkRuntimeRequirements(chunk: Chunk, items: Set): void; addTreeRuntimeRequirements(chunk: Chunk, items: Iterable): void; getModuleRuntimeRequirements( module: Module, - runtime: string | SortableSet + runtime: RuntimeSpec ): ReadonlySet; getChunkRuntimeRequirements(chunk: Chunk): ReadonlySet; getTreeRuntimeRequirements(chunk: Chunk): ReadonlySet; @@ -834,23 +818,15 @@ declare class ChunkGraph { } declare abstract class ChunkGroup { groupDebugId: number; - options: { preloadOrder?: number; prefetchOrder?: number; name?: string }; + options: ChunkGroupOptions; chunks: Chunk[]; - origins: { - module: Module; - loc: SyntheticDependencyLocation | RealDependencyLocation; - request: string; - }[]; + origins: OriginRecord[]; index: number; /** * when a new chunk is added to a chunkGroup, addingOptions will occur. */ - addOptions(options: { - preloadOrder?: number; - prefetchOrder?: number; - name?: string; - }): void; + addOptions(options: ChunkGroupOptions): void; /** * returns the name of current ChunkGroup @@ -903,11 +879,7 @@ declare abstract class ChunkGroup { hasBlock(block?: any): boolean; readonly blocksIterable: Iterable; addBlock(block: AsyncDependenciesBlock): boolean; - addOrigin( - module: Module, - loc: SyntheticDependencyLocation | RealDependencyLocation, - request: string - ): void; + addOrigin(module: Module, loc: DependencyLocation, request: string): void; getFiles(): string[]; remove(): void; sortItems(): void; @@ -945,6 +917,12 @@ declare abstract class ChunkGroup { getModuleIndex: (module: Module) => number; getModuleIndex2: (module: Module) => number; } + +declare interface ChunkGroupOptions { + preloadOrder?: number; + prefetchOrder?: number; + name?: string; +} declare interface ChunkHashContext { /** * the runtime template @@ -1037,7 +1015,7 @@ declare interface CodeGenerationContext { /** * the runtimes code should be generated for */ - runtime: string | SortableSet; + runtime: RuntimeSpec; /** * when in concatenated module, information about other concatenated modules @@ -1062,29 +1040,17 @@ declare interface CodeGenerationResult { } declare abstract class CodeGenerationResults { map: Map>; - get( - module: Module, - runtime: string | SortableSet - ): CodeGenerationResult; - getSource( - module: Module, - runtime: string | SortableSet, - sourceType: string - ): Source; + get(module: Module, runtime: RuntimeSpec): CodeGenerationResult; + getSource(module: Module, runtime: RuntimeSpec, sourceType: string): Source; getRuntimeRequirements( module: Module, - runtime: string | SortableSet + runtime: RuntimeSpec ): ReadonlySet; - getData( - module: Module, - runtime: string | SortableSet, - key: string - ): any; - add( - module: Module, - runtime: string | SortableSet, - result: CodeGenerationResult - ): void; + getData(module: Module, runtime: RuntimeSpec, key: string): any; + add(module: Module, runtime: RuntimeSpec, result: CodeGenerationResult): void; +} +declare interface Comparator { + (arg0: T, arg1: T): 0 | 1 | -1; } declare class CompatSource extends Source { constructor(sourceLike: SourceLike); @@ -1101,56 +1067,11 @@ declare class Compilation { failedModule: SyncHook<[Module, WebpackError]>; succeedModule: SyncHook<[Module]>; stillValidModule: SyncHook<[Module]>; - addEntry: SyncHook< - [ - Dependency, - { name?: string } & Pick< - EntryDescriptionNormalized, - | "filename" - | "chunkLoading" - | "dependOn" - | "library" - | "runtime" - | "wasmLoading" - > - ] - >; - failedEntry: SyncHook< - [ - Dependency, - { name?: string } & Pick< - EntryDescriptionNormalized, - | "filename" - | "chunkLoading" - | "dependOn" - | "library" - | "runtime" - | "wasmLoading" - >, - Error - ] - >; - succeedEntry: SyncHook< - [ - Dependency, - { name?: string } & Pick< - EntryDescriptionNormalized, - | "filename" - | "chunkLoading" - | "dependOn" - | "library" - | "runtime" - | "wasmLoading" - >, - Module - ] - >; + addEntry: SyncHook<[Dependency, EntryOptions]>; + failedEntry: SyncHook<[Dependency, EntryOptions, Error]>; + succeedEntry: SyncHook<[Dependency, EntryOptions, Module]>; dependencyReferencedExports: SyncWaterfallHook< - [ - (string[] | ReferencedExport)[], - Dependency, - string | SortableSet - ] + [(string[] | ReferencedExport)[], Dependency, RuntimeSpec] >; finishModules: AsyncSeriesHook<[Iterable]>; finishRebuildingModule: AsyncSeriesHook<[Module]>; @@ -1209,44 +1130,42 @@ declare class Compilation { beforeModuleAssets: SyncHook<[]>; shouldGenerateChunkAssets: SyncBailHook<[], boolean>; beforeChunkAssets: SyncHook<[]>; - additionalChunkAssets: Pick< - AsyncSeriesHook<[Set]>, - "tap" | "tapAsync" | "tapPromise" | "name" - > & - FakeHookMarker; - additionalAssets: Pick< - AsyncSeriesHook<[]>, - "tap" | "tapAsync" | "tapPromise" | "name" - > & - FakeHookMarker; - optimizeChunkAssets: Pick< - AsyncSeriesHook<[Set]>, - "tap" | "tapAsync" | "tapPromise" | "name" - > & - FakeHookMarker; - afterOptimizeChunkAssets: Pick< - AsyncSeriesHook<[Set]>, - "tap" | "tapAsync" | "tapPromise" | "name" - > & - FakeHookMarker; + additionalChunkAssets: FakeHook< + Pick< + AsyncSeriesHook<[Set]>, + "tap" | "tapAsync" | "tapPromise" | "name" + > + >; + additionalAssets: FakeHook< + Pick, "tap" | "tapAsync" | "tapPromise" | "name"> + >; + optimizeChunkAssets: FakeHook< + Pick< + AsyncSeriesHook<[Set]>, + "tap" | "tapAsync" | "tapPromise" | "name" + > + >; + afterOptimizeChunkAssets: FakeHook< + Pick< + AsyncSeriesHook<[Set]>, + "tap" | "tapAsync" | "tapPromise" | "name" + > + >; optimizeAssets: AsyncSeriesHook< [Record], - { additionalAssets?: true | Function } + ProcessAssetsAdditionalOptions >; afterOptimizeAssets: SyncHook<[Record]>; processAssets: AsyncSeriesHook< [Record], - { additionalAssets?: true | Function } + ProcessAssetsAdditionalOptions >; afterProcessAssets: SyncHook<[Record]>; processAdditionalAssets: AsyncSeriesHook<[Record]>; needAdditionalSeal: SyncBailHook<[], boolean>; afterSeal: AsyncSeriesHook<[]>; renderManifest: SyncWaterfallHook< - [ - (RenderManifestEntryTemplated | RenderManifestEntryStatic)[], - RenderManifestOptions - ] + [RenderManifestEntry[], RenderManifestOptions] >; fullHash: SyncHook<[Hash]>; chunkHash: SyncHook<[Chunk, Hash, ChunkHashContext]>; @@ -1314,7 +1233,7 @@ declare class Compilation { warnings: WebpackError[]; children: Compilation[]; logging: Map; - dependencyFactories: Map<{ new (...args: any[]): Dependency }, ModuleFactory>; + dependencyFactories: Map; dependencyTemplates: DependencyTemplates; childrenCounters: {}; usedChunkIds: Set; @@ -1378,31 +1297,13 @@ declare class Compilation { addEntry( context: string, entry: Dependency, - optionsOrName: - | string - | ({ name?: string } & Pick< - EntryDescriptionNormalized, - | "filename" - | "chunkLoading" - | "dependOn" - | "library" - | "runtime" - | "wasmLoading" - >), + optionsOrName: string | EntryOptions, callback: (err?: WebpackError, result?: Module) => void ): void; addInclude( context: string, dependency: Dependency, - options: { name?: string } & Pick< - EntryDescriptionNormalized, - | "filename" - | "chunkLoading" - | "dependOn" - | "library" - | "runtime" - | "wasmLoading" - >, + options: EntryOptions, callback: (err?: WebpackError, result?: Module) => void ): void; rebuildModule( @@ -1420,25 +1321,15 @@ declare class Compilation { processRuntimeRequirements(): void; addRuntimeModule(chunk: Chunk, module: RuntimeModule): void; addChunkInGroup( - groupOptions: - | string - | { preloadOrder?: number; prefetchOrder?: number; name?: string }, + groupOptions: string | ChunkGroupOptions, module: Module, - loc: SyntheticDependencyLocation | RealDependencyLocation, + loc: DependencyLocation, request: string ): ChunkGroup; addAsyncEntrypoint( - options: { name?: string } & Pick< - EntryDescriptionNormalized, - | "filename" - | "chunkLoading" - | "dependOn" - | "library" - | "runtime" - | "wasmLoading" - >, + options: EntryOptions, module: Module, - loc: SyntheticDependencyLocation | RealDependencyLocation, + loc: DependencyLocation, request: string ): Entrypoint; @@ -1450,7 +1341,7 @@ declare class Compilation { assignDepth(module: Module): void; getDependencyReferencedExports( dependency: Dependency, - runtime: string | SortableSet + runtime: RuntimeSpec ): (string[] | ReferencedExport)[]; removeReasonsOfDependencyBlock( module: Module, @@ -1477,9 +1368,7 @@ declare class Compilation { getAsset(name: string): Readonly; clearAssets(): void; createModuleAssets(): void; - getRenderManifest( - options: RenderManifestOptions - ): (RenderManifestEntryTemplated | RenderManifestEntryStatic)[]; + getRenderManifest(options: RenderManifestOptions): RenderManifestEntry[]; createChunkAssets(callback: (err?: WebpackError) => void): void; getPath( filename: string | ((arg0: PathData, arg1: AssetInfo) => string), @@ -1659,9 +1548,7 @@ declare class Compiler { outputPath: string; watching: Watching; outputFileSystem: OutputFileSystem; - intermediateFileSystem: InputFileSystem & - OutputFileSystem & - IntermediateFileSystemExtras; + intermediateFileSystem: IntermediateFileSystem; inputFileSystem: InputFileSystem; watchFileSystem: WatchFileSystem; recordsInputPath: string; @@ -1747,9 +1634,7 @@ declare interface ConcatenationBailoutReasonContext { } declare class ConcatenationScope { constructor( - modulesMap: - | (ConcatenatedModuleInfo | ExternalModuleInfo)[] - | Map, + modulesMap: ModuleInfo[] | Map, currentModule: ConcatenatedModuleInfo ); isModuleInScope(module: Module): boolean; @@ -1980,6 +1865,13 @@ declare interface Configuration { */ watchOptions?: WatchOptions; } +type ConnectionState = + | boolean + | typeof TRANSITIVE_ONLY + | typeof CIRCULAR_CONNECTION; +declare interface Constructor { + new (...params: any[]): any; +} declare class ConsumeSharedPlugin { constructor(options: ConsumeSharedPluginOptions); @@ -2056,6 +1948,9 @@ declare interface ConsumesConfig { declare interface ConsumesObject { [index: string]: string | ConsumesConfig; } +type ContainerOptionsFormat = + | Record + | (string | Record)[]; declare class ContainerPlugin { constructor(options: ContainerPluginOptions); @@ -2126,68 +2021,57 @@ declare class ContextExclusionPlugin { */ apply(compiler: Compiler): void; } +type ContextMode = + | "sync" + | "eager" + | "weak" + | "async-weak" + | "lazy" + | "lazy-once"; declare abstract class ContextModuleFactory extends ModuleFactory { hooks: Readonly<{ beforeResolve: AsyncSeriesWaterfallHook<[any]>; afterResolve: AsyncSeriesWaterfallHook<[any]>; contextModuleFiles: SyncWaterfallHook<[string[]]>; - alternatives: Pick< - AsyncSeriesWaterfallHook<[any[]]>, - "tap" | "tapAsync" | "tapPromise" | "name" - > & - FakeHookMarker; + alternatives: FakeHook< + Pick< + AsyncSeriesWaterfallHook<[any[]]>, + "tap" | "tapAsync" | "tapPromise" | "name" + > + >; alternativeRequests: AsyncSeriesWaterfallHook< - [ - any[], - { - mode: "sync" | "eager" | "weak" | "async-weak" | "lazy" | "lazy-once"; - recursive: boolean; - regExp: RegExp; - namespaceObject?: boolean | "strict"; - addon?: string; - chunkName?: string; - include?: RegExp; - exclude?: RegExp; - groupOptions?: RawChunkGroupOptions; - category?: string; - /** - * exports referenced from modules (won't be mangled) - */ - referencedExports?: string[][]; - resource: string; - resourceQuery?: string; - resourceFragment?: string; - resolveOptions: any; - } - ] + [any[], ContextModuleOptions] >; }>; resolverFactory: ResolverFactory; resolveDependencies( fs: InputFileSystem, - options: { - mode: "sync" | "eager" | "weak" | "async-weak" | "lazy" | "lazy-once"; - recursive: boolean; - regExp: RegExp; - namespaceObject?: boolean | "strict"; - addon?: string; - chunkName?: string; - include?: RegExp; - exclude?: RegExp; - groupOptions?: RawChunkGroupOptions; - category?: string; - /** - * exports referenced from modules (won't be mangled) - */ - referencedExports?: string[][]; - resource: string; - resourceQuery?: string; - resourceFragment?: string; - resolveOptions: any; - }, + options: ContextModuleOptions, callback: (err?: Error, dependencies?: ContextElementDependency[]) => any ): void; } + +declare interface ContextModuleOptions { + mode: ContextMode; + recursive: boolean; + regExp: RegExp; + namespaceObject?: boolean | "strict"; + addon?: string; + chunkName?: string; + include?: RegExp; + exclude?: RegExp; + groupOptions?: RawChunkGroupOptions; + category?: string; + + /** + * exports referenced from modules (won't be mangled) + */ + referencedExports?: string[][]; + resource: string; + resourceQuery?: string; + resourceFragment?: string; + resolveOptions: any; +} declare class ContextReplacementPlugin { constructor( resourceRegExp?: any, @@ -2239,6 +2123,9 @@ declare class DelegatedPlugin { */ apply(compiler: Compiler): void; } +declare interface DepConstructor { + new (...args: any[]): Dependency; +} declare abstract class DependenciesBlock { dependencies: Dependency[]; blocks: AsyncDependenciesBlock[]; @@ -2267,7 +2154,7 @@ declare class Dependency { constructor(); weak: boolean; optional: boolean; - loc: SyntheticDependencyLocation | RealDependencyLocation; + loc: DependencyLocation; readonly type: string; readonly category: string; getResourceIdentifier(): string; @@ -2282,14 +2169,11 @@ declare class Dependency { */ getReferencedExports( moduleGraph: ModuleGraph, - runtime: string | SortableSet + runtime: RuntimeSpec ): (string[] | ReferencedExport)[]; getCondition( moduleGraph: ModuleGraph - ): ( - arg0: ModuleGraphConnection, - arg1: string | SortableSet - ) => boolean | typeof TRANSITIVE_ONLY | typeof CIRCULAR_CONNECTION; + ): (arg0: ModuleGraphConnection, arg1: RuntimeSpec) => ConnectionState; /** * Returns the exported names @@ -2317,7 +2201,7 @@ declare class Dependency { getNumberOfIdOccurrences(): number; getModuleEvaluationSideEffectsState( moduleGraph: ModuleGraph - ): boolean | typeof TRANSITIVE_ONLY | typeof CIRCULAR_CONNECTION; + ): ConnectionState; serialize(__0: { write: any }): void; deserialize(__0: { read: any }): void; module: any; @@ -2325,6 +2209,10 @@ declare class Dependency { static NO_EXPORTS_REFERENCED: any[]; static EXPORTS_OBJECT_REFERENCED: any[][]; } +declare interface DependencyConstructor { + new (...args: any[]): Dependency; +} +type DependencyLocation = SyntheticDependencyLocation | RealDependencyLocation; declare abstract class DependencyTemplate { apply( dependency: Dependency, @@ -2366,7 +2254,7 @@ declare interface DependencyTemplateContext { /** * current runtimes, for which code is generated */ - runtime: string | SortableSet; + runtime: RuntimeSpec; /** * mutable array of init fragments for the current module @@ -2379,9 +2267,9 @@ declare interface DependencyTemplateContext { concatenationScope?: ConcatenationScope; } declare abstract class DependencyTemplates { - get(dependency: { new (...args: any[]): Dependency }): DependencyTemplate; + get(dependency: DependencyConstructor): DependencyTemplate; set( - dependency: { new (...args: any[]): Dependency }, + dependency: DependencyConstructor, dependencyTemplate: DependencyTemplate ): void; updateHash(part: string): void; @@ -2661,15 +2549,7 @@ declare interface EntryData { /** * options of the entrypoint */ - options: { name?: string } & Pick< - EntryDescriptionNormalized, - | "filename" - | "chunkLoading" - | "dependOn" - | "library" - | "runtime" - | "wasmLoading" - >; + options: EntryOptions; } declare abstract class EntryDependency extends ModuleDependency {} @@ -2775,49 +2655,26 @@ declare class EntryOptionPlugin { compiler: Compiler, name: string, desc: EntryDescriptionNormalized - ): { name?: string } & Pick< - EntryDescriptionNormalized, - | "filename" - | "chunkLoading" - | "dependOn" - | "library" - | "runtime" - | "wasmLoading" - >; + ): EntryOptions; } +type EntryOptions = { name?: string } & Pick< + EntryDescriptionNormalized, + | "filename" + | "chunkLoading" + | "dependOn" + | "library" + | "runtime" + | "wasmLoading" +>; declare class EntryPlugin { /** * An entry plugin which will handle * creation of the EntryDependency */ - constructor( - context: string, - entry: string, - options: - | string - | ({ name?: string } & Pick< - EntryDescriptionNormalized, - | "filename" - | "chunkLoading" - | "dependOn" - | "library" - | "runtime" - | "wasmLoading" - >) - ); + constructor(context: string, entry: string, options: string | EntryOptions); context: string; entry: string; - options: - | string - | ({ name?: string } & Pick< - EntryDescriptionNormalized, - | "filename" - | "chunkLoading" - | "dependOn" - | "library" - | "runtime" - | "wasmLoading" - >); + options: string | EntryOptions; /** * Apply the plugin @@ -2825,17 +2682,7 @@ declare class EntryPlugin { apply(compiler: Compiler): void; static createDependency( entry: string, - options: - | string - | ({ name?: string } & Pick< - EntryDescriptionNormalized, - | "filename" - | "chunkLoading" - | "dependOn" - | "library" - | "runtime" - | "wasmLoading" - >) + options: string | EntryOptions ): EntryDependency; } type EntryStatic = string | EntryObject | string[]; @@ -3006,32 +2853,26 @@ declare abstract class ExportInfo { exportsInfoOwned: boolean; exportsInfo: ExportsInfo; readonly canMangle: boolean; - setUsedInUnknownWay(runtime: string | SortableSet): boolean; - setUsedWithoutInfo(runtime: string | SortableSet): boolean; + setUsedInUnknownWay(runtime: RuntimeSpec): boolean; + setUsedWithoutInfo(runtime: RuntimeSpec): boolean; setHasUseInfo(): void; setUsedConditionally( - condition: (arg0: 0 | 1 | 2 | 3 | 4) => boolean, - newValue: 0 | 1 | 2 | 3 | 4, - runtime: string | SortableSet - ): boolean; - setUsed( - newValue: 0 | 1 | 2 | 3 | 4, - runtime: string | SortableSet + condition: (arg0: UsageStateType) => boolean, + newValue: UsageStateType, + runtime: RuntimeSpec ): boolean; + setUsed(newValue: UsageStateType, runtime: RuntimeSpec): boolean; setTarget( key?: any, connection?: ModuleGraphConnection, exportName?: string[] ): boolean; - getUsed(runtime: string | SortableSet): 0 | 1 | 2 | 3 | 4; + getUsed(runtime: RuntimeSpec): UsageStateType; /** * get used name */ - getUsedName( - fallbackName: string, - runtime: string | SortableSet - ): DevTool; + getUsedName(fallbackName: string, runtime: RuntimeSpec): DevTool; hasUsedName(): boolean; /** @@ -3107,6 +2948,7 @@ declare interface ExportSpec { */ export?: string[]; } +type ExportedVariableInfo = string | ScopeInfo | VariableInfo; declare abstract class ExportsInfo { readonly ownedExports: Iterable; readonly orderedOwnedExports: Iterable; @@ -3127,29 +2969,21 @@ declare abstract class ExportsInfo { targetKey?: any, targetModule?: ModuleGraphConnection ): boolean; - setUsedInUnknownWay(runtime: string | SortableSet): boolean; - setUsedWithoutInfo(runtime: string | SortableSet): boolean; - setAllKnownExportsUsed(runtime: string | SortableSet): boolean; - setUsedForSideEffectsOnly(runtime: string | SortableSet): boolean; - isUsed(runtime: string | SortableSet): boolean; - isModuleUsed(runtime: string | SortableSet): boolean; - getUsedExports( - runtime: string | SortableSet - ): boolean | SortableSet; + setUsedInUnknownWay(runtime: RuntimeSpec): boolean; + setUsedWithoutInfo(runtime: RuntimeSpec): boolean; + setAllKnownExportsUsed(runtime: RuntimeSpec): boolean; + setUsedForSideEffectsOnly(runtime: RuntimeSpec): boolean; + isUsed(runtime: RuntimeSpec): boolean; + isModuleUsed(runtime: RuntimeSpec): boolean; + getUsedExports(runtime: RuntimeSpec): boolean | SortableSet; getProvidedExports(): true | string[]; - getRelevantExports(runtime: string | SortableSet): ExportInfo[]; + getRelevantExports(runtime: RuntimeSpec): ExportInfo[]; isExportProvided(name: EntryItem): boolean; - getUsageKey(runtime: string | SortableSet): string; - isEquallyUsed( - runtimeA: string | SortableSet, - runtimeB: string | SortableSet - ): boolean; - getUsed( - name: EntryItem, - runtime: string | SortableSet - ): 0 | 1 | 2 | 3 | 4; - getUsedName(name: EntryItem, runtime: string | SortableSet): Target; - updateHash(hash: Hash, runtime: string | SortableSet): void; + getUsageKey(runtime: RuntimeSpec): string; + isEquallyUsed(runtimeA: RuntimeSpec, runtimeB: RuntimeSpec): boolean; + getUsed(name: EntryItem, runtime: RuntimeSpec): UsageStateType; + getUsedName(name: EntryItem, runtime: RuntimeSpec): Target; + updateHash(hash: Hash, runtime: RuntimeSpec): void; getRestoreProvidedData(): any; restoreProvided(__0: { otherProvided: any; @@ -3234,6 +3068,12 @@ type Expression = | AwaitExpression | ImportExpression | ChainExpression; +declare interface ExpressionExpressionInfo { + type: "expression"; + rootInfo: string | VariableInfo; + name: string; + getMembers: () => string[]; +} type ExternalItem = | string | RegExp @@ -3348,6 +3188,7 @@ declare interface FactorizeModuleOptions { originModule: Module; context?: string; } +type FakeHook = T & FakeHookMarker; declare interface FakeHookMarker {} declare interface FallbackCacheGroup { minSize: Record; @@ -3591,7 +3432,7 @@ declare interface GenerateContext { /** * the runtime */ - runtime: string | SortableSet; + runtime: RuntimeSpec; /** * when in concatenated module, information about other concatenated modules @@ -3688,7 +3529,7 @@ declare interface HashedModuleIdsPluginOptions { /** * The encoding to use when generating the hash, defaults to 'base64'. All encodings from Node.JS' hash.digest are supported. */ - hashDigest?: "base64" | "latin1" | "hex"; + hashDigest?: "hex" | "latin1" | "base64"; /** * The prefix length of the hash digest to use, defaults to 4. @@ -3762,6 +3603,7 @@ type IgnorePluginOptions = */ checkResource?: (resource: string, context: string) => boolean; }; +type ImportSource = string | SimpleLiteral | RegExpLiteral; /** * Options for infrastructure level logging. @@ -3822,6 +3664,9 @@ declare interface InputFileSystem { relative?: (arg0: string, arg1: string) => string; dirname?: (arg0: string) => string; } +type IntermediateFileSystem = InputFileSystem & + OutputFileSystem & + IntermediateFileSystemExtras; declare interface IntermediateFileSystemExtras { mkdirSync: (arg0: string) => void; createWriteStream: (arg0: string) => WriteStream; @@ -3831,6 +3676,7 @@ declare interface IntermediateFileSystemExtras { arg2: (arg0: NodeJS.ErrnoException) => void ) => void; } +type InternalCell = T | typeof TOMBSTONE | typeof UNDEFINED_MARKER; declare abstract class ItemCacheFacade { get(callback: CallbackCache): void; getPromise(): Promise; @@ -4048,19 +3894,13 @@ declare class JavascriptParser extends Parser { boolean | void >; label: HookMap>; - import: SyncBailHook< - [Statement, string | SimpleLiteral | RegExpLiteral], - boolean | void - >; + import: SyncBailHook<[Statement, ImportSource], boolean | void>; importSpecifier: SyncBailHook< - [Statement, string | SimpleLiteral | RegExpLiteral, string, string], + [Statement, ImportSource, string, string], boolean | void >; export: SyncBailHook<[Statement], boolean | void>; - exportImport: SyncBailHook< - [Statement, string | SimpleLiteral | RegExpLiteral], - boolean | void - >; + exportImport: SyncBailHook<[Statement, ImportSource], boolean | void>; exportDeclaration: SyncBailHook<[Statement, Declaration], boolean | void>; exportExpression: SyncBailHook<[Statement, Declaration], boolean | void>; exportSpecifier: SyncBailHook< @@ -4068,13 +3908,7 @@ declare class JavascriptParser extends Parser { boolean | void >; exportImportSpecifier: SyncBailHook< - [ - Statement, - string | SimpleLiteral | RegExpLiteral, - string, - string, - number - ], + [Statement, ImportSource, string, string, number], boolean | void >; preDeclarator: SyncBailHook< @@ -4128,7 +3962,7 @@ declare class JavascriptParser extends Parser { }>; sourceType: "module" | "script" | "auto"; scope: ScopeInfo; - state: Record & ParserStateBase; + state: ParserState; comments: any; semicolons: any; statementPath: ( @@ -4263,14 +4097,14 @@ declare class JavascriptParser extends Parser { walkLogicalExpression(expression?: any): void; walkAssignmentExpression(expression?: any): void; walkConditionalExpression(expression?: any): void; - walkNewExpression(expression?: any, args?: any): void; + walkNewExpression(expression?: any): void; walkYieldExpression(expression?: any): void; walkTemplateLiteral(expression?: any): void; walkTaggedTemplateExpression(expression?: any): void; walkClassExpression(expression?: any): void; walkChainExpression(expression: ChainExpression): void; walkImportExpression(expression?: any): void; - walkCallExpression(expression?: any, args?: any): void; + walkCallExpression(expression?: any): void; walkMemberExpression(expression?: any): void; walkMemberExpressionWithExpressionName( expression?: any, @@ -4288,7 +4122,7 @@ declare class JavascriptParser extends Parser { expr: MemberExpression, fallback: ( arg0: string, - arg1: string | ScopeInfo | VariableInfo, + arg1: ExportedVariableInfo, arg2: () => string[] ) => any, defined: (arg0: string) => any, @@ -4301,12 +4135,12 @@ declare class JavascriptParser extends Parser { ): R; callHooksForInfo( hookMap: HookMap>, - info: string | ScopeInfo | VariableInfo, + info: ExportedVariableInfo, ...args: AsArray ): R; callHooksForInfoWithFallback( hookMap: HookMap>, - info: string | ScopeInfo | VariableInfo, + info: ExportedVariableInfo, fallback: (arg0: string) => any, defined: () => any, ...args: AsArray @@ -4364,8 +4198,7 @@ declare class JavascriptParser extends Parser { | FunctionDeclaration | VariableDeclaration | ClassDeclaration, - commentsStartPos: number, - args?: any + commentsStartPos: number ): boolean; getComments(range?: any): any; isAsiPosition(pos: number): boolean; @@ -4376,11 +4209,8 @@ declare class JavascriptParser extends Parser { defineVariable(name?: any): void; undefineVariable(name?: any): void; isVariableDefined(name?: any): boolean; - getVariableInfo(name: string): string | ScopeInfo | VariableInfo; - setVariable( - name: string, - variableInfo: string | ScopeInfo | VariableInfo - ): void; + getVariableInfo(name: string): ExportedVariableInfo; + setVariable(name: string, variableInfo: ExportedVariableInfo): void; parseCommentOptions(range?: any): { options: any; errors: any }; extractMemberExpressionChain( expression: MemberExpression @@ -4421,32 +4251,17 @@ declare class JavascriptParser extends Parser { getMemberExpressionInfo( expression: MemberExpression, allowedTypes: number - ): - | { - type: "call"; - call: CallExpression; - calleeName: string; - rootInfo: string | VariableInfo; - getCalleeMembers: () => string[]; - name: string; - getMembers: () => string[]; - } - | { - type: "expression"; - rootInfo: string | VariableInfo; - name: string; - getMembers: () => string[]; - }; + ): CallExpressionInfo | ExpressionExpressionInfo; getNameForExpression( expression: MemberExpression ): { name: string; - rootInfo: string | ScopeInfo | VariableInfo; + rootInfo: ExportedVariableInfo; getMembers: () => string[]; }; - static ALLOWED_MEMBER_TYPES_ALL: number; - static ALLOWED_MEMBER_TYPES_EXPRESSION: number; - static ALLOWED_MEMBER_TYPES_CALL_EXPRESSION: number; + static ALLOWED_MEMBER_TYPES_ALL: 3; + static ALLOWED_MEMBER_TYPES_EXPRESSION: 2; + static ALLOWED_MEMBER_TYPES_CALL_EXPRESSION: 1; } declare class JsonpChunkLoadingRuntimeModule extends RuntimeModule { constructor(runtimeRequirements?: any); @@ -4847,7 +4662,7 @@ declare class Module extends DependenciesBlock { factoryMeta: any; useSourceMap: boolean; useSimpleSourceMap: boolean; - buildMeta: KnownBuildMeta & Record; + buildMeta: BuildMeta; buildInfo: any; presentationalDependencies: Dependency[]; id: string | number; @@ -4906,10 +4721,7 @@ declare class Module extends DependenciesBlock { moduleGraph: ModuleGraph, chunkGraph: ChunkGraph ): boolean; - hasReasons( - moduleGraph: ModuleGraph, - runtime: string | SortableSet - ): boolean; + hasReasons(moduleGraph: ModuleGraph, runtime: RuntimeSpec): boolean; needBuild( context: NeedBuildContext, callback: (arg0: WebpackError, arg1: boolean) => void @@ -4924,7 +4736,7 @@ declare class Module extends DependenciesBlock { build( options: WebpackOptionsNormalized, compilation: Compilation, - resolver: Resolver & WithOptions, + resolver: ResolverWithOptions, fs: InputFileSystem, callback: (arg0: WebpackError) => void ): void; @@ -4940,9 +4752,7 @@ declare class Module extends DependenciesBlock { getConcatenationBailoutReason( context: ConcatenationBailoutReasonContext ): string; - getSideEffectsConnectionState( - moduleGraph: ModuleGraph - ): boolean | typeof TRANSITIVE_ONLY | typeof CIRCULAR_CONNECTION; + getSideEffectsConnectionState(moduleGraph: ModuleGraph): ConnectionState; codeGeneration(context: CodeGenerationContext): CodeGenerationResult; chunkCondition(chunk: Chunk, compilation: Compilation): boolean; @@ -5106,7 +4916,7 @@ declare class ModuleGraph { getReadOnlyExportInfo(module: Module, exportName: string): ExportInfo; getUsedExports( module: Module, - runtime: string | SortableSet + runtime: RuntimeSpec ): boolean | SortableSet; getPreOrderIndex(module: Module): number; getPostOrderIndex(module: Module): number; @@ -5140,8 +4950,8 @@ declare class ModuleGraphConnection { weak?: boolean, condition?: ( arg0: ModuleGraphConnection, - arg1: string | SortableSet - ) => boolean | typeof TRANSITIVE_ONLY | typeof CIRCULAR_CONNECTION + arg1: RuntimeSpec + ) => ConnectionState ); originModule: Module; resolvedOriginModule: Module; @@ -5152,32 +4962,31 @@ declare class ModuleGraphConnection { conditional: boolean; condition: ( arg0: ModuleGraphConnection, - arg1: string | SortableSet - ) => boolean | typeof TRANSITIVE_ONLY | typeof CIRCULAR_CONNECTION; + arg1: RuntimeSpec + ) => ConnectionState; explanations: Set; clone(): ModuleGraphConnection; addCondition( condition: ( arg0: ModuleGraphConnection, - arg1: string | SortableSet - ) => boolean | typeof TRANSITIVE_ONLY | typeof CIRCULAR_CONNECTION + arg1: RuntimeSpec + ) => ConnectionState ): void; addExplanation(explanation: string): void; readonly explanation: string; active: void; - isActive(runtime: string | SortableSet): boolean; - isTargetActive(runtime: string | SortableSet): boolean; - getActiveState( - runtime: string | SortableSet - ): boolean | typeof TRANSITIVE_ONLY | typeof CIRCULAR_CONNECTION; + isActive(runtime: RuntimeSpec): boolean; + isTargetActive(runtime: RuntimeSpec): boolean; + getActiveState(runtime: RuntimeSpec): ConnectionState; setActive(value: boolean): void; static addConnectionStates: ( - a: boolean | typeof TRANSITIVE_ONLY | typeof CIRCULAR_CONNECTION, - b: boolean | typeof TRANSITIVE_ONLY | typeof CIRCULAR_CONNECTION - ) => boolean | typeof TRANSITIVE_ONLY | typeof CIRCULAR_CONNECTION; + a: ConnectionState, + b: ConnectionState + ) => ConnectionState; static TRANSITIVE_ONLY: typeof TRANSITIVE_ONLY; static CIRCULAR_CONNECTION: typeof CIRCULAR_CONNECTION; } +type ModuleInfo = ConcatenatedModuleInfo | ExternalModuleInfo; /** * Options affecting the normal modules (`NormalModuleFactory`). @@ -5358,9 +5167,7 @@ declare class MultiCompiler { inputFileSystem: InputFileSystem; outputFileSystem: OutputFileSystem; watchFileSystem: WatchFileSystem; - intermediateFileSystem: InputFileSystem & - OutputFileSystem & - IntermediateFileSystemExtras; + intermediateFileSystem: IntermediateFileSystem; getInfrastructureLogger(name?: any): WebpackLogger; setDependencies(compiler: Compiler, dependencies: string[]): void; validateDependencies(callback: CallbackFunction): boolean; @@ -5627,7 +5434,7 @@ declare class NormalModule extends Module { associatedObjectForCache?: any ): Source; createLoaderContext( - resolver: Resolver & WithOptions, + resolver: ResolverWithOptions, options: WebpackOptionsNormalized, compilation: Compilation, fs: InputFileSystem @@ -5642,7 +5449,7 @@ declare class NormalModule extends Module { doBuild( options: WebpackOptionsNormalized, compilation: Compilation, - resolver: Resolver & WithOptions, + resolver: ResolverWithOptions, fs: InputFileSystem, callback: (arg0: WebpackError) => void ): void; @@ -5665,19 +5472,7 @@ declare abstract class NormalModuleFactory extends ModuleFactory { hooks: Readonly<{ resolve: AsyncSeriesBailHook<[ResolveData], any>; resolveForScheme: HookMap< - AsyncSeriesBailHook< - [ - { - resource: string; - path: string; - query: string; - fragment: string; - data: Record; - }, - ResolveData - ], - true | void - > + AsyncSeriesBailHook<[ResourceDataWithData, ResolveData], true | void> >; factorize: AsyncSeriesBailHook<[ResolveData], any>; beforeResolve: AsyncSeriesBailHook<[ResolveData], any>; @@ -5717,7 +5512,7 @@ declare abstract class NormalModuleFactory extends ModuleFactory { createParser(type: string, parserOptions?: { [index: string]: any }): Parser; getGenerator(type?: any, generatorOptions?: {}): Generator; createGenerator(type?: any, generatorOptions?: {}): any; - getResolver(type?: any, resolveOptions?: any): Resolver & WithOptions; + getResolver(type?: any, resolveOptions?: any): ResolverWithOptions; } declare class NormalModuleReplacementPlugin { /** @@ -6147,6 +5942,11 @@ type OptimizationSplitChunksSizes = number | { [index: string]: number }; declare abstract class OptionsApply { process(options?: any, compiler?: any): void; } +declare interface OriginRecord { + module: Module; + loc: DependencyLocation; + request: string; +} declare class OriginalSource extends Source { constructor(source: string | Buffer, name: string); getName(): string; @@ -6620,6 +6420,9 @@ declare interface OutputNormalized { */ workerWasmLoading?: DevTool; } +declare interface ParameterizedComparator { + (arg0: TArg): Comparator; +} declare interface ParsedIdentifier { request: string; query: string; @@ -6633,9 +6436,10 @@ declare class Parser { constructor(); parse( source: string | Record | Buffer, - state: Record & ParserStateBase - ): Record & ParserStateBase; + state: ParserState + ): ParserState; } +type ParserState = Record & ParserStateBase; declare interface ParserStateBase { current: NormalModule; module: NormalModule; @@ -6648,7 +6452,7 @@ declare interface PathData { hashWithLength?: (arg0: number) => string; chunk?: Chunk | ChunkPathData; module?: Module | ModulePathData; - runtime?: string | SortableSet; + runtime?: RuntimeSpec; filename?: string; basename?: string; query?: string; @@ -6713,18 +6517,22 @@ declare interface PrintedElement { content: string; } declare interface Problem { - type: - | "unknown-argument" - | "unexpected-non-array-in-path" - | "unexpected-non-object-in-path" - | "multiple-values-unexpected" - | "invalid-value"; + type: ProblemType; path: string; argument: string; value?: any; index?: number; expected?: string; } +type ProblemType = + | "unknown-argument" + | "unexpected-non-array-in-path" + | "unexpected-non-object-in-path" + | "multiple-values-unexpected" + | "invalid-value"; +declare interface ProcessAssetsAdditionalOptions { + additionalAssets?: true | Function; +} declare class Profiler { constructor(inspector?: any); session: any; @@ -7043,6 +6851,9 @@ declare interface RenderContextObject { */ codeGenerationResults: CodeGenerationResults; } +type RenderManifestEntry = + | RenderManifestEntryTemplated + | RenderManifestEntryStatic; declare interface RenderManifestEntryStatic { render: () => Source; filename: string; @@ -7387,6 +7198,143 @@ declare interface ResolveOptionsWebpackOptions { useSyncFileSystemCalls?: boolean; } +/** + * Options object for resolving requests. + */ +declare interface ResolveOptionsWithDependencyType { + /** + * Redirect module requests. + */ + alias?: ResolveAlias; + + /** + * Fields in the description file (usually package.json) which are used to redirect requests inside the module. + */ + aliasFields?: EntryItem[]; + + /** + * Extra resolve options per dependency category. Typical categories are "commonjs", "amd", "esm". + */ + byDependency?: { [index: string]: ResolveOptionsWebpackOptions }; + + /** + * Enable caching of successfully resolved requests (cache entries are revalidated). + */ + cache?: boolean; + + /** + * Predicate function to decide which requests should be cached. + */ + cachePredicate?: (request: ResolveRequest) => boolean; + + /** + * 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 the resolver to use one of the extensions from the extensions option (User must specify requests without extension). + */ + 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[]; + + /** + * Redirect module requests when normal resolving fails. + */ + fallback?: ResolveAlias; + + /** + * Filesystem for the resolver. + */ + fileSystem?: InputFileSystem; + + /** + * Treats the request specified by the user as fully specified, meaning no extensions are added and the mainFiles in directories are not resolved (This doesn't affect requests from mainFields, aliasFields or aliases). + */ + fullySpecified?: boolean; + + /** + * Field names from the description file (usually package.json) which are used to provide internal request of a package (requests starting with # are considered as internal). + */ + importsFields?: string[]; + + /** + * Field names from the description file (package.json) which are used to find the default entry point. + */ + mainFields?: EntryItem[]; + + /** + * 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)[]; + + /** + * Prefer to resolve module requests as relative request and fallback to resolving as module. + */ + preferRelative?: boolean; + + /** + * Custom resolver. + */ + resolver?: Resolver; + + /** + * A list of resolve restrictions. Resolve results must fulfill all of these restrictions to resolve successfully. Other resolve paths are taken when restrictions are not met. + */ + restrictions?: (string | RegExp)[]; + + /** + * A list of directories in which requests that are server-relative URLs (starting with '/') are resolved. On non-windows system these requests are tried to resolve as absolute path first. + */ + roots?: string[]; + + /** + * 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; + resolveToContext?: boolean; +} + /** * Plugin instance. */ @@ -7449,354 +7397,32 @@ declare abstract class Resolver { normalize(path?: any): string; } declare interface ResolverCache { - direct: WeakMap; - stringified: Map; + direct: WeakMap; + stringified: Map; } declare abstract class ResolverFactory { hooks: Readonly<{ resolveOptions: HookMap< - SyncWaterfallHook< - [ - { - /** - * Redirect module requests. - */ - alias?: ResolveAlias; - /** - * Fields in the description file (usually package.json) which are used to redirect requests inside the module. - */ - aliasFields?: EntryItem[]; - /** - * Extra resolve options per dependency category. Typical categories are "commonjs", "amd", "esm". - */ - byDependency?: { [index: string]: ResolveOptionsWebpackOptions }; - /** - * Enable caching of successfully resolved requests (cache entries are revalidated). - */ - cache?: boolean; - /** - * Predicate function to decide which requests should be cached. - */ - cachePredicate?: (request: ResolveRequest) => boolean; - /** - * 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 the resolver to use one of the extensions from the extensions option (User must specify requests without extension). - */ - 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[]; - /** - * Redirect module requests when normal resolving fails. - */ - fallback?: ResolveAlias; - /** - * Filesystem for the resolver. - */ - fileSystem?: InputFileSystem; - /** - * Treats the request specified by the user as fully specified, meaning no extensions are added and the mainFiles in directories are not resolved (This doesn't affect requests from mainFields, aliasFields or aliases). - */ - fullySpecified?: boolean; - /** - * Field names from the description file (usually package.json) which are used to provide internal request of a package (requests starting with # are considered as internal). - */ - importsFields?: string[]; - /** - * Field names from the description file (package.json) which are used to find the default entry point. - */ - mainFields?: EntryItem[]; - /** - * 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)[]; - /** - * Prefer to resolve module requests as relative request and fallback to resolving as module. - */ - preferRelative?: boolean; - /** - * Custom resolver. - */ - resolver?: Resolver; - /** - * A list of resolve restrictions. Resolve results must fulfill all of these restrictions to resolve successfully. Other resolve paths are taken when restrictions are not met. - */ - restrictions?: (string | RegExp)[]; - /** - * A list of directories in which requests that are server-relative URLs (starting with '/') are resolved. On non-windows system these requests are tried to resolve as absolute path first. - */ - roots?: string[]; - /** - * 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; - resolveToContext?: boolean; - } - ] - > + SyncWaterfallHook<[ResolveOptionsWithDependencyType]> >; resolver: HookMap< - SyncHook< - [ - Resolver, - UserResolveOptions, - { - /** - * Redirect module requests. - */ - alias?: ResolveAlias; - /** - * Fields in the description file (usually package.json) which are used to redirect requests inside the module. - */ - aliasFields?: EntryItem[]; - /** - * Extra resolve options per dependency category. Typical categories are "commonjs", "amd", "esm". - */ - byDependency?: { [index: string]: ResolveOptionsWebpackOptions }; - /** - * Enable caching of successfully resolved requests (cache entries are revalidated). - */ - cache?: boolean; - /** - * Predicate function to decide which requests should be cached. - */ - cachePredicate?: (request: ResolveRequest) => boolean; - /** - * 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 the resolver to use one of the extensions from the extensions option (User must specify requests without extension). - */ - 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[]; - /** - * Redirect module requests when normal resolving fails. - */ - fallback?: ResolveAlias; - /** - * Filesystem for the resolver. - */ - fileSystem?: InputFileSystem; - /** - * Treats the request specified by the user as fully specified, meaning no extensions are added and the mainFiles in directories are not resolved (This doesn't affect requests from mainFields, aliasFields or aliases). - */ - fullySpecified?: boolean; - /** - * Field names from the description file (usually package.json) which are used to provide internal request of a package (requests starting with # are considered as internal). - */ - importsFields?: string[]; - /** - * Field names from the description file (package.json) which are used to find the default entry point. - */ - mainFields?: EntryItem[]; - /** - * 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)[]; - /** - * Prefer to resolve module requests as relative request and fallback to resolving as module. - */ - preferRelative?: boolean; - /** - * Custom resolver. - */ - resolver?: Resolver; - /** - * A list of resolve restrictions. Resolve results must fulfill all of these restrictions to resolve successfully. Other resolve paths are taken when restrictions are not met. - */ - restrictions?: (string | RegExp)[]; - /** - * A list of directories in which requests that are server-relative URLs (starting with '/') are resolved. On non-windows system these requests are tried to resolve as absolute path first. - */ - roots?: string[]; - /** - * 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; - resolveToContext?: boolean; - } - ] - > + SyncHook<[Resolver, UserResolveOptions, ResolveOptionsWithDependencyType]> >; }>; cache: Map; get( type: string, - resolveOptions?: { - /** - * Redirect module requests. - */ - alias?: ResolveAlias; - /** - * Fields in the description file (usually package.json) which are used to redirect requests inside the module. - */ - aliasFields?: EntryItem[]; - /** - * Extra resolve options per dependency category. Typical categories are "commonjs", "amd", "esm". - */ - byDependency?: { [index: string]: ResolveOptionsWebpackOptions }; - /** - * Enable caching of successfully resolved requests (cache entries are revalidated). - */ - cache?: boolean; - /** - * Predicate function to decide which requests should be cached. - */ - cachePredicate?: (request: ResolveRequest) => boolean; - /** - * 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 the resolver to use one of the extensions from the extensions option (User must specify requests without extension). - */ - 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[]; - /** - * Redirect module requests when normal resolving fails. - */ - fallback?: ResolveAlias; - /** - * Filesystem for the resolver. - */ - fileSystem?: InputFileSystem; - /** - * Treats the request specified by the user as fully specified, meaning no extensions are added and the mainFiles in directories are not resolved (This doesn't affect requests from mainFields, aliasFields or aliases). - */ - fullySpecified?: boolean; - /** - * Field names from the description file (usually package.json) which are used to provide internal request of a package (requests starting with # are considered as internal). - */ - importsFields?: string[]; - /** - * Field names from the description file (package.json) which are used to find the default entry point. - */ - mainFields?: EntryItem[]; - /** - * 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)[]; - /** - * Prefer to resolve module requests as relative request and fallback to resolving as module. - */ - preferRelative?: boolean; - /** - * Custom resolver. - */ - resolver?: Resolver; - /** - * A list of resolve restrictions. Resolve results must fulfill all of these restrictions to resolve successfully. Other resolve paths are taken when restrictions are not met. - */ - restrictions?: (string | RegExp)[]; - /** - * A list of directories in which requests that are server-relative URLs (starting with '/') are resolved. On non-windows system these requests are tried to resolve as absolute path first. - */ - roots?: string[]; - /** - * 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; - resolveToContext?: boolean; - } - ): Resolver & WithOptions; + resolveOptions?: ResolveOptionsWithDependencyType + ): ResolverWithOptions; +} +type ResolverWithOptions = Resolver & WithOptions; + +declare interface ResourceDataWithData { + resource: string; + path: string; + query: string; + fragment: string; + data: Record; } declare interface RuleSet { /** @@ -8049,19 +7675,20 @@ declare class RuntimeModule extends Module { getGeneratedCode(): string; shouldIsolate(): boolean; } +type RuntimeSpec = string | SortableSet; declare abstract class RuntimeSpecMap { - get(runtime: string | SortableSet): T; - has(runtime: string | SortableSet): boolean; + get(runtime: RuntimeSpec): T; + has(runtime: RuntimeSpec): boolean; set(runtime?: any, value?: any): void; delete(runtime?: any): void; update(runtime?: any, fn?: any): void; - keys(): (string | SortableSet)[]; + keys(): RuntimeSpec[]; values(): IterableIterator; } declare abstract class RuntimeSpecSet { add(runtime?: any): void; has(runtime?: any): boolean; - [Symbol.iterator](): IterableIterator>; + [Symbol.iterator](): IterableIterator; readonly size: number; } declare abstract class RuntimeTemplate { @@ -8290,7 +7917,7 @@ declare abstract class RuntimeTemplate { /** * runtime for which this code will be generated */ - runtime?: string | SortableSet; + runtime?: RuntimeSpec; /** * only execute the statement in some runtimes */ @@ -8382,7 +8009,7 @@ declare abstract class RuntimeTemplate { /** * runtime for which this code will be generated */ - runtime: string | SortableSet; + runtime: RuntimeSpec; /** * if set, will be filled with runtime requirements */ @@ -8467,6 +8094,9 @@ declare interface ScopeInfo { inTry: boolean; } type ScriptType = false | "module" | "text/javascript"; +declare interface Selector { + (input: A): B; +} declare abstract class Serializer { serializeMiddlewares: any; deserializeMiddlewares: any; @@ -8862,8 +8492,8 @@ declare class SplitChunksPlugin { apply(compiler: Compiler): void; } declare abstract class StackedMap { - map: Map; - stack: Map[]; + map: Map>; + stack: Map>[]; set(item: K, value: V): void; delete(item: K): void; has(item: K): boolean; @@ -9389,7 +9019,7 @@ declare interface TimestampAndHash { declare const UNDEFINED_MARKER: unique symbol; declare interface UpdateHashContextDependency { chunkGraph: ChunkGraph; - runtime: string | SortableSet; + runtime: RuntimeSpec; runtimeTemplate?: RuntimeTemplate; } declare interface UpdateHashContextGenerator { @@ -9398,8 +9028,9 @@ declare interface UpdateHashContextGenerator { */ module: NormalModule; chunkGraph: ChunkGraph; - runtime: string | SortableSet; + runtime: RuntimeSpec; } +type UsageStateType = 0 | 1 | 2 | 3 | 4; declare interface UserResolveOptions { /** * A list of module alias configurations or an object which maps key to value @@ -9573,6 +9204,11 @@ declare abstract class VariableInfo { freeName: string | true; tagInfo: TagInfo; } +declare interface VariableInfoInterface { + declaredScope: ScopeInfo; + freeName: string | true; + tagInfo: TagInfo; +} declare interface WatchFileSystem { watch: ( files: Iterable, @@ -9710,7 +9346,7 @@ declare class WebWorkerTemplatePlugin { declare interface WebpackError extends Error { details: any; module: Module; - loc: SyntheticDependencyLocation | RealDependencyLocation; + loc: DependencyLocation; hideStack: boolean; chunk: Chunk; file: string; @@ -9947,115 +9583,8 @@ declare interface WithOptions { * create a resolver with additional/different options */ withOptions: ( - arg0: Partial<{ - /** - * Redirect module requests. - */ - alias?: ResolveAlias; - /** - * Fields in the description file (usually package.json) which are used to redirect requests inside the module. - */ - aliasFields?: EntryItem[]; - /** - * Extra resolve options per dependency category. Typical categories are "commonjs", "amd", "esm". - */ - byDependency?: { [index: string]: ResolveOptionsWebpackOptions }; - /** - * Enable caching of successfully resolved requests (cache entries are revalidated). - */ - cache?: boolean; - /** - * Predicate function to decide which requests should be cached. - */ - cachePredicate?: (request: ResolveRequest) => boolean; - /** - * 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 the resolver to use one of the extensions from the extensions option (User must specify requests without extension). - */ - 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[]; - /** - * Redirect module requests when normal resolving fails. - */ - fallback?: ResolveAlias; - /** - * Filesystem for the resolver. - */ - fileSystem?: InputFileSystem; - /** - * Treats the request specified by the user as fully specified, meaning no extensions are added and the mainFiles in directories are not resolved (This doesn't affect requests from mainFields, aliasFields or aliases). - */ - fullySpecified?: boolean; - /** - * Field names from the description file (usually package.json) which are used to provide internal request of a package (requests starting with # are considered as internal). - */ - importsFields?: string[]; - /** - * Field names from the description file (package.json) which are used to find the default entry point. - */ - mainFields?: EntryItem[]; - /** - * 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)[]; - /** - * Prefer to resolve module requests as relative request and fallback to resolving as module. - */ - preferRelative?: boolean; - /** - * Custom resolver. - */ - resolver?: Resolver; - /** - * A list of resolve restrictions. Resolve results must fulfill all of these restrictions to resolve successfully. Other resolve paths are taken when restrictions are not met. - */ - restrictions?: (string | RegExp)[]; - /** - * A list of directories in which requests that are server-relative URLs (starting with '/') are resolved. On non-windows system these requests are tried to resolve as absolute path first. - */ - roots?: string[]; - /** - * 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; - resolveToContext?: boolean; - }> - ) => Resolver & WithOptions; + arg0: Partial + ) => ResolverWithOptions; } type __TypeWebpackOptions = (data: {}) => | string @@ -10294,9 +9823,7 @@ declare namespace exports { export namespace container { export const scope: ( scope: string, - options: - | Record - | (string | Record)[] + options: ContainerOptionsFormat ) => Record; export { ContainerPlugin, @@ -10307,9 +9834,7 @@ declare namespace exports { export namespace sharing { export const scope: ( scope: string, - options: - | Record - | (string | Record)[] + options: ContainerOptionsFormat ) => Record; export { ConsumeSharedPlugin, ProvideSharedPlugin, SharePlugin }; } @@ -10324,23 +9849,25 @@ declare namespace exports { a: Module, b: Module ) => 0 | 1 | -1; - export let compareModulesById: ( - arg0: ChunkGraph - ) => (arg0: Module, arg1: Module) => 0 | 1 | -1; + export let compareModulesById: ParameterizedComparator< + ChunkGraph, + Module + >; export let compareNumbers: (a: number, b: number) => 0 | 1 | -1; export let compareStringsNumeric: (a: string, b: string) => 0 | 1 | -1; - export let compareModulesByPostOrderIndexOrIdentifier: ( - arg0: ModuleGraph - ) => (arg0: Module, arg1: Module) => 0 | 1 | -1; - export let compareModulesByPreOrderIndexOrIdentifier: ( - arg0: ModuleGraph - ) => (arg0: Module, arg1: Module) => 0 | 1 | -1; - export let compareModulesByIdOrIdentifier: ( - arg0: ChunkGraph - ) => (arg0: Module, arg1: Module) => 0 | 1 | -1; - export let compareChunks: ( - arg0: ChunkGraph - ) => (arg0: Chunk, arg1: Chunk) => 0 | 1 | -1; + export let compareModulesByPostOrderIndexOrIdentifier: ParameterizedComparator< + ModuleGraph, + Module + >; + export let compareModulesByPreOrderIndexOrIdentifier: ParameterizedComparator< + ModuleGraph, + Module + >; + export let compareModulesByIdOrIdentifier: ParameterizedComparator< + ChunkGraph, + Module + >; + export let compareChunks: ParameterizedComparator; export let compareIds: ( a: string | number, b: string | number @@ -10351,31 +9878,29 @@ declare namespace exports { b: ChunkGroup ) => 0 | 1 | -1; export let concatComparators: ( - c1: (arg0: T, arg1: T) => 0 | 1 | -1, - c2: (arg0: T, arg1: T) => 0 | 1 | -1, - ...cRest: ((arg0: T, arg1: T) => 0 | 1 | -1)[] - ) => (arg0: T, arg1: T) => 0 | 1 | -1; + c1: Comparator, + c2: Comparator, + ...cRest: Comparator[] + ) => Comparator; export let compareSelect: ( - getter: (input: T) => R, - comparator: (arg0: R, arg1: R) => 0 | 1 | -1 - ) => (arg0: T, arg1: T) => 0 | 1 | -1; + getter: Selector, + comparator: Comparator + ) => Comparator; export let compareIterables: ( - elementComparator: (arg0: T, arg1: T) => 0 | 1 | -1 - ) => (arg0: Iterable, arg1: Iterable) => 0 | 1 | -1; - export let keepOriginalOrder: ( - iterable: Iterable - ) => (arg0: T, arg1: T) => 0 | 1 | -1; + elementComparator: Comparator + ) => Comparator>; + export let keepOriginalOrder: (iterable: Iterable) => Comparator; export let compareChunksNatural: ( chunkGraph: ChunkGraph - ) => (arg0: Chunk, arg1: Chunk) => 0 | 1 | -1; + ) => Comparator; export let compareLocations: ( - a: SyntheticDependencyLocation | RealDependencyLocation, - b: SyntheticDependencyLocation | RealDependencyLocation + a: DependencyLocation, + b: DependencyLocation ) => 0 | 1 | -1; } export namespace serialization { export let register: ( - Constructor: { new (...params: any[]): any }, + Constructor: Constructor, request: string, name: string, serializer: ObjectSerializer @@ -10384,9 +9909,7 @@ declare namespace exports { regExp: RegExp, loader: (arg0: string) => boolean ) => void; - export let registerNotSerializable: (Constructor: { - new (...params: any[]): any; - }) => void; + export let registerNotSerializable: (Constructor: Constructor) => void; export let NOT_SERIALIZABLE: {}; export let buffersSerializer: Serializer; export let createFileSerializer: (fs?: any) => Serializer; @@ -10417,7 +9940,6 @@ declare namespace exports { this: Compiler, compiler: Compiler ) => void; - export type ParserState = Record & ParserStateBase; export { AutomaticPrefetchPlugin, BannerPlugin, @@ -10482,7 +10004,8 @@ declare namespace exports { RuleSetUseItem, Configuration, WebpackOptionsNormalized, - WebpackPluginInstance + WebpackPluginInstance, + ParserState }; } diff --git a/yarn.lock b/yarn.lock index 446b5d098..17b6e37b2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6472,10 +6472,10 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typescript@^3.9.7: - version "3.9.7" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa" - integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw== +typescript@^4.2.0-dev.20201130: + version "4.2.0-dev.20201130" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.0-dev.20201130.tgz#13339af4dfd23070dcd16f28e590efe541c766c4" + integrity sha512-oMboCGPKWDJ8BFmmanPAWw3LUGlEXSkkF+MbuHu97i1iF7K4z4zjmnodoD3Dilqs2IMuVDmWBIkmget9xMrpTw== uglify-js@^3.1.4: version "3.10.1" From c847009d87cfcfea528320efa9b0e16936b5b4cd Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 26 Nov 2020 13:12:49 +0100 Subject: [PATCH 2/3] typescript workarounds see https://github.com/microsoft/TypeScript/issues/41697 --- lib/WebpackOptionsApply.js | 12 ++++++++++++ lib/javascript/EnableChunkLoadingPlugin.js | 2 ++ lib/library/EnableLibraryPlugin.js | 8 ++++++++ lib/util/registerExternalSerializer.js | 7 ++++--- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lib/WebpackOptionsApply.js b/lib/WebpackOptionsApply.js index 3e4b6d616..c282e8992 100644 --- a/lib/WebpackOptionsApply.js +++ b/lib/WebpackOptionsApply.js @@ -76,14 +76,17 @@ class WebpackOptionsApply extends OptionsApply { new NodeTargetPlugin().apply(compiler); } if (options.externalsPresets.electronMain) { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const ElectronTargetPlugin = require("./electron/ElectronTargetPlugin"); new ElectronTargetPlugin("main").apply(compiler); } if (options.externalsPresets.electronPreload) { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const ElectronTargetPlugin = require("./electron/ElectronTargetPlugin"); new ElectronTargetPlugin("preload").apply(compiler); } if (options.externalsPresets.electronRenderer) { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const ElectronTargetPlugin = require("./electron/ElectronTargetPlugin"); new ElectronTargetPlugin("renderer").apply(compiler); } @@ -93,17 +96,21 @@ class WebpackOptionsApply extends OptionsApply { !options.externalsPresets.electronPreload && !options.externalsPresets.electronRenderer ) { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const ElectronTargetPlugin = require("./electron/ElectronTargetPlugin"); new ElectronTargetPlugin().apply(compiler); } if (options.externalsPresets.nwjs) { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const ExternalsPlugin = require("./ExternalsPlugin"); new ExternalsPlugin("commonjs", "nw.gui").apply(compiler); } if (options.externalsPresets.webAsync) { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const ExternalsPlugin = require("./ExternalsPlugin"); new ExternalsPlugin("import", /^(https?:\/\/|std:)/).apply(compiler); } else if (options.externalsPresets.web) { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const ExternalsPlugin = require("./ExternalsPlugin"); new ExternalsPlugin("module", /^(https?:\/\/|std:)/).apply(compiler); } @@ -155,6 +162,7 @@ class WebpackOptionsApply extends OptionsApply { } if (options.externals) { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const ExternalsPlugin = require("./ExternalsPlugin"); new ExternalsPlugin(options.externalsType, options.externals).apply( compiler @@ -420,6 +428,7 @@ class WebpackOptionsApply extends OptionsApply { break; } case "size": { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const OccurrenceChunkIdsPlugin = require("./ids/OccurrenceChunkIdsPlugin"); new OccurrenceChunkIdsPlugin({ prioritiseInitial: true @@ -427,6 +436,7 @@ class WebpackOptionsApply extends OptionsApply { break; } case "total-size": { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const OccurrenceChunkIdsPlugin = require("./ids/OccurrenceChunkIdsPlugin"); new OccurrenceChunkIdsPlugin({ prioritiseInitial: false @@ -478,6 +488,7 @@ class WebpackOptionsApply extends OptionsApply { const cacheOptions = options.cache; switch (cacheOptions.type) { case "memory": { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const MemoryCachePlugin = require("./cache/MemoryCachePlugin"); new MemoryCachePlugin().apply(compiler); break; @@ -488,6 +499,7 @@ class WebpackOptionsApply extends OptionsApply { const list = cacheOptions.buildDependencies[key]; new AddBuildDependenciesPlugin(list).apply(compiler); } + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const MemoryCachePlugin = require("./cache/MemoryCachePlugin"); new MemoryCachePlugin().apply(compiler); switch (cacheOptions.store) { diff --git a/lib/javascript/EnableChunkLoadingPlugin.js b/lib/javascript/EnableChunkLoadingPlugin.js index 6504cd65b..2cb2e28bc 100644 --- a/lib/javascript/EnableChunkLoadingPlugin.js +++ b/lib/javascript/EnableChunkLoadingPlugin.js @@ -81,6 +81,7 @@ class EnableChunkLoadingPlugin { break; } case "require": { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const CommonJsChunkLoadingPlugin = require("../node/CommonJsChunkLoadingPlugin"); new CommonJsChunkLoadingPlugin({ asyncChunkLoading: false @@ -88,6 +89,7 @@ class EnableChunkLoadingPlugin { break; } case "async-node": { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const CommonJsChunkLoadingPlugin = require("../node/CommonJsChunkLoadingPlugin"); new CommonJsChunkLoadingPlugin({ asyncChunkLoading: true diff --git a/lib/library/EnableLibraryPlugin.js b/lib/library/EnableLibraryPlugin.js index dd24659d8..1c9b64e83 100644 --- a/lib/library/EnableLibraryPlugin.js +++ b/lib/library/EnableLibraryPlugin.js @@ -76,6 +76,7 @@ class EnableLibraryPlugin { }).apply(compiler); switch (type) { case "var": { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const AssignLibraryPlugin = require("./AssignLibraryPlugin"); new AssignLibraryPlugin({ type, @@ -86,6 +87,7 @@ class EnableLibraryPlugin { break; } case "assign": { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const AssignLibraryPlugin = require("./AssignLibraryPlugin"); new AssignLibraryPlugin({ type, @@ -96,6 +98,7 @@ class EnableLibraryPlugin { break; } case "this": { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const AssignLibraryPlugin = require("./AssignLibraryPlugin"); new AssignLibraryPlugin({ type, @@ -106,6 +109,7 @@ class EnableLibraryPlugin { break; } case "window": { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const AssignLibraryPlugin = require("./AssignLibraryPlugin"); new AssignLibraryPlugin({ type, @@ -116,6 +120,7 @@ class EnableLibraryPlugin { break; } case "self": { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const AssignLibraryPlugin = require("./AssignLibraryPlugin"); new AssignLibraryPlugin({ type, @@ -126,6 +131,7 @@ class EnableLibraryPlugin { break; } case "global": { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const AssignLibraryPlugin = require("./AssignLibraryPlugin"); new AssignLibraryPlugin({ type, @@ -136,6 +142,7 @@ class EnableLibraryPlugin { break; } case "commonjs": { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const AssignLibraryPlugin = require("./AssignLibraryPlugin"); new AssignLibraryPlugin({ type, @@ -147,6 +154,7 @@ class EnableLibraryPlugin { } case "commonjs2": case "commonjs-module": { + //@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 const AssignLibraryPlugin = require("./AssignLibraryPlugin"); new AssignLibraryPlugin({ type, diff --git a/lib/util/registerExternalSerializer.js b/lib/util/registerExternalSerializer.js index bdf4bdc51..7bf3f9d13 100644 --- a/lib/util/registerExternalSerializer.js +++ b/lib/util/registerExternalSerializer.js @@ -308,10 +308,11 @@ register( register( ValidationError, CURRENT_MODULE, - "schema-util/ValidationError", + "schema-utils/ValidationError", new (class ValidationErrorSerializer { + // TODO error should be ValidationError, but this fails the type checks /** - * @param {ValidationError} error the source map source to be serialized + * @param {TODO} error the source map source to be serialized * @param {WebpackObjectSerializerContext} context context * @returns {void} */ @@ -327,7 +328,7 @@ register( /** * @param {ObjectDeserializerContext} context context - * @returns {ValidationError} error + * @returns {TODO} error */ deserialize({ read }) { return new ValidationError(read(), read(), read()); From 855a74d4a4525e673efdadf4ef3da22ef1559f3b Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 30 Nov 2020 08:42:07 +0100 Subject: [PATCH 3/3] workaround for https://github.com/microsoft/TypeScript/issues/41699 --- test/configCases/asset-modules/http-url/webpack.config.js | 6 +++++- test/configCases/asset-modules/https-url/webpack.config.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/test/configCases/asset-modules/http-url/webpack.config.js b/test/configCases/asset-modules/http-url/webpack.config.js index 0f7f0c0b5..4c3a2d4c1 100644 --- a/test/configCases/asset-modules/http-url/webpack.config.js +++ b/test/configCases/asset-modules/http-url/webpack.config.js @@ -1,4 +1,8 @@ -const { HttpUriPlugin } = require("../../../../").experiments.schemes; +const { + experiments: { + schemes: { HttpUriPlugin } + } +} = require("../../../../"); const ServerPlugin = require("./server"); /** @type {import("../../../../").Configuration} */ diff --git a/test/configCases/asset-modules/https-url/webpack.config.js b/test/configCases/asset-modules/https-url/webpack.config.js index a159c4452..6375d2a4f 100644 --- a/test/configCases/asset-modules/https-url/webpack.config.js +++ b/test/configCases/asset-modules/https-url/webpack.config.js @@ -1,4 +1,8 @@ -const { HttpsUriPlugin } = require("../../../../").experiments.schemes; +const { + experiments: { + schemes: { HttpsUriPlugin } + } +} = require("../../../../"); /** @type {import("../../../../").Configuration} */ module.exports = {