Skip to content

Commit 3380893

Browse files
authored
feat: definePlugin helper (#2302)
* feat: add definePlugin * chore: changeset * fix: export helper
1 parent c49c03c commit 3380893

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

.changeset/honest-yaks-tan.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@rspack/cli": patch
3+
---
4+
5+
add definePlugin helper

packages/rspack-cli/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export * from "./types";
2-
export { RspackCLI, defineConfig } from "./rspack-cli";
2+
export { RspackCLI, defineConfig, definePlugin } from "./rspack-cli";

packages/rspack-cli/src/rspack-cli.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
import { normalizeEnv } from "./utils/options";
1717
import { loadRspackConfig } from "./utils/loadConfig";
1818
import { Mode } from "@rspack/core/src/config";
19+
import { RspackPluginInstance, RspackPluginFunction } from "@rspack/core";
1920

2021
type RspackEnv = "development" | "production";
2122
export class RspackCLI {
@@ -252,3 +253,10 @@ export class RspackCLI {
252253
export function defineConfig(config: RspackOptions): RspackOptions {
253254
return config;
254255
}
256+
257+
// Note: use union type will make apply function's `compiler` type to be `any`
258+
export function definePlugin(plugin: RspackPluginFunction): RspackPluginFunction
259+
export function definePlugin(plugin: RspackPluginInstance): RspackPluginInstance
260+
export function definePlugin(plugin: any): any {
261+
return plugin;
262+
}

0 commit comments

Comments
 (0)