Skip to content

Commit 8ebfc0e

Browse files
authored
Revert "fix(type): make the PostCSS plugin type loose (#5364)" (#5366)
1 parent 8772871 commit 8ebfc0e

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

packages/core/src/plugins/css.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ const getPostcssLoaderOptions = async ({
144144
root: string;
145145
postcssrcCache: PostcssrcCache;
146146
}): Promise<PostCSSLoaderOptions> => {
147-
const extraPlugins: unknown[] = [];
147+
const extraPlugins: AcceptedPlugin[] = [];
148148

149149
const utils = {
150-
addPlugins(plugins: unknown | unknown[]) {
150+
addPlugins(plugins: AcceptedPlugin | AcceptedPlugin[]) {
151151
extraPlugins.push(...castArray(plugins));
152152
},
153153
};
@@ -181,9 +181,7 @@ const getPostcssLoaderOptions = async ({
181181
// initialize the plugin to avoid multiple initialization
182182
// https://github.com/web-infra-dev/rsbuild/issues/3618
183183
options.plugins = options.plugins.map((plugin) =>
184-
isPostcssPluginCreator(plugin as AcceptedPlugin)
185-
? (plugin as PluginCreator<unknown>)()
186-
: plugin,
184+
isPostcssPluginCreator(plugin) ? plugin() : plugin,
187185
);
188186

189187
// always use postcss-load-config to load external config

packages/core/src/types/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import type {
4040
CSSLoaderOptions,
4141
HtmlRspackPlugin,
4242
PostCSSLoaderOptions,
43+
PostCSSPlugin,
4344
StyleLoaderOptions,
4445
WebpackConfig,
4546
} from './thirdParty';
@@ -60,7 +61,7 @@ export type ToolsBundlerChainConfig = OneOrMany<
6061

6162
export type ToolsPostCSSLoaderConfig = ConfigChainWithContext<
6263
PostCSSLoaderOptions,
63-
{ addPlugins: (plugins: unknown | unknown[]) => void }
64+
{ addPlugins: (plugins: PostCSSPlugin | PostCSSPlugin[]) => void }
6465
>;
6566

6667
export type ToolsCSSLoaderConfig = ConfigChain<CSSLoaderOptions>;

packages/core/src/types/thirdParty.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export type { WebpackConfig };
1919

2020
export type PostCSSOptions = ProcessOptions & {
2121
config?: boolean;
22-
plugins?: unknown[];
22+
plugins?: AcceptedPlugin[];
2323
};
2424

2525
export type PostCSSLoaderOptions = {

0 commit comments

Comments
 (0)