mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 07:17:04 +00:00
webpack: Add few missing type definitions on compilation.MainTemplate (#41368)
- adds mainTemplate.hooks.requireEnsure hook - adds mainTemplate.hooks.localVars hook - adds mainTemplate.renderRequireFunctionForModule method - adds mainTemplate.renderAddModule method
This commit is contained in:
committed by
Armando Aguirre
parent
8db5f5a772
commit
8ae07ce306
Vendored
+4
@@ -1073,9 +1073,13 @@ declare namespace webpack {
|
||||
hooks: {
|
||||
jsonpScript?: SyncWaterfallHook<string, Chunk, string>;
|
||||
requireExtensions: SyncWaterfallHook<string, Chunk, string>;
|
||||
requireEnsure: SyncWaterfallHook<string, Chunk, string>;
|
||||
localVars: SyncWaterfallHook<string, Chunk, string>;
|
||||
};
|
||||
outputOptions: Output;
|
||||
requireFn: string;
|
||||
renderRequireFunctionForModule(hash: string, chunk: Chunk, varModuleId?: number | string): string;
|
||||
renderAddModule(hash: string, chunk: Chunk, varModuleId: number | string | undefined, varModule: string): string;
|
||||
}
|
||||
class ChunkTemplate extends Tapable {}
|
||||
class HotUpdateChunkTemplate extends Tapable {}
|
||||
|
||||
@@ -307,6 +307,14 @@ configuration = {
|
||||
mainTemplate.hooks.requireExtensions.tap('SomePlugin', resource => {
|
||||
return resource.trimLeft();
|
||||
});
|
||||
mainTemplate.hooks.requireEnsure.tap('SomePlugin', (resource, chunk, hash, chunkIdExpression: string) => {
|
||||
mainTemplate.renderRequireFunctionForModule(hash, chunk, 'moduleId');
|
||||
mainTemplate.renderAddModule(hash, chunk, 'moduleId', JSON.stringify({ ok: true }));
|
||||
return `${resource};/* additional requests for ${chunkIdExpression} */`;
|
||||
});
|
||||
mainTemplate.hooks.localVars.tap('SomePlugin', resource => {
|
||||
return resource.trimLeft();
|
||||
});
|
||||
if (mainTemplate.hooks.jsonpScript == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user