Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typings #34

Merged
merged 2 commits into from
Jul 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 48 additions & 46 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,59 @@
import {MergeExclusive} from 'type-fest';
import {Compiler} from 'webpack';

export type Alias =
| 'Buffer'
| 'console'
| 'process'
| 'assert'
| 'buffer'
| 'console'
| 'constants'
| 'crypto'
| 'domain'
| 'events'
| 'http'
| 'https'
| 'os'
| 'path'
| 'punycode'
| 'process'
| 'querystring'
| 'stream'
| '_stream_duplex'
| '_stream_passthrough'
| '_stream_readable'
| '_stream_transform'
| '_stream_writable'
| 'string_decoder'
| 'sys'
| 'timers'
| 'tty'
| 'url'
| 'util'
| 'vm'
| 'zlib';
declare namespace NodePolyfillPlugin {
export type Alias =
| 'Buffer'
| 'console'
| 'process'
| 'assert'
| 'buffer'
| 'console'
| 'constants'
| 'crypto'
| 'domain'
| 'events'
| 'http'
| 'https'
| 'os'
| 'path'
| 'punycode'
| 'process'
| 'querystring'
| 'stream'
| '_stream_duplex'
| '_stream_passthrough'
| '_stream_readable'
| '_stream_transform'
| '_stream_writable'
| 'string_decoder'
| 'sys'
| 'timers'
| 'tty'
| 'url'
| 'util'
| 'vm'
| 'zlib';

interface IncludeOptions {
/**
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.
*/
includeAliases?: readonly Alias[];
}
export interface IncludeOptions {
/**
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.
*/
includeAliases?: readonly Alias[];
}

interface ExcludeOptions {
/**
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.
*/
excludeAliases?: readonly Alias[];
}
export interface ExcludeOptions {
/**
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.
*/
excludeAliases?: readonly Alias[];
}

export type Options = MergeExclusive<IncludeOptions, ExcludeOptions>;
export type Options = MergeExclusive<IncludeOptions, ExcludeOptions>;
}

declare class NodePolyfillPlugin {
constructor(options?: Options);
constructor(options?: NodePolyfillPlugin.Options);

apply(compiler: InstanceType<typeof Compiler>): void;
}
Expand Down