Skip to content

Commit

Permalink
fix(plugin-react): option useAbsoluatePath panic (#1827)
Browse files Browse the repository at this point in the history
  • Loading branch information
wre232114 authored Oct 13, 2024
1 parent e1f5c69 commit a4c0363
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/little-boats-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@farmfe/plugin-react": patch
---

Fix(plugin-react) useAbsolutePath is panic
5 changes: 4 additions & 1 deletion examples/react/farm.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig } from '@farmfe/core';
import react from '@farmfe/plugin-react';

export default defineConfig((env) => {
console.log(env);
Expand All @@ -23,6 +24,8 @@ export default defineConfig((env) => {
},
}
},
plugins: ['@farmfe/plugin-react', '@farmfe/plugin-sass']
plugins: [react({
useAbsolutePath: true
}), '@farmfe/plugin-sass']
};
});
6 changes: 6 additions & 0 deletions rust-plugins/react/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ impl FarmPluginReact {
let react_options = serde_json::from_str::<SwcTransformReactOptions>(&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::<serde_json::Map<String, serde_json::Value>>(&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,
Expand Down

0 comments on commit a4c0363

Please sign in to comment.