From aaaa2a08e657edcf3fd953b9ec8c1583627650c5 Mon Sep 17 00:00:00 2001 From: Mohsen Azimi Date: Sun, 13 May 2018 14:32:32 -0700 Subject: [PATCH] Add typing for webpack profiling plugin --- types/webpack/index.d.ts | 21 +++++++++++++++++++++ types/webpack/webpack-tests.ts | 7 +++++++ 2 files changed, 28 insertions(+) diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index 5be4abdcbd..403036d378 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -648,6 +648,27 @@ declare namespace webpack { portableRecords?: boolean; } } + + namespace debug { + interface ProfilingPluginOptions { + /** A relative path to a custom output file (json) */ + outputPath?: string; + } + /** + * Generate Chrome profile file which includes timings of plugins execution. Outputs `events.json` file by + * default. It is possible to provide custom file path using `outputPath` option. + * + * In order to view the profile file: + * * Run webpack with ProfilingPlugin. + * * Go to Chrome, open the Profile Tab. + * * Drag and drop generated file (events.json by default) into the profiler. + * + * It will then display timeline stats and calls per plugin! + */ + class ProfilingPlugin extends Plugin { + constructor(options?: ProfilingPluginOptions); + } + } namespace compilation { class Asset { } diff --git a/types/webpack/webpack-tests.ts b/types/webpack/webpack-tests.ts index b42d836c0c..ec5d0236a8 100644 --- a/types/webpack/webpack-tests.ts +++ b/types/webpack/webpack-tests.ts @@ -732,3 +732,10 @@ configuration = { ] } }; + +let profiling = new webpack.debug.ProfilingPlugin(); +profiling = new webpack.debug.ProfilingPlugin({ outputPath: './path.json' }); + +configuration = { + plugins: [profiling] +};