From a4c0363b41d811ee3823384705d10b1b330379cd Mon Sep 17 00:00:00 2001 From: brightwu <1521488775@qq.com> Date: Sun, 13 Oct 2024 09:47:52 +0800 Subject: [PATCH] fix(plugin-react): option useAbsoluatePath panic (#1827) --- .changeset/little-boats-watch.md | 5 +++++ examples/react/farm.config.js | 5 ++++- rust-plugins/react/src/lib.rs | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 .changeset/little-boats-watch.md diff --git a/.changeset/little-boats-watch.md b/.changeset/little-boats-watch.md new file mode 100644 index 000000000..590da6382 --- /dev/null +++ b/.changeset/little-boats-watch.md @@ -0,0 +1,5 @@ +--- +"@farmfe/plugin-react": patch +--- + +Fix(plugin-react) useAbsolutePath is panic diff --git a/examples/react/farm.config.js b/examples/react/farm.config.js index 31092e8b1..b35ddf3ac 100644 --- a/examples/react/farm.config.js +++ b/examples/react/farm.config.js @@ -1,4 +1,5 @@ import { defineConfig } from '@farmfe/core'; +import react from '@farmfe/plugin-react'; export default defineConfig((env) => { console.log(env); @@ -23,6 +24,8 @@ export default defineConfig((env) => { }, } }, - plugins: ['@farmfe/plugin-react', '@farmfe/plugin-sass'] + plugins: [react({ + useAbsolutePath: true + }), '@farmfe/plugin-sass'] }; }); diff --git a/rust-plugins/react/src/lib.rs b/rust-plugins/react/src/lib.rs index 090b6dd3a..0e1b8007e 100644 --- a/rust-plugins/react/src/lib.rs +++ b/rust-plugins/react/src/lib.rs @@ -39,6 +39,12 @@ impl FarmPluginReact { let react_options = serde_json::from_str::(&options).unwrap(); let is_dev = matches!(config.mode, farmfe_core::config::Mode::Development); + // remove useAbsolutePath in options + let mut options_obj = + serde_json::from_str::>(&options).unwrap(); + options_obj.remove("useAbsolutePath"); + let options = serde_json::to_string(&options_obj).unwrap(); + Self { core_lib: load_core_lib(config.core_lib_path.as_ref().unwrap()), options,