Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/honest-yaks-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rspack/cli": patch
---

add definePlugin helper
2 changes: 1 addition & 1 deletion packages/rspack-cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./types";
export { RspackCLI, defineConfig } from "./rspack-cli";
export { RspackCLI, defineConfig, definePlugin } from "./rspack-cli";
8 changes: 8 additions & 0 deletions packages/rspack-cli/src/rspack-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { normalizeEnv } from "./utils/options";
import { loadRspackConfig } from "./utils/loadConfig";
import { Mode } from "@rspack/core/src/config";
import { RspackPluginInstance, RspackPluginFunction } from "@rspack/core";

type RspackEnv = "development" | "production";
export class RspackCLI {
Expand Down Expand Up @@ -252,3 +253,10 @@ export class RspackCLI {
export function defineConfig(config: RspackOptions): RspackOptions {
return config;
}

// Note: use union type will make apply function's `compiler` type to be `any`
export function definePlugin(plugin: RspackPluginFunction): RspackPluginFunction
export function definePlugin(plugin: RspackPluginInstance): RspackPluginInstance
export function definePlugin(plugin: any): any {
return plugin;
}