Skip to content

Commit

Permalink
[webpack] Add missing ProvidePlugin (#4564)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brianzchen committed Jan 16, 2024
1 parent c097941 commit 208a92c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Expand Up @@ -163,4 +163,31 @@ describe('webpack', () => {
]
});
});

test('ProvidePlugin', () => {
webpack({
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser.js',
foo: ['bar', 'baz'],
}),
]
});

webpack({
plugins: [
new webpack.ProvidePlugin({
// $FlowExpectedError[incompatible-call]
foo: 1,
}),
]
});

webpack({
plugins: [
// $FlowExpectedError[incompatible-call]
new webpack.ProvidePlugin('test'),
]
});
});
});
11 changes: 11 additions & 0 deletions definitions/npm/webpack_v5.x.x/flow_v0.104.x-/webpack_v5.x.x.js
Expand Up @@ -769,6 +769,16 @@ declare module 'webpack' {
) => (percentage: number, msg: string, ...args: $ReadOnlyArray<string>) => void;
}

declare class ProvidePlugin {
constructor(definitions: { [key: string]: string | string[] }): $NonMaybeType<ResolveOptions['plugins']>[number];
definitions: { [key: string]: string | string[] };

/**
* Apply the plugin
*/
apply(compiler: WebpackCompiler | WebpackMultiCompiler): void;
}

declare function builder(
options: WebpackOptions,
callback?: Callback
Expand All @@ -786,6 +796,7 @@ declare module 'webpack' {
HotModuleReplacementPlugin: typeof HotModuleReplacementPlugin,
ContextReplacementPlugin: typeof ContextReplacementPlugin,
ProgressPlugin: typeof ProgressPlugin,
ProvidePlugin: typeof ProvidePlugin,
...
};
}

0 comments on commit 208a92c

Please sign in to comment.