analytics.d.ts 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * @license
  3. * Copyright Google Inc. All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. import { analytics } from '@angular-devkit/core';
  9. import { Compiler, Module, Stats, compilation } from 'webpack';
  10. import { Source } from 'webpack-sources';
  11. declare const NormalModule: any;
  12. interface NormalModule extends Module {
  13. _source?: Source | null;
  14. resource?: string;
  15. }
  16. /**
  17. * Faster than using a RegExp, so we use this to count occurences in source code.
  18. * @param source The source to look into.
  19. * @param match The match string to look for.
  20. * @param wordBreak Whether to check for word break before and after a match was found.
  21. * @return The number of matches found.
  22. * @private
  23. */
  24. export declare function countOccurrences(source: string, match: string, wordBreak?: boolean): number;
  25. /**
  26. * Holder of statistics related to the build.
  27. */
  28. declare class AnalyticsBuildStats {
  29. isIvy: boolean;
  30. errors: string[];
  31. numberOfNgOnInit: number;
  32. numberOfComponents: number;
  33. initialChunkSize: number;
  34. totalChunkCount: number;
  35. totalChunkSize: number;
  36. lazyChunkCount: number;
  37. lazyChunkSize: number;
  38. assetCount: number;
  39. assetSize: number;
  40. polyfillSize: number;
  41. cssSize: number;
  42. }
  43. /**
  44. * Analytics plugin that reports the analytics we want from the CLI.
  45. */
  46. export declare class NgBuildAnalyticsPlugin {
  47. protected _projectRoot: string;
  48. protected _analytics: analytics.Analytics;
  49. protected _category: string;
  50. protected _built: boolean;
  51. protected _stats: AnalyticsBuildStats;
  52. constructor(_projectRoot: string, _analytics: analytics.Analytics, _category: string);
  53. protected _reset(): void;
  54. protected _getMetrics(stats: Stats): (string | number)[];
  55. protected _getDimensions(stats: Stats): import("../../../../../dist-schema/packages/angular/cli/commands/config").Value[];
  56. protected _reportBuildMetrics(stats: Stats): void;
  57. protected _reportRebuildMetrics(stats: Stats): void;
  58. protected _checkTsNormalModule(module: NormalModule): void;
  59. protected _checkNgFactoryNormalModule(module: NormalModule): void;
  60. protected _collectErrors(stats: Stats): void;
  61. protected _collectBundleStats(json: any): void;
  62. /************************************************************************************************
  63. * The next section is all the different Webpack hooks for this plugin.
  64. */
  65. /**
  66. * Reports a succeed module.
  67. * @private
  68. */
  69. protected _succeedModule(mod: Module): void;
  70. protected _compilation(compiler: Compiler, compilation: compilation.Compilation): void;
  71. protected _done(stats: Stats): void;
  72. apply(compiler: Compiler): void;
  73. }
  74. export {};