* Applies the plugin by registering its hooks on the compiler. * @param {Compiler} compiler the compiler instance * @returns {void}
(compiler)
| 2744 | * @returns {void} |
| 2745 | */ |
| 2746 | apply(compiler) { |
| 2747 | compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => { |
| 2748 | compilation.hooks.statsFactory.tap( |
| 2749 | PLUGIN_NAME, |
| 2750 | /** |
| 2751 | * Handles the callback logic for this hook. |
| 2752 | * @param {StatsFactory} stats stats factory |
| 2753 | * @param {NormalizedStatsOptions} options stats options |
| 2754 | */ |
| 2755 | (stats, options) => { |
| 2756 | iterateConfig(SIMPLE_EXTRACTORS, options, (hookFor, fn) => { |
| 2757 | stats.hooks.extract |
| 2758 | .for(hookFor) |
| 2759 | .tap(PLUGIN_NAME, (obj, data, ctx) => |
| 2760 | fn(obj, data, ctx, options, stats) |
| 2761 | ); |
| 2762 | }); |
| 2763 | iterateConfig(FILTER, options, (hookFor, fn) => { |
| 2764 | stats.hooks.filter |
| 2765 | .for(hookFor) |
| 2766 | .tap(PLUGIN_NAME, (item, ctx, idx, i) => |
| 2767 | fn(item, ctx, options, idx, i) |
| 2768 | ); |
| 2769 | }); |
| 2770 | iterateConfig(FILTER_RESULTS, options, (hookFor, fn) => { |
| 2771 | stats.hooks.filterResults |
| 2772 | .for(hookFor) |
| 2773 | .tap(PLUGIN_NAME, (item, ctx, idx, i) => |
| 2774 | fn(item, ctx, options, idx, i) |
| 2775 | ); |
| 2776 | }); |
| 2777 | iterateConfig(SORTERS, options, (hookFor, fn) => { |
| 2778 | stats.hooks.sort |
| 2779 | .for(hookFor) |
| 2780 | .tap(PLUGIN_NAME, (comparators, ctx) => |
| 2781 | fn(comparators, ctx, options) |
| 2782 | ); |
| 2783 | }); |
| 2784 | iterateConfig(RESULT_SORTERS, options, (hookFor, fn) => { |
| 2785 | stats.hooks.sortResults |
| 2786 | .for(hookFor) |
| 2787 | .tap(PLUGIN_NAME, (comparators, ctx) => |
| 2788 | fn(comparators, ctx, options) |
| 2789 | ); |
| 2790 | }); |
| 2791 | iterateConfig(RESULT_GROUPERS, options, (hookFor, fn) => { |
| 2792 | stats.hooks.groupResults |
| 2793 | .for(hookFor) |
| 2794 | .tap(PLUGIN_NAME, (groupConfigs, ctx) => |
| 2795 | fn(groupConfigs, ctx, options) |
| 2796 | ); |
| 2797 | }); |
| 2798 | for (const key of Object.keys(ITEM_NAMES)) { |
| 2799 | const itemName = ITEM_NAMES[key]; |
| 2800 | stats.hooks.getItemName.for(key).tap(PLUGIN_NAME, () => itemName); |
| 2801 | } |
| 2802 | for (const key of Object.keys(MERGER)) { |
| 2803 | const merger = MERGER[key]; |
nothing calls this directly
no test coverage detected