duplicate-package-checker-webpack-plugin.d.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Type definitions for duplicate-package-checker-webpack-plugin 2.1
  2. // Project: https://github.com/darrenscerri/duplicate-package-checker-webpack-plugin#readme
  3. // Definitions by: Matt Traynham <https://github.com/mtraynham>
  4. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  5. // TypeScript Version: 2.3
  6. // Modified to work with Webpack 5 typings by Jason Grout <https://github.com/jasongrout>
  7. /* eslint-disable @typescript-eslint/interface-name-prefix */
  8. // Once to get a typed module first.
  9. declare module 'duplicate-package-checker-webpack-plugin';
  10. // Then we expand the definition with the things we use.
  11. declare module 'duplicate-package-checker-webpack-plugin' {
  12. export = DuplicatePackageCheckerWebpackPlugin;
  13. class DuplicatePackageCheckerWebpackPlugin {
  14. constructor(options?: DuplicatePackageCheckerWebpackPlugin.Options);
  15. apply(compiler: any): void;
  16. }
  17. namespace DuplicatePackageCheckerWebpackPlugin {
  18. /** The properties of the instance of a package */
  19. interface PackageInstanceProperties {
  20. /** The name of the package */
  21. name: string;
  22. /** The version of the package */
  23. version: string;
  24. /** Absolute path to the package */
  25. path: string;
  26. /** Absolute path to the module that requested the package */
  27. issuer?: string;
  28. }
  29. /** The configurable options for the plugin */
  30. interface Options {
  31. /** Also show module that is requiring each duplicate package (default: false) */
  32. verbose?: boolean;
  33. /** Emit errors instead of warnings (default: false) */
  34. emitError?: boolean;
  35. /** Show help message if duplicate packages are found (default: true) */
  36. showHelp?: boolean;
  37. /** Warn also if major versions differ (default: true) */
  38. strict?: boolean;
  39. /**
  40. * Exclude instances of packages from the results.
  41. * If all instances of a package are excluded, or all instances except one,
  42. * then the package is no longer considered duplicated and won't be emitted as a warning/error.
  43. * @param instance The instance of a package being evaluated for exclusion.
  44. * @returns true to exclude the instance, false otherwise
  45. */
  46. exclude?: (instance: PackageInstanceProperties) => boolean;
  47. }
  48. }
  49. }