From d9c72f2dc43a2fb28b09bcdd738e50bd6caf99aa Mon Sep 17 00:00:00 2001 From: Qingyu Wang <40660121+colinaaa@users.noreply.github.com> Date: Mon, 19 May 2025 19:44:39 +0800 Subject: [PATCH] docs(react/transform): add docs for `extractStr` --- .changeset/free-facts-tell.md | 3 ++ packages/react/transform/index.d.ts | 29 ++++++++++++++++++- .../src/swc_plugin_extract_str/mod.rs | 24 +++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 .changeset/free-facts-tell.md diff --git a/.changeset/free-facts-tell.md b/.changeset/free-facts-tell.md new file mode 100644 index 0000000000..853d812bb3 --- /dev/null +++ b/.changeset/free-facts-tell.md @@ -0,0 +1,3 @@ +--- + +--- diff --git a/packages/react/transform/index.d.ts b/packages/react/transform/index.d.ts index 0649e3f782..b261df5cae 100644 --- a/packages/react/transform/index.d.ts +++ b/packages/react/transform/index.d.ts @@ -353,8 +353,35 @@ export interface DynamicImportVisitorConfig { /** @internal */ layer: string } +/** + * {@inheritdoc PluginReactLynxOptions.extractStr} + * @public + */ export interface ExtractStrConfig { - /** @public */ + /** + * @public + * The minimum length of string literals to be extracted. + * + * @remarks + * Default value: `20`. + * + * @example + * + * ```js + * import { defineConfig } from '@lynx-js/rspeedy' + * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' + * + * export default defineConfig({ + * plugins: [ + * pluginReactLynx({ + * extractStr: { + * strLength: 10, + * }, + * }) + * ], + * }) + * ``` + */ strLength: number /** @internal */ extractedStrArr?: Array diff --git a/packages/react/transform/src/swc_plugin_extract_str/mod.rs b/packages/react/transform/src/swc_plugin_extract_str/mod.rs index 79445622f6..8dda6b88ec 100644 --- a/packages/react/transform/src/swc_plugin_extract_str/mod.rs +++ b/packages/react/transform/src/swc_plugin_extract_str/mod.rs @@ -7,11 +7,35 @@ use swc_core::{ ecma::visit::{VisitMut, VisitMutWith}, quote, }; + +/// {@inheritdoc PluginReactLynxOptions.extractStr} +/// @public #[derive(PartialEq, Serialize, Deserialize, Clone, Debug)] #[serde(rename_all = "camelCase")] #[napi(object)] pub struct ExtractStrConfig { /// @public + /// The minimum length of string literals to be extracted. + /// + /// @remarks + /// Default value: `20`. + /// + /// @example + /// + /// ```js + /// import { defineConfig } from '@lynx-js/rspeedy' + /// import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' + /// + /// export default defineConfig({ + /// plugins: [ + /// pluginReactLynx({ + /// extractStr: { + /// strLength: 10, + /// }, + /// }) + /// ], + /// }) + /// ``` pub str_length: u32, /// @internal pub extracted_str_arr: Option>,