index.d.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* eslint-disable no-redeclare */
  2. import {MergeExclusive} from 'type-fest';
  3. import {Compiler} from 'webpack';
  4. declare namespace NodePolyfillPlugin {
  5. export type Alias =
  6. | 'Buffer'
  7. | 'console'
  8. | 'process'
  9. | 'assert'
  10. | 'buffer'
  11. | 'console'
  12. | 'constants'
  13. | 'crypto'
  14. | 'domain'
  15. | 'events'
  16. | 'http'
  17. | 'https'
  18. | 'os'
  19. | 'path'
  20. | 'punycode'
  21. | 'process'
  22. | 'querystring'
  23. | 'stream'
  24. | '_stream_duplex'
  25. | '_stream_passthrough'
  26. | '_stream_readable'
  27. | '_stream_transform'
  28. | '_stream_writable'
  29. | 'string_decoder'
  30. | 'sys'
  31. | 'timers'
  32. | 'tty'
  33. | 'url'
  34. | 'util'
  35. | 'vm'
  36. | 'zlib';
  37. export interface IncludeOptions {
  38. /**
  39. By default, the modules that were polyfilled in Webpack 4 are mirrored over. However, you can choose to only include certain aliases. For example, you can only have `console` polyfilled.
  40. */
  41. includeAliases?: readonly Alias[];
  42. }
  43. export interface ExcludeOptions {
  44. /**
  45. By default, the modules that were polyfilled in Webpack 4 are mirrored over. However, if you don't want a module like `console` to be polyfilled you can specify alises to be skipped here.
  46. */
  47. excludeAliases?: readonly Alias[];
  48. }
  49. export type Options = MergeExclusive<IncludeOptions, ExcludeOptions>;
  50. }
  51. declare class NodePolyfillPlugin {
  52. constructor(options?: NodePolyfillPlugin.Options);
  53. apply(compiler: InstanceType<typeof Compiler>): void;
  54. }
  55. export = NodePolyfillPlugin;