diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index d15a516f97..38728ee46a 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -1073,9 +1073,13 @@ declare namespace webpack { hooks: { jsonpScript?: SyncWaterfallHook; requireExtensions: SyncWaterfallHook; + requireEnsure: SyncWaterfallHook; + localVars: SyncWaterfallHook; }; 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 {} diff --git a/types/webpack/webpack-tests.ts b/types/webpack/webpack-tests.ts index d128bac5db..ef75f2976b 100644 --- a/types/webpack/webpack-tests.ts +++ b/types/webpack/webpack-tests.ts @@ -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; }