-
Notifications
You must be signed in to change notification settings - Fork 8
feat(rust-plugins): 🎸 update farm v2-beta #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughProject-wide migration to Farm v2 beta: updates workspace dependencies and toolchain, introduces prerelease changesets, bumps plugin package versions, and applies code/API adjustments across multiple Rust plugins (parser ownership, PathFilter path, filename transform params, source map/codegen, resource metadata). Worker plugin gains host_config flow; several plugins adapt to new finalize_resources and output naming. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App as Host App
participant WorkerPlg as Worker Plugin
participant Builder as Compiler
participant FS as FS Toolkit
Note over App,WorkerPlg: Initialize plugin with host_config (v2-beta)
App->>WorkerPlg: new(config, options{ host_config })
WorkerPlg-->>App: instance
Note over WorkerPlg,Builder: Resolve and build worker
WorkerPlg->>WorkerPlg: get_worker_url(module_id)
WorkerPlg->>FS: transform_output_filename({ filename_config, name, name_hash, bytes, ext, special_placeholders })
FS-->>WorkerPlg: output_name
WorkerPlg->>Builder: build_worker(resolved_path, module_id, compiler_config, host_config)
Builder-->>WorkerPlg: worker bundle (.mjs)
WorkerPlg-->>App: worker URL
sequenceDiagram
autonumber
participant Plugin as Any Plugin
participant Core as Core finalize_resources
participant FS as FS Toolkit
Note over Plugin,Core: Finalize resources (v2-beta structs)
Core->>Plugin: finalize_resources(&mut PluginFinalizeResourcesHookParam)
Plugin->>FS: transform_output_filename({ ...params })
FS-->>Plugin: name/out path
Plugin-->>Core: updated resources (with name_hash/meta/placeholders)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 15
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (11)
rust-plugins/dsv/src/lib.rs (1)
81-95: Replace unwraps to avoid build-time panics on malformed CSV/TSV.Unwraps on reader and each record can panic on invalid input. Handle errors and bail out gracefully.
Apply:
- let reader = get_reader(&binding); - - if reader.is_err() { - return Ok(None); - } - - let mut records = vec![]; - for result in reader.unwrap().records() { - let record = result.unwrap(); - let json_record: Value = record - .iter() - .map(|field| Value::String(field.to_string())) - .collect(); - records.push(json_record); - } + let mut records = vec![]; + match get_reader(&binding) { + Ok(mut rdr) => { + for result in rdr.records() { + match result { + Ok(record) => { + let json_record: Value = record + .iter() + .map(|field| Value::String(field.to_string())) + .collect(); + records.push(json_record); + } + Err(_) => { + // Abort transform instead of panicking on a bad row. + return Ok(None); + } + } + } + } + Err(_) => return Ok(None), + }rust-plugins/react-components/package.json (1)
75-78: Types won’t be published (files array missing "types")The package exports under
"./types/*"but"types"isn’t included in"files", which will break consumers after publish. Add"types"to the files list.Apply this diff:
"files": [ - "scripts", - "options.d.ts" + "scripts", + "types", + "options.d.ts" ]rust-plugins/svgr/src/react_compiler.rs (1)
12-21: Don’t panic on transform errors; propagate them.
unwrap()will crash the process on bad SVG. Return a Result and surface the error instead.-pub fn react_compiler(param: CompilerParams) -> String { +pub fn react_compiler(param: CompilerParams) -> Result<String, String> { let CompilerParams { svg, .. } = param; - let code = _react_compiler( + let code = _react_compiler( svg, Config { jsx_runtime: JSXRuntime::Classic, ..Default::default() }, Default::default(), - ) - .unwrap(); - code + ).map_err(|e| format!("{e}"))?; + Ok(code) }rust-plugins/image/src/lib.rs (1)
55-57: Potential move out of borrowed field; also avoid panic on file read.Use a reference for resolved_path and prefer unwrap_or_default().
Apply:
- let file_base64 = - general_purpose::STANDARD.encode(read_file_raw(param.resolved_path).unwrap_or(vec![])); + let file_base64 = general_purpose::STANDARD.encode( + read_file_raw(¶m.resolved_path).unwrap_or_default() + );Optionally, log and return Ok(None) on read errors instead of silently inlining empty data.
rust-plugins/react-components/src/insert_import.rs (1)
48-49: Bug: retain predicate should use AND, not ORCurrently keeps entries when either name differs, which fails to remove components imported via alias. Use
&&to keep only when both differ.Apply:
- components - .retain(|c| &c.name != imported_name || c.name != named_spec.local.sym.as_ref()); + components + .retain(|c| &c.name != imported_name && c.name != named_spec.local.sym.as_ref());rust-plugins/auto-import/src/parser/parse.rs (1)
112-116: Bug: type-only and value imports are invertedValue imports are going into
type_named_importsand type-only intonamed_imports. Swap the branches.Apply:
- if !named.is_type_only { - type_named_imports.insert(named.local.sym.to_string(), imported_name); - } else { - named_imports.insert(named.local.sym.to_string(), imported_name); - } + if named.is_type_only { + type_named_imports.insert(named.local.sym.to_string(), imported_name); + } else { + named_imports.insert(named.local.sym.to_string(), imported_name); + }rust-plugins/strip/src/lib.rs (1)
231-237: Bug: invalid AST for “void 0” — using an Ident yields invalid JS.Building (void 0) as an identifier prints a bare token that isn’t a valid identifier. Emit a real UnaryExpr instead.
Apply this diff:
-fn void_expr() -> Box<Expr> { - Box::new(Expr::Ident(Ident { - sym: "(void 0)".into(), - span: DUMMY_SP, - optional: false, - ctxt: SyntaxContext::empty(), - })) -} +fn void_expr() -> Box<Expr> { + Box::new(Expr::Unary(UnaryExpr { + op: UnaryOp::Void, + span: DUMMY_SP, + arg: Box::new(Expr::Lit(Lit::Num(Number { + span: DUMMY_SP, + value: 0.0 + }))), + })) +}rust-plugins/icons/src/compiler/react.rs (1)
1-1: Rename “complier” to “compiler” throughout rust-plugins/icons/src/compilerChange in react.rs:
-pub use svgr_rs::{transform as _react_complier, Config, JSXRuntime}; +pub use svgr_rs::{transform as _react_compiler, Config, JSXRuntime}; -pub fn react_complier(param: CompilerParams) -> String { +pub fn react_compiler(param: CompilerParams) -> String { - let code = _react_complier( + let code = _react_compiler(Change in preact.rs:
-pub use svgr_rs::{transform as react_complier, Config, JSXRuntime}; +pub use svgr_rs::{transform as react_compiler, Config, JSXRuntime}; - let code = react_complier( + let code = react_compiler(Update module export in mod.rs:
- react::react_complier + react::react_compilerRun:
rg -nP '\breact_complier\b|_react_complier\b'to verify no remaining occurrences.
rust-plugins/icons/src/cache/mod.rs (2)
53-58: Encode with the same config you decode withEnsure new entries are written using the same configuration to avoid future decode failures. (docs.rs)
- let serialized_data = bincode::encode_to_vec(&cache_value, config).unwrap(); + let serialized_data = bincode::encode_to_vec(&cache_value, config).unwrap();(No behavioral change after the previous comment; this is to emphasize config parity.)
41-47: Add HTTP client timeouts
reqwest::getuses a client without an explicit timeout; a slow server can stall the build. Prefer a sharedreqwest::Clientwith a sane timeout (e.g., 10–30s).Example (outside this hunk):
let client = reqwest::Client::builder() .timeout(Duration::from_secs(20)) .build() .unwrap(); let result = client.get(url).send().await;rust-plugins/worker/src/lib.rs (1)
209-213: Inline path fetches cache with the wrong keyYou insert by file_name but read by resolved_path, causing a panic.
Apply:
- let content_bytes = worker_cache.get(resolved_path).unwrap(); + let content_bytes = worker_cache.get(&file_name).unwrap();
🧹 Nitpick comments (55)
rust-plugins/modular-import/package.json (1)
3-3: Pre-release hygiene: set npm dist-tag and access.To avoid publishing beta as latest, add a publishConfig with tag and access.
"version": "0.1.0-beta.0", + "publishConfig": { "access": "public", "tag": "beta" },.changeset/blue-crabs-fail.md (1)
1-19: Changelog clarity: add brief per-plugin notes.Optional but helpful: one-line notes per plugin (API surface touched, behavioral changes) to aid consumers scanning release PRs.
rust-plugins/auto-import/package.json (1)
3-3: Pre-release hygiene: set npm dist-tag and access.Mirror the beta flow here to prevent accidental latest publishes.
"version": "0.1.0-beta.0", + "publishConfig": { "access": "public", "tag": "beta" },rust-plugins/worker/CHANGELOG.md (1)
3-7: Expand prerelease notes with migration highlights and PR linkAdd a brief list of notable changes impacting consumers (e.g., API changes, output naming, config flow) and link PR #137 to aid upgrade. Also consider wording “Farm v2 beta” instead of “v2-beta”.
Apply:
-## 0.1.0-beta.0 - -### Minor Changes - -- feat(rust-plugins): update farm v2-beta +## 0.1.0-beta.0 + +### Minor Changes + +- feat: migrate to Farm v2 beta + - Summarize any breaking/behavioral changes for this package (APIs, output names, config). + - See PR #137 for details.rust-plugins/worker/Cargo.toml (1)
19-20: rkyv versions are aligned; bytecheck features not required
Both theworkerandwasmcrates pin rkyv at 0.8.10, and no#[derive(Archive)]macros were detected—so you don’t need to enable bytecheck features.
Optional: consolidate rkyv into[workspace.dependencies]for simpler management:- rkyv = "0.8.10" + rkyv = { version = "0.8.10" }rust-plugins/icons/package.json (1)
3-3: Pre-release hygiene: dist-tag and toolchain pinTo ensure prereleases don’t publish under “latest” and the build uses the v2 beta toolchain, set an npm dist-tag and pin plugin-tools to the beta line.
Apply:
"devDependencies": { - "@farmfe/plugin-tools": "latest" + "@farmfe/plugin-tools": "^2.0.0-beta.0" }, + "publishConfig": { + "access": "public", + "tag": "beta" + },rust-plugins/image/package.json (1)
3-3: Pre-release hygiene: dist-tag and toolchain pinSame suggestion as other packages: publish under “beta” and pin plugin-tools to v2 beta to avoid CLI mismatches.
Apply:
"scripts": { "dev": "cargo watch -w src -s 'scripts/watch.sh'", "bump": "npx changeset version", "play": "cd playground && farm", "build": "farm-plugin-tools build --platform --cargo-name farmfe_plugin_image -p farmfe_plugin_image --release", "prepublishOnly": "farm-plugin-tools prepublish" }, + "publishConfig": { + "access": "public", + "tag": "beta" + },If this package also uses @farmfe/plugin-tools in devDependencies elsewhere, pin it to ^2.0.0-beta.x.
rust-plugins/url/package.json (1)
3-3: Pre-release hygiene: dist-tag and toolchain pinPublish with “beta” tag and pin plugin-tools to the beta channel for Farm v2.
Apply:
"devDependencies": { - "@farmfe/plugin-tools": "latest" + "@farmfe/plugin-tools": "^2.0.0-beta.0" }, + "publishConfig": { + "access": "public", + "tag": "beta" + },rust-plugins/icons/CHANGELOG.md (1)
3-8: Consider adding migration notes for v2-beta consumers.A brief “Migration Notes” subsection (breaking API changes, config updates, known caveats) will help users adopt v2-beta without guesswork.
## 0.1.0-beta.0 ### Minor Changes - feat(rust-plugins): update farm v2-beta +### Migration Notes +- Outline any breaking changes or config updates required for Farm v2-beta.rust-plugins/mdx/CHANGELOG.md (1)
3-8: Add brief notes on MDX ecosystem impact.Call out MDX parser/runtime version expectations or behavioral changes under Farm v2-beta to reduce integration surprises.
## 0.1.0-beta.0 ### Minor Changes - feat(rust-plugins): update farm v2-beta +### Notes +- Confirm supported MDX versions and any config changes needed with Farm v2-beta.rust-plugins/svgr/CHANGELOG.md (1)
3-8: Reflect dependency bumps in changelog.Since svgr-rs and xmltree were upgraded, list them for visibility and potential behavior diffs.
## 0.1.0-beta.0 ### Minor Changes - feat(rust-plugins): update farm v2-beta + - deps: svgr-rs 0.2.0, xmltree 0.11.0rust-plugins/wasm/package.json (2)
8-11: Avoid “latest” in devDependencies for reproducible builds.
Pin @farmfe/plugin-tools (caret or exact) to prevent surprise breakages in CI.
34-41: Pre-release publish tagging/engines.
If not already handled by .changeset/pre.json (tag: beta), add publishConfig.tag: "beta" and an engines.node (e.g., ">=18" or ">=20") to match @types/node 22.rust-plugins/svgr/package.json (1)
8-10: Pin dev toolchain.
Replace "latest" for @farmfe/plugin-tools with a pinned range to keep builds deterministic across the beta cycle.rust-plugins/mdx/package.json (1)
43-49: Optional: add engines.node for clarity.
Document the supported Node range (>=18/20) to align with your toolchain.rust-plugins/virtual/CHANGELOG.md (1)
3-8: Changelog entry is minimal; consider migration notes.
Add a one-liner on any behavioral changes or required config tweaks for Farm v2-beta consumers.rust-plugins/react-components/CHANGELOG.md (1)
3-8: Add actionable upgrade guidance.
A short note on any API/filename/output changes in v1.1.0-beta.0 will help adopters during the beta rollout.rust-plugins/react-components/Cargo.toml (1)
21-21: Move rustc-hash to dev-dependencies in Cargo.toml
rustc-hash is only referenced in tests (tests/mod.rs), so relocate it:[dependencies] -rustc-hash = "2.1.1" +[dev-dependencies] +rustc-hash = "2.1.1"Keep in mind FxHasher is non-randomized—avoid using FxHashMap on untrusted inputs in production.
rust-plugins/strip/package.json (1)
23-25: Pin plugin-tools instead of "latest" for reproducible builds.Floating "latest" can break builds unexpectedly. Prefer a caret range (e.g., ^x.y.z).
rust-toolchain.toml (1)
1-4: Optional: add profile = "minimal" to speed toolchain installs.Keeps installs lean; components are explicitly listed anyway.
[toolchain] +profile = "minimal" channel = "nightly-2025-05-06" components = ["clippy", "rustfmt", "rust-src", "rustc-dev"]rust-plugins/worker/package.json (1)
8-10: Avoid using "latest" for reproducible buildsPin
@farmfe/plugin-toolsto a semver range (e.g., ^x.y.z-beta.0) instead of"latest".rust-plugins/auto-import/CHANGELOG.md (1)
3-8: Consider adding migration notes for Farm v2-betaA brief note on API changes (e.g., PathFilter import move, normalize_path path) would aid adopters.
rust-plugins/strip/CHANGELOG.md (1)
3-8: Optional: enrich changelog with impact detailsCall out any breaking/behavioral changes (e.g., finalize_resources/output naming adjustments) to ease upgrades.
rust-plugins/image/CHANGELOG.md (1)
3-8: Clarify scope of the v2-beta upgrade in this plugin’s contextConsider adding one or two bullets on plugin-specific impacts (API changes, config keys, output naming, migration tips) rather than a single generic “update farm v2-beta” line. This helps consumers assess breakage risk quickly.
rust-plugins/auto-import/playground-vue/package.json (1)
17-17: Align CLI and core versions in playground-vue
- Update
@farmfe/clifrom^1.0.2to2.0.0-beta.0to match the core prerelease (CLI v2-beta exists).- Pin
@farmfe/coreto2.0.0-beta.0(remove the caret) to avoid unintentionally pulling newer beta releases.
Path: rust-plugins/auto-import/playground-vue/package.json lines 16–17.rust-plugins/yaml/CHANGELOG.md (1)
3-8: Add brief migration notes for usersSince this is a minor bump tied to Farm v2-beta, call out any YAML-specific behavior changes (e.g., resource metadata, filename transforms, sourcemap behavior) and note required config tweaks if any.
rust-plugins/modular-import/CHANGELOG.md (1)
1-8: Great to have an initial changelog; add purpose and first-release highlightsFor a brand-new plugin entry, add a one-liner describing the plugin’s goal and any notable capabilities or caveats in v2-beta. If there are known limitations, list them briefly.
rust-plugins/wasm/CHANGELOG.md (1)
3-8: Capture concrete changes relevant to wasm consumersGiven recent internal adjustments (e.g., filename transform params, cache traits, toolkit deps), add bullets on:
- required config field changes,
- output filename placeholder support,
- any cache behavior differences.
This will reduce upgrade friction.rust-plugins/worker/playground/farm.config.ts (2)
20-21: Typo in assets output path ("asserts" vs "assets").If unintentional, this will emit files under an "asserts" directory and break references.
- assetsFilename: 'asserts/[resourceName].[hash].[ext]', + assetsFilename: 'assets/[resourceName].[hash].[ext]',
25-25: Prefersatisfiesoverasto keep type safety.Use the TS
satisfiesoperator so mismatched keys don’t get erased by a type assertion.- } as UserConfig['compilation'] + } satisfies UserConfig['compilation']rust-plugins/react-components/playground/package.json (2)
25-25: Optional: bump CLI to match other playgounds.Other packages use
@farmfe/cli@^1.0.4. Aligning helps avoid CLI/core skew during local dev.- "@farmfe/cli": "^1.0.2", + "@farmfe/cli": "^1.0.4",
26-27: Standardize Farm v2 prerelease version spec across all packages
Multiple v2 packages use mixed prerelease versions and spec types—exact vs caret and β.0 vs β.2—leading to potential duplicate installs and API drift. Unify all to^2.0.0-beta.2:
- rust-plugins/react-components/playground/package.json: change
"2.0.0-beta.0"→"^2.0.0-beta.2"- rust-plugins/auto-import/playground-react/package.json: update
^2.0.0-beta.0→^2.0.0-beta.2- rust-plugins/auto-import/playground-vue/package.json: update
^2.0.0-beta.0→^2.0.0-beta.2- rust-plugins/wasm/playground/package.json: fix typo
bate→betaand bump to^2.0.0-beta.2- rust-plugins/worker/playground/package.json: fix typo and bump to
^2.0.0-beta.2rust-plugins/compress/playground/package.json (1)
20-21: Version skew with other playgrounds.This playground uses
^2.0.0-beta.2while react-components uses2.0.0-beta.0. Recommend converging on a single prerelease across the repo to avoid duplication and transitive incompatibilities.You can reuse the drift-check script from the other comment to list versions across packages.
rust-plugins/svgr/src/react_compiler.rs (1)
15-16: JSX runtime choice: Classic vs Automatic.Here you hardcode
JSXRuntime::Classicwhile playgounds configure React withruntime: "automatic"(see worker playground config). Consider parameterizing the runtime or aligning defaults to avoid mixing modes.rust-plugins/url/CHANGELOG.md (1)
3-8: Add release date and notes (if any breaking/migration steps).For prereleases, adding the release date and a brief note about v2-beta implications (if any) helps consumers.
Example:
- 0.1.0-beta.0 — 2025-09-02
- feat: update to Farm v2-beta
- note: requires @farmfe/core >= 2.0.0-beta
rust-plugins/icons/src/compiler/preact.rs (2)
1-5: Typo: “complier” → “compiler” (keep a compatibility alias).Spelling leaks into the public surface. Recommend renaming while preserving an alias to avoid breakage.
Apply:
-pub use svgr_rs::{transform as react_complier, Config, JSXRuntime}; +pub use svgr_rs::{transform as react_compiler, Config, JSXRuntime}; +// Back-compat alias (deprecated) +#[allow(deprecated)] +#[deprecated(note = "Use `react_compiler`")] +pub use react_compiler as react_complier; -pub fn preact_complier(param: CompilerParams) -> String { +pub fn preact_compiler(param: CompilerParams) -> String { let CompilerParams { svg, .. } = param; - let code = react_complier( + let code = react_compiler( svg, Config { jsx_runtime: JSXRuntime::ClassicPreact, ..Default::default() }, Default::default(), ) .unwrap(); code } + +#[deprecated(note = "Use `preact_compiler`")] +pub fn preact_complier(param: CompilerParams) -> String { + preact_compiler(param) +}
7-15: Avoid unwrap() panic; return Result instead.Transform failures would panic. Consider propagating errors.
Example:
-pub fn preact_compiler(param: CompilerParams) -> String { +pub fn preact_compiler(param: CompilerParams) -> Result<String, anyhow::Error> { let CompilerParams { svg, .. } = param; - let code = react_compiler( /* ... */ ).unwrap(); - code + let code = react_compiler( /* ... */ )?; + Ok(code) }rust-plugins/worker/playground/src/index.tsx (3)
3-3: Remove stale commented import or add a note.Small clean-up to reduce noise.
-// import TestWorker from "./worker/test.worker?worker" +// (legacy comlink worker import removed during v2 migration)
8-12: Improve robustness: consistent URL base and error handling for worker.Use a relative URL (respects non-root base) and add onerror.
-const worker = new Worker(new URL("/src/worker/test.worker.ts",import.meta.url)); +const worker = new Worker(new URL("./worker/test.worker.ts", import.meta.url)); worker.postMessage([5, 5]); worker.onmessage = (e) => { console.log('test worker', e.data); } +worker.onerror = (e) => { + console.error('test worker error', e); +}
16-19: Add worker error handler (mirrors the first worker).Catches runtime errors from vue.worker.ts.
worker2.postMessage([2, 3]); worker2.onmessage = (e) => { console.log('vue worker', e.data); } +worker2.onerror = (e) => { + console.error('vue worker error', e); +}Cargo.toml (1)
7-12: Normalize workspace dependency style for consistencyMinor: use the same table form everywhere; change
farmfe_toolkit = "2.0.0"to{ version = "2.0.0" }to match others.Apply:
- farmfe_toolkit = "2.0.0" + farmfe_toolkit = { version = "2.0.0" }rust-plugins/url/Cargo.toml (1)
17-17: Optional: unify serde managementConsider moving serde to
[workspace.dependencies]and using{ workspace = true, features = ["derive"] }across crates for uniformity.rust-plugins/react-components/src/insert_import.rs (1)
114-123: Avoid potential panic onparent().unwrap()Edge cases (path without parent) could panic. Default to current dir.
Apply:
- relative( - Path::new(&self.file_path) - .parent() - .unwrap() - .to_str() - .unwrap(), - &component.path, - ) + relative( + Path::new(&self.file_path) + .parent() + .and_then(|p| p.to_str()) + .unwrap_or("."), + &component.path, + )rust-plugins/auto-import/src/parser/parse.rs (1)
387-427: DRY: factor out common parse boilerplateThree functions repeat file/content resolution and
parse_modulesetup. Consider a small helper to reduce duplication.Also applies to: 430-468, 470-506
rust-plugins/strip/src/lib.rs (2)
37-41: Nit: “Pulgin” typo in plugin name/struct.If renaming won’t break external references, consider correcting to “Plugin” for consistency.
-const PLUGIN_NAME: &str = "FarmPulginStrip"; +const PLUGIN_NAME: &str = "FarmPluginStrip"; - -pub struct FarmPulginStrip { +pub struct FarmPluginStrip {If the string is externally consumed, keep name() stable and only rename the struct.
131-134: Prefer returning a structured error over println!/panic!.Surface parse failures via HookResult to avoid aborting the whole process abruptly.
- Err(err) => { - println!("{}", err.to_string()); - panic!("Parse {} failed. See error details above.", param.module_id); - } + Err(err) => { + return Err(farmfe_core::error::CompilationError::GenericError(format!( + "Parse {} failed: {}", + param.module_id, err + )) + .into()); + }rust-plugins/react-components/playground/src/types/components.d.ts (1)
19-20: Nit: inconsistent Ant global names (casing).*Antversion/Antmessage/Antnotification/Anttheme differ from PascalCase used elsewhere (e.g., AntImage). Consider normalizing for API clarity.
- const Antversion: typeof import('antd')['version'] + const AntVersion: typeof import('antd')['version'] - const Antmessage: typeof import('antd')['message'] + const AntMessage: typeof import('antd')['message'] - const Antnotification: typeof import('antd')['notification'] + const AntNotification: typeof import('antd')['notification'] - const Anttheme: typeof import('antd')['theme'] + const AntTheme: typeof import('antd')['theme']Also applies to: 81-99, 145-145
rust-plugins/icons/src/compiler/react.rs (1)
7-16: Avoid panic on transform failureUse
expect(at minimum) for a clearer failure, or bubble the error up.Apply:
- ) - .unwrap(); + ) + .expect("svgr_rs::transform failed in react_complier");Optional: change fn to return
Result<String, E>and propagate instead of panicking.rust-plugins/url/src/lib.rs (1)
140-146: Avoid double disk readReuse
raw_bytesinstead of reading the file again.Apply:
- let content = read_file_raw(param.resolved_path).unwrap(); + let content = raw_bytes.clone();rust-plugins/icons/src/cache/mod.rs (1)
29-31: Nit: simplify tuple destructuringIf you keep the direct decode, destructure the tuple to avoid
cached_value.0field access.- let cached_value:(CacheValue, usize) = bincode::decode_from_slice(&entry, config).unwrap(); - if cached_value.0.expiration > SystemTime::now() { + let (cached_value, _) = bincode::decode_from_slice::<CacheValue>(&entry, config).unwrap(); + if cached_value.expiration > SystemTime::now() {rust-plugins/react-components/src/find_local_components.rs (1)
330-335: Avoid temporary churn: precompute module id and reuse it
&components_path.clone().into()takes a reference to a temporary and is harder to read. Precompute once and pass the owned id; this also makes future changes (like logging) simpler.- let ParseScriptModuleResult { ast,..} = match parse_module( - &components_path.clone().into(), - file_content, + let module_id = components_path.clone().into(); + let ParseScriptModuleResult { ast, .. } = match parse_module( + &module_id, + file_content,rust-plugins/react-components/src/lib.rs (2)
164-171: Reuse the same Arc content to avoid an extra allocationYou already have
content; reuse it forparse_moduleto avoid cloning the String again.- let content = Arc::new(param.content.clone()); - let (cm, _) = create_swc_source_map(¶m.module_id.clone().into(), content); + let content = Arc::new(param.content.clone()); + let (cm, _) = create_swc_source_map(¶m.module_id.clone().into(), Arc::clone(&content)); @@ - ¶m.module_id.clone().into(), - Arc::new(param.content.clone()), + ¶m.module_id.clone().into(), + Arc::clone(&content),
129-136: Optional: version byte for cacheable transformsIf this plugin’s output is cached downstream, consider prefixing generated maps or content with a small version tag to simplify future migrations.
rust-plugins/worker/src/lib.rs (2)
403-417: Handle failed resolves instead of unwrap() x2resolve(...) can return Err/None; double unwrap will panic during transform.
Apply:
- context - .plugin_driver - .resolve( + match context.plugin_driver.resolve( &PluginResolveHookParam { source: worker_url.to_string(), importer: Some(param.module_id.clone().into()), kind: ResolveKind::Import, }, context, &PluginHookContext::default(), - ) - .unwrap() - .unwrap() - .resolved_path + ) { + Ok(Some(res)) => res.resolved_path, + _ => return, // or early-return Err(...) if you choose to propagate + }
131-132: Clarify/implement hashing inputComment mentions combining resolved_path + filename to avoid collisions, but bytes currently uses only module_id. Consider concatenating both for stronger uniqueness.
Apply:
- let file_name = transform_output_filename(transform_output_file_name_params); + let file_name = transform_output_filename(TransformOutputFileNameParams { + bytes: [module_id.as_bytes(), file_name_ext.as_bytes()].concat().as_slice(), + ..transform_output_file_name_params + });Note: If lifetime/allocation is a concern, precompute the concatenated Vec before constructing params.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (6)
Cargo.lockis excluded by!**/*.lockrust-plugins/auto-import/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlrust-plugins/compress/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlrust-plugins/react-components/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlrust-plugins/wasm/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlrust-plugins/worker/pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (72)
.changeset/blue-crabs-fail.md(1 hunks).changeset/pre.json(1 hunks)Cargo.toml(1 hunks)rust-plugins/auto-import/CHANGELOG.md(1 hunks)rust-plugins/auto-import/package.json(1 hunks)rust-plugins/auto-import/playground-react/package.json(1 hunks)rust-plugins/auto-import/playground-vue/package.json(1 hunks)rust-plugins/auto-import/src/lib.rs(1 hunks)rust-plugins/auto-import/src/parser/parse.rs(4 hunks)rust-plugins/auto-import/src/parser/scan_dirs_exports.rs(1 hunks)rust-plugins/auto-import/src/parser/scan_exports.rs(1 hunks)rust-plugins/compress/CHANGELOG.md(1 hunks)rust-plugins/compress/Cargo.toml(1 hunks)rust-plugins/compress/package.json(1 hunks)rust-plugins/compress/playground/package.json(1 hunks)rust-plugins/compress/src/lib.rs(3 hunks)rust-plugins/dsv/CHANGELOG.md(1 hunks)rust-plugins/dsv/package.json(1 hunks)rust-plugins/dsv/src/lib.rs(1 hunks)rust-plugins/icons/CHANGELOG.md(1 hunks)rust-plugins/icons/Cargo.toml(1 hunks)rust-plugins/icons/package.json(1 hunks)rust-plugins/icons/src/cache/mod.rs(3 hunks)rust-plugins/icons/src/compiler/preact.rs(1 hunks)rust-plugins/icons/src/compiler/react.rs(1 hunks)rust-plugins/icons/src/lib.rs(1 hunks)rust-plugins/image/CHANGELOG.md(1 hunks)rust-plugins/image/package.json(1 hunks)rust-plugins/image/src/lib.rs(1 hunks)rust-plugins/mdx/CHANGELOG.md(1 hunks)rust-plugins/mdx/package.json(1 hunks)rust-plugins/modular-import/CHANGELOG.md(1 hunks)rust-plugins/modular-import/Cargo.toml(1 hunks)rust-plugins/modular-import/package.json(1 hunks)rust-plugins/react-components/CHANGELOG.md(1 hunks)rust-plugins/react-components/Cargo.toml(1 hunks)rust-plugins/react-components/package.json(1 hunks)rust-plugins/react-components/playground/package.json(2 hunks)rust-plugins/react-components/playground/src/types/components.d.ts(1 hunks)rust-plugins/react-components/src/find_local_components.rs(2 hunks)rust-plugins/react-components/src/insert_import.rs(3 hunks)rust-plugins/react-components/src/lib.rs(5 hunks)rust-plugins/react-components/tests/mod.rs(2 hunks)rust-plugins/strip/CHANGELOG.md(1 hunks)rust-plugins/strip/package.json(1 hunks)rust-plugins/strip/src/lib.rs(6 hunks)rust-plugins/svgr/CHANGELOG.md(1 hunks)rust-plugins/svgr/Cargo.toml(1 hunks)rust-plugins/svgr/package.json(1 hunks)rust-plugins/svgr/src/react_compiler.rs(1 hunks)rust-plugins/url/CHANGELOG.md(1 hunks)rust-plugins/url/Cargo.toml(1 hunks)rust-plugins/url/package.json(1 hunks)rust-plugins/url/src/lib.rs(3 hunks)rust-plugins/virtual/CHANGELOG.md(1 hunks)rust-plugins/virtual/package.json(1 hunks)rust-plugins/wasm/CHANGELOG.md(1 hunks)rust-plugins/wasm/Cargo.toml(1 hunks)rust-plugins/wasm/package.json(1 hunks)rust-plugins/wasm/playground/package.json(1 hunks)rust-plugins/wasm/src/lib.rs(2 hunks)rust-plugins/worker/CHANGELOG.md(1 hunks)rust-plugins/worker/Cargo.toml(1 hunks)rust-plugins/worker/package.json(1 hunks)rust-plugins/worker/playground/farm.config.ts(1 hunks)rust-plugins/worker/playground/package.json(1 hunks)rust-plugins/worker/playground/src/index.tsx(1 hunks)rust-plugins/worker/src/lib.rs(10 hunks)rust-plugins/yaml/CHANGELOG.md(1 hunks)rust-plugins/yaml/package.json(1 hunks)rust-toolchain.toml(1 hunks)rustfmt.toml(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (7)
rust-plugins/auto-import/src/parser/scan_dirs_exports.rs (1)
rust-plugins/virtual/src/utils.rs (1)
normalize_path(57-80)
rust-plugins/auto-import/src/parser/parse.rs (1)
rust-plugins/auto-import/src/lib.rs (1)
new(106-125)
rust-plugins/react-components/src/find_local_components.rs (1)
rust-plugins/virtual/src/utils.rs (1)
normalize_path(57-80)
rust-plugins/auto-import/src/parser/scan_exports.rs (1)
rust-plugins/virtual/src/utils.rs (1)
normalize_path(57-80)
rust-plugins/react-components/src/lib.rs (1)
rust-plugins/virtual/src/utils.rs (1)
normalize_path(57-80)
rust-plugins/worker/src/lib.rs (1)
rust-plugins/worker/src/cache.rs (1)
new(10-14)
rust-plugins/compress/src/lib.rs (1)
rust-plugins/compress/src/utils.rs (1)
get_ext_name(90-96)
🔇 Additional comments (59)
rustfmt.toml (1)
2-2: Confirm rustfmt edition matches all crate editions.If any crate still uses 2018 or mixes editions, rustfmt can misparse. Either ensure every Cargo.toml sets edition = "2021" or drop this key to let rustfmt infer per-crate.
rust-plugins/svgr/Cargo.toml (1)
17-17: Upgrade looks correct; verify MSRV and transitive breaks.svgr-rs 0.2.0 and xmltree 0.11.0 can raise MSRV or minor API shifts. Please run cargo check across all feature combos and ensure cargo-deny/cargo-audit are clean.
Also applies to: 19-19
rust-plugins/compress/package.json (1)
3-3: Version bump looks good.No other metadata changes; aligns with prerelease strategy.
rust-plugins/wasm/package.json (2)
3-3: Version bump to 0.1.0-beta.0 looks good.
No API/field churn here; aligned with the repo-wide prerelease move.
25-33: Declaration files ship correctly. Bothscripts/index.d.tsandtypes/index.d.tsare present in the published tarball.rust-plugins/svgr/package.json (2)
3-3: Version bump to 0.1.0-beta.0 is fine.
Matches the prerelease workflow.
32-38: Ensure prerelease publish uses beta dist-tag.
If CI relies solely on Changesets, you’re good; otherwise add publishConfig.tag: "beta".rust-plugins/mdx/package.json (2)
3-3: MDX package version bump LGTM.
No surface changes here.
35-42: Type declarations are included via thescriptsdirectory entry
Thefilesarray lists"scripts", which will includescripts/index.d.tsat publish time—no changes needed.rust-plugins/dsv/src/lib.rs (1)
3-3: Import path update looks correct.Matches the toolkit refactor to plugin_utils; no behavioral change.
rust-plugins/strip/package.json (1)
3-3: Version bump to pre-release is consistent with the workspace’s v2 beta.No further changes needed here.
rust-toolchain.toml (1)
2-2: Verify nightly-2025-05-06 component availability across CI
Linux install showed repeated “sysinfo failure”—runrustup component list --toolchain nightly-2025-05-06 \ | grep -E 'clippy|rustfmt|rust-src|rustc-dev'to ensure those components are available, and likewise confirm on macOS and Windows CI.
rust-plugins/virtual/package.json (1)
3-3: Version bump aligns with the pre-release cycle.Looks good.
rust-plugins/worker/package.json (1)
3-3: Version bump to 0.1.0-beta.0 looks goodAligned with the pre-release flow.
rust-plugins/react-components/package.json (1)
3-3: Version bump acknowledgedNo issues spotted with the prerelease tag.
rust-plugins/worker/playground/package.json (1)
21-23: Confirm availability of @farmfe/cli v2-beta before bumping
No2.0.0-beta.0release exists for@farmfe/cli; coordinate on publishing a matching v2-beta or retain^1.0.4until it’s available.rust-plugins/dsv/CHANGELOG.md (1)
3-8: Changelog entry reads wellPre-release section and messaging are consistent.
rust-plugins/auto-import/src/lib.rs (1)
21-21: Import path update for PathFilter is correctMatches the new
plugin_utils::path_filterlocation; usage below remains compatible.rust-plugins/dsv/package.json (1)
3-3: Pre-release version bump looks goodNo functional changes; aligns with repo-wide beta pre-release.
rust-plugins/yaml/package.json (1)
3-3: Version bump to beta acknowledgedConsistent with workspace pre-release strategy.
rust-plugins/worker/playground/farm.config.ts (1)
22-24: Confirm worker runtime config placement.You're adding
compilerConfig.runtime.path = "/". Please confirm the worker plugin actually merges this intocompilation.runtimeunder Farm v2. If the intent is to set the public/base path for assets, that typically lives under output/public path semantics; double-check the expected key for v2 to avoid a no-op.rust-plugins/react-components/playground/package.json (1)
14-14: Nightly less plugin vs beta core.
@farmfe/js-plugin-less@^2.0.0-nightly-20250827162746may outpacecore@beta. If there are peer constraints, consider a matching beta tag or lockfile verification before merging.rust-plugins/svgr/src/react_compiler.rs (1)
15-16: Behavioral change: rely on defaults forexpand_props.Dropping the explicit
expand_props: true(per the PR summary) may alter generated component signatures. Please confirm the Default matches the previous behavior. If not, restore explicit configuration.rust-plugins/icons/src/compiler/preact.rs (1)
10-12: Correct switch to non-optional JSXRuntime for svgr-rs 0.2.x.The new non-Option field usage is correct. LGTM.
rust-plugins/image/src/lib.rs (1)
11-12: Import path relocation LGTM.Using farmfe_toolkit::plugin_utils::path_filter::PathFilter and separating read_file_raw import is correct for v2.
rust-plugins/compress/CHANGELOG.md (1)
3-8: Changelog entry reads well.Version/tag and note align with the v2 beta migration.
rust-plugins/url/Cargo.toml (1)
16-17: LGTM: migrate farmfe_utils to workspaceUsing
{ workspace = true }aligns with the workspace pin.rust-plugins/react-components/src/insert_import.rs (3)
62-68: LGTM: safer, clearer lookup of used JSX componentsLock scope is minimal and cloning before insert avoids holding the lock.
129-133: SWC API update handled correctlyPassing
SyntaxContext::empty()withIdent::newmatches the new 3-arg signature.
140-145: Consistent Ident constructionGood consistency for default and named specifiers with
SyntaxContext::empty().rust-plugins/auto-import/src/parser/parse.rs (4)
2-2: LGTM: import Arc for newparse_modulecontent ownershipMatches the Arc content handoff.
405-409: LGTM: adapt toparse_moduletaking ownedArc<String>Construction and call site look correct.
446-449: LGTM: same adaptation for imports pathConsistent with exports/combined parsers.
487-489: LGTM: same adaptation for exports pathConsistent handling across all entry points.
rust-plugins/icons/Cargo.toml (4)
14-14: LGTM: migrate farmfe_utils to workspaceConsistent with workspace strategy.
23-23: xmltree bumped to 0.11.0: validate SVG parse/write behavior
– References in rust-plugins/svgr/src/svg_builder.rs and rust-plugins/icons/src/loader/svg_builder.rs.
– Runcargo testin both crates to confirm existing SVG round-trip tests pass; add coverage for any untested SVG structures.
17-17: Confirm svgr-rs 0.2.0 API compatibility
Verify thatsvgr_rs::{transform, Config, JSXRuntime}usage inrust-plugins/svgr/src/react_compiler.rsandrust-plugins/icons/src/compiler/*still matches the crate’s v0.2.0 API (check changelog for any signature or option changes).
27-28: Dependencies safe to upgrade; nocachedusage detected and bincode v2 API calls align with the migration guide.rust-plugins/strip/src/lib.rs (1)
113-144: SWC v2 migration and source-map flow looks correct.Switch to create_swc_source_map, passing cm into codegen_module, and building maps with DefaultSourceMapGenConfig align with v2 changes.
rust-plugins/compress/src/lib.rs (1)
95-111: Data propagation through compression looks good.Forwarding meta, should_transform_output_filename, and special_placeholders preserves downstream behavior; insert path is correct.
Also applies to: 129-141
rust-plugins/react-components/playground/src/types/components.d.ts (2)
7-7: Retain ComponentG import from ComponentE
ComponentG is indeed exported fromComponentE.tsx; no change to the mapping is required.Likely an incorrect or invalid review comment.
9-9: Ignore the proposed change to import from ComponentX.tsx. ComponentX is defined and exported in ComponentD.tsx (no ComponentX.tsx exists), so the existing import path is correct.Likely an incorrect or invalid review comment.
rust-plugins/auto-import/src/parser/scan_exports.rs (1)
6-7: Correct module path update for normalize_path — LGTM.Import now points to plugin_utils; consistent with v2 layout.
rust-plugins/wasm/Cargo.toml (2)
10-13: Switch to workspace-managed farmfe crates — LGTM.Keeps versions aligned across the workspace.
14-14: rkyv bump safe: no derive usages detected
No rkyv imports or #[derive(Archive|Serialize|Deserialize)] macros found in any crate; no feature flags required.rust-plugins/modular-import/Cargo.toml (2)
10-12: Workspace-managed farmfe deps — LGTM.Consistent with the v2 migration.
15-15: regex bump to 1.10.6 — LGTM.No known breaking changes for typical patterns.
rust-plugins/auto-import/src/parser/scan_dirs_exports.rs (1)
3-3: Import path realignment to plugin_utils — LGTM.Matches the toolkit’s new module layout and other files in this PR.
rust-plugins/icons/src/compiler/react.rs (1)
10-12: LGTM on JSXRuntime migrationSwitching to a non-optional
JSXRuntime::Classicaligns with the upstream API change.rust-plugins/react-components/tests/mod.rs (2)
21-21: LGTM: switch to FxHashMapImport looks correct and matches the updated
PluginTransformHookParam.metatype.
71-79: Struct init updates look correct
meta: FxHashMap::default()andquery: vec![]match the new API; field order is fine.rust-plugins/compress/Cargo.toml (1)
10-13: LGTM: workspace dependency normalizationMoving core/toolkit/macros to
{ workspace = true }(and addingfarmfe_toolkit) is consistent with the v2 workspace upgrade.rust-plugins/url/src/lib.rs (2)
24-26: LGTM: API/import migrations
TransformOutputFileNameParamsstruct call path is correct.PathFilterpath update matches toolkit changes.
165-169: LGTM: finalize_resources signature updateAdapts to
PluginFinalizeResourcesHookParamcorrectly; ignoring_paramis fine.rust-plugins/react-components/src/find_local_components.rs (2)
8-9: Imports look consistent with the workspace-wideplugin_utilsmove
376-384: Verify PathFilter::execute parameter types
Ensure theexecutemethod in thePathFilterimplementation accepts both string slices and path references (e.g.&str,&Path/&PathBuf), since here it’s called with aStringpath and elsewhere with&str, to avoid accidental filtering mismatches.rust-plugins/react-components/src/lib.rs (3)
20-28: New SWC imports align with the v2 toolchain
create_swc_source_mapandDefaultSourceMapGenConfigadoption matches other plugins in this PR.
197-206: Codegen config changed to defaults—confirm target/minify expectationsSwitching to
swc_ecma_codegen::Config::default()may alter emitted syntax or whitespace compared tocontext.config.script.target/previous settings. Please confirm this matches farm v2’s expectations for output and minification.Suggested checks:
- Compare output of a representative TSX file before/after.
- Ensure minify settings (if any) are now applied elsewhere in the pipeline.
212-216: Sourcemap generation viacm.build_source_maplooks correctUsing
DefaultSourceMapGenConfigis aligned with the newcreate_swc_source_mapflow.
| { | ||
| "mode": "pre", | ||
| "tag": "beta", | ||
| "initialVersions": { | ||
| "@farmfe/js-plugin-babel": "0.0.3", | ||
| "@farmfe/js-plugin-copy": "0.0.4", | ||
| "@farmfe/js-plugin-react-compiler": "0.0.3", | ||
| "@farmfe/js-plugin-vuetify": "0.0.1", | ||
| "@farmfe/plugin-auto-import": "0.0.9", | ||
| "@farmfe/plugin-compress": "0.0.2", | ||
| "@farmfe/plugin-dsv": "0.0.8", | ||
| "@farmfe/plugin-icons": "0.0.9", | ||
| "@farmfe/plugin-image": "0.0.8", | ||
| "@farmfe/plugin-mdx": "0.0.7", | ||
| "@farmfe/plugin-modular-import": "0.0.1", | ||
| "@farmfe/plugin-react-components": "1.0.12", | ||
| "@farmfe/plugin-strip": "0.0.9", | ||
| "@farmfe/plugin-svgr": "0.0.3", | ||
| "@farmfe/plugin-url": "0.0.9", | ||
| "@farmfe/plugin-virtual": "0.0.12", | ||
| "@farmfe/plugin-wasm": "0.0.8", | ||
| "@farmfe/plugin-worker": "0.0.10", | ||
| "@farmfe/plugin-yaml": "0.0.10", | ||
| "babel-react-compiler": "1.0.2", | ||
| "mdx": "1.0.1", | ||
| "virtual": "1.0.0", | ||
| "vuetify": "0.0.0" | ||
| }, | ||
| "changesets": [ | ||
| "blue-crabs-fail" | ||
| ] | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Pre-release config looks fine; verify initialVersions coverage and stray package names.
Ensure every workspace package that should publish in pre-mode is present here, and that entries like "mdx", "virtual", and "vuetify" correspond to actual workspace package names (not external deps). Otherwise, publish may skip or mis-tag packages.
Run to diff workspace package names vs pre.json:
If any mismatches appear, adjust initialVersions accordingly. Also remember to exit pre mode after the beta train is published.
🏁 Script executed:
#!/bin/bash
set -euo pipefail
jq -r 'keys[]' .changeset/pre.json | awk 'NR==1, /"initialVersions"/ {next} /}/ {exit} {gsub(/[", ]/,""); if($0!="") print $0}' > /tmp/pre_pkgs.txt
# Collect all package.json names (excluding node_modules and target)
mapfile -t files < <(fd -t f package.json -E node_modules -E target)
: > /tmp/ws_pkgs.txt
for f in "${files[@]}"; do
name=$(jq -r '.name? // empty' "$f")
if [[ -n "$name" ]]; then echo "$name" >> /tmp/ws_pkgs.txt; fi
done
sort -u /tmp/pre_pkgs.txt > /tmp/pre_pkgs_sorted.txt
sort -u /tmp/ws_pkgs.txt > /tmp/ws_pkgs_sorted.txt
echo "In pre.json but not in workspace:"
comm -23 /tmp/pre_pkgs_sorted.txt /tmp/ws_pkgs_sorted.txt || true
echo
echo "In workspace but missing from pre.json:"
comm -13 /tmp/pre_pkgs_sorted.txt /tmp/ws_pkgs_sorted.txt || trueLength of output: 327
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
# Extract initialVersions keys from .changeset/pre.json
jq -r '.initialVersions | keys[]' .changeset/pre.json | sort -u > /tmp/pre_pkgs_sorted.txt
# Find all workspace package.json files (excluding node_modules and target), extract their names
find . -type f -name package.json -not -path '*/node_modules/*' -not -path '*/target/*' -print \
| xargs -n1 jq -r '.name? // empty' \
| grep -v '^$' | sort -u > /tmp/ws_pkgs_sorted.txt
echo "In pre.json but not in workspace:"
comm -23 /tmp/pre_pkgs_sorted.txt /tmp/ws_pkgs_sorted.txt || true
echo
echo "In workspace but missing from pre.json:"
comm -13 /tmp/pre_pkgs_sorted.txt /tmp/ws_pkgs_sorted.txt || trueLength of output: 5645
Sync initialVersions with actual workspace packages
Workspace contains numerous platform-specific packages (e.g., @farmfe/plugin-auto-import-darwin-arm64, @farmfe/plugin-compress-win32-x64-msvc, etc.) plus farm-plugins, playground, playground-react, and playground-vue that aren’t listed under initialVersions in .changeset/pre.json. Pre-release will skip any missing entries—confirm which packages should participate in the beta train and update initialVersions accordingly. Also remember to switch out of pre mode after the beta train is published.
| farmfe_core = { version = "2.0.0" } | ||
| farmfe_utils = { version = "2.0.0" } | ||
| farmfe_toolkit_plugin_types = { version = "2.0.0" } | ||
| farmfe_macro_plugin = { version = "2.0.0" } | ||
| farmfe_toolkit = "2.0.0" | ||
| farmfe_compiler = { version = "2.0.0" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify single-version lock across workspace
Ensure no duplicate versions of farm v2 crates are pulled.
Run:
🏁 Script executed:
#!/bin/bash
set -euo pipefail
cargo tree -d | rg -n 'farmfe_(core|utils|toolkit_plugin_types|macro_plugin|toolkit|compiler)'Length of output: 1990
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
# Use cargo metadata and Python to detect any farmfe_* crates with more than one version
python3 - <<'PYCODE'
import json, subprocess, sys
data = json.loads(subprocess.check_output(
["cargo", "metadata", "--format-version", "1"], stderr=subprocess.DEVNULL
).decode())
targets = {
"farmfe_core",
"farmfe_utils",
"farmfe_toolkit_plugin_types",
"farmfe_macro_plugin",
"farmfe_toolkit",
"farmfe_compiler",
}
crate_versions = {}
for pkg in data["packages"]:
name = pkg["name"]
if name in targets:
crate_versions.setdefault(name, set()).add(pkg["version"])
duplicates = False
for name in sorted(targets):
vers = crate_versions.get(name, set())
if len(vers) > 1:
print(f"{name} has multiple versions: {', '.join(sorted(vers))}")
duplicates = True
elif len(vers) == 1:
print(f"{name}: {next(iter(vers))}")
else:
print(f"{name}: not found in metadata")
sys.exit(1 if duplicates else 0)
PYCODELength of output: 546
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
# Fallback: inspect Cargo.lock for farmfe_* crates and detect multiple versions
python3 - <<'PYCODE'
import re, sys
from collections import defaultdict
lock_path = "Cargo.lock"
if not os.path.isfile(lock_path):
print("Cargo.lock not found", file=sys.stderr)
sys.exit(2)
versions = defaultdict(set)
with open(lock_path) as f:
for line in f:
m = re.match(r'name = "(farmfe_[^"]+)"', line)
if m:
name = m.group(1)
version_line = next(f, "")
mv = re.match(r'version = "([^"]+)"', version_line)
if mv:
versions[name].add(mv.group(1))
duplicates = False
for name in sorted(versions):
vers = versions[name]
if len(vers) > 1:
print(f"{name} has multiple versions: {', '.join(sorted(vers))}")
duplicates = True
else:
print(f"{name}: {next(iter(vers))}")
sys.exit(1 if duplicates else 0)
PYCODELength of output: 140
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
# List all farmfe_* crate entries in Cargo.lock for manual scan
grep -E '^\s*name = "farmfe_[^"]+"' -A1 Cargo.lock || trueLength of output: 2302
Deduplicate farmfe_utils crate versions
Cargo.lock lists farmfe_utils at both 0.1.6 and 2.0.0; update all dependencies to use 2.0.0 only to enforce a single-version lock.
🤖 Prompt for AI Agents
In Cargo.toml around lines 7 to 12 there are mixed versions of farmfe crates and
Cargo.lock shows farmfe_utils at 0.1.6 and 2.0.0; ensure all dependency entries
(in this Cargo.toml and any workspace member Cargo.toml files) reference
farmfe_utils = { version = "2.0.0" } (or the same 2.0.0 syntax used for other
farmfe crates) so only one version is requested, then run cargo update -p
farmfe_utils --precise 2.0.0 (or a full cargo update) to regenerate Cargo.lock
with a single farmfe_utils 2.0.0 entry.
| "@farmfe/core": "^2.0.0-beta.0", | ||
| "@farmfe/plugin-react": "^2.0.0-beta.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify CLI/Core compatibility for v2-beta.
Ensure @farmfe/cli version is compatible with @farmfe/core ^2.0.0-beta.0; upgrade CLI if required to avoid dev workflow issues.
🌐 Web query:
Is @farmfe/cli v1.x compatible with @farmfe/core v2.0.0-beta.x, or is a v2-beta CLI required?
💡 Result:
Short answer: You should use a v2 (nightly/beta) CLI with @farmfe/core v2.x — @farmfe/cli v1.x targets the v1 core API and there are separate v2/nightly CLI releases for core v2. (farm-fe.github.io, npmjs.com, socket.dev)
Citations:
- 1: https://farm-fe.github.io/docs/tutorials/create/?utm_source=openai
- 2: https://www.npmjs.com/package/%40farmfe/core/v/2.0.0-nightly-20241022124925?utm_source=openai
- 3: https://socket.dev/npm/package/%40farmfe/cli?utm_source=openai
Upgrade @farmfe/cli to ^2.0.0-beta.0
Use the v2-beta CLI release alongside @farmfe/core ^2.0.0-beta.0, as v1.x is incompatible with the v2 core API.
🤖 Prompt for AI Agents
In rust-plugins/auto-import/playground-react/package.json around lines 20-21,
the project depends on @farmfe/core and @farmfe/plugin-react v2.0.0-beta.0 but
still uses an incompatible v1.x @farmfe/cli; update the @farmfe/cli entry in
package.json to "^2.0.0-beta.0" to match the core API, then run your package
manager (npm/yarn/pnpm) to update lockfile and reinstall dependencies; finally
verify the dev/build commands work and update any CLI invocation scripts if they
rely on v1.x behavior.
| { | ||
| let bytes = buffer?; | ||
| let name = format!("{}.{}", resource_id, ext_name); | ||
| saved += origin_file_size - bytes.len(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix possible underflow when compression inflates size.
origin_file_size - bytes.len() can underflow (panic in debug, wrap in release). Use saturating_sub.
- saved += origin_file_size - bytes.len();
+ saved += origin_file_size.saturating_sub(bytes.len());📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| saved += origin_file_size - bytes.len(); | |
| saved += origin_file_size.saturating_sub(bytes.len()); |
🤖 Prompt for AI Agents
In rust-plugins/compress/src/lib.rs around line 127, the subtraction saved +=
origin_file_size - bytes.len() can underflow if compression inflates the data;
replace that subtraction with a saturating subtraction (e.g. saved +=
origin_file_size.saturating_sub(bytes.len())) so the result floors at zero
instead of panicking or wrapping; adjust any type as needed (both operands
should be usize) and no extra imports are required.
| origin, | ||
| info: None, | ||
| name_hash: sha256(&name.as_bytes(), 8), | ||
| meta, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sha256 arg type: drop redundant reference to avoid type mismatch.
sha256 usually accepts AsRef<[u8]> or &[u8]; passing &&[u8] may fail.
- name_hash: sha256(&name.as_bytes(), 8),
+ name_hash: sha256(name.as_bytes(), 8),🤖 Prompt for AI Agents
In rust-plugins/compress/src/lib.rs around line 137, the call is passing a
redundant reference (&&[u8]) to sha256 which expects AsRef<[u8]> or &[u8];
remove the extra ampersand so you pass a single reference (e.g., change &&data
to &data or data as &[u8]) to match the sha256 parameter type and resolve the
type mismatch.
| let transform_output_file_name_params = TransformOutputFileNameParams { | ||
| filename_config: assets_filename_config, | ||
| name: file_name, | ||
| name_hash: "", | ||
| bytes: ¶m.module_id.as_bytes(), | ||
| ext, | ||
| ); | ||
| special_placeholders: &Default::default(), | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix type mismatch: remove extra reference in bytes
You’re passing &&[u8]; TransformOutputFileNameParams.bytes expects &[u8].
Apply:
- let transform_output_file_name_params = TransformOutputFileNameParams {
+ let transform_output_file_name_params = TransformOutputFileNameParams {
filename_config: assets_filename_config,
name: file_name,
name_hash: "",
- bytes: ¶m.module_id.as_bytes(),
+ bytes: param.module_id.as_bytes(),
ext,
special_placeholders: &Default::default(),
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let transform_output_file_name_params = TransformOutputFileNameParams { | |
| filename_config: assets_filename_config, | |
| name: file_name, | |
| name_hash: "", | |
| bytes: ¶m.module_id.as_bytes(), | |
| ext, | |
| ); | |
| special_placeholders: &Default::default(), | |
| }; | |
| let transform_output_file_name_params = TransformOutputFileNameParams { | |
| filename_config: assets_filename_config, | |
| name: file_name, | |
| name_hash: "", | |
| bytes: param.module_id.as_bytes(), | |
| ext, | |
| special_placeholders: &Default::default(), | |
| }; |
🤖 Prompt for AI Agents
In rust-plugins/wasm/src/lib.rs around lines 84 to 91,
TransformOutputFileNameParams.bytes is being passed a &&[u8] due to an extra
reference; change the argument to pass a &[u8] by removing the leading ampersand
so use param.module_id.as_bytes() (not ¶m.module_id.as_bytes()) when
constructing TransformOutputFileNameParams.
| "@farmfe/core": "^2.0.0-bate.0", | ||
| "@farmfe/plugin-react": "^2.0.0-bate.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: “bate” → “beta” breaks installs
Both deps have the prerelease tag misspelled.
Fix with:
- "@farmfe/core": "^2.0.0-bate.0",
- "@farmfe/plugin-react": "^2.0.0-bate.0",
+ "@farmfe/core": "^2.0.0-beta.0",
+ "@farmfe/plugin-react": "^2.0.0-beta.0",📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "@farmfe/core": "^2.0.0-bate.0", | |
| "@farmfe/plugin-react": "^2.0.0-bate.0", | |
| "@farmfe/core": "^2.0.0-beta.0", | |
| "@farmfe/plugin-react": "^2.0.0-beta.0", |
🤖 Prompt for AI Agents
In rust-plugins/worker/playground/package.json around lines 22 to 23 the
prerelease tag in the dependency versions is misspelled as "bate" which breaks
installs; update both entries to use the correct "beta" prerelease tag (e.g.
^2.0.0-beta.0) so package managers can resolve the prerelease versions
correctly.
| let resource_name = format!("{}.mjs", full_file_name); | ||
| let resource = resources_map.get(&resource_name).unwrap(); | ||
| let content_bytes = resource.bytes.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong resource lookup: appends .mjs to a name that already has an extension
format!("{}.mjs", full_file_name) likely produces names like worker.js.mjs and then unwrap() can panic if the key doesn’t exist. Replace the extension to .mjs and fall back to the original if not found.
Apply:
- let resource_name = format!("{}.mjs", full_file_name);
- let resource = resources_map.get(&resource_name).unwrap();
+ let candidate_mjs = Path::new(&full_file_name)
+ .with_extension("mjs")
+ .to_string_lossy()
+ .to_string();
+ let resource = resources_map
+ .get(&candidate_mjs)
+ .or_else(|| resources_map.get(&full_file_name))
+ .expect("worker resource not found after compilation");📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let resource_name = format!("{}.mjs", full_file_name); | |
| let resource = resources_map.get(&resource_name).unwrap(); | |
| let content_bytes = resource.bytes.clone(); | |
| // replace extension with .mjs, falling back to the original file name if needed | |
| - let resource_name = format!("{}.mjs", full_file_name); | |
| let candidate_mjs = Path::new(&full_file_name) | |
| .with_extension("mjs") | |
| .to_string_lossy() | |
| .to_string(); | |
| let resource = resources_map | |
| .get(&candidate_mjs) | |
| .or_else(|| resources_map.get(&full_file_name)) | |
| .expect("worker resource not found after compilation"); | |
| let content_bytes = resource.bytes.clone(); |
🤖 Prompt for AI Agents
In rust-plugins/worker/src/lib.rs around lines 90-92, the code appends ".mjs" to
full_file_name (producing names like "worker.js.mjs") and unwraps the lookup
which can panic; replace the extension with ".mjs" first (e.g. swap the file
extension on full_file_name to ".mjs"), attempt
resources_map.get(&replaced_name) and if that returns None fall back to
resources_map.get(&full_file_name), and handle the final None without blind
unwrap (return an error or provide a clear expect message) before assigning
content_bytes.
| let (file_name, ext) = file_name_ext.split_once(".").unwrap(); | ||
| let assets_filename_config = compiler_config.output.assets_filename.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Safer filename parsing
Use rsplit_once with fallback to avoid panics and correctly split multi-dot filenames.
Apply:
- let (file_name, ext) = file_name_ext.split_once(".").unwrap();
+ let (file_name, ext) = file_name_ext
+ .rsplit_once('.')
+ .unwrap_or((&file_name_ext, ""));🤖 Prompt for AI Agents
In rust-plugins/worker/src/lib.rs around lines 120 to 121, replace the
panic-prone file_name_ext.split_once(".").unwrap() with a safer
rsplit_once-based approach that handles filenames with multiple dots and missing
extensions; if rsplit_once returns Some((name, ext)) use name and ext, otherwise
treat the whole string as the name and set ext to an empty string (or a suitable
default), avoiding unwraps and panics and preserving the existing
assets_filename_config usage.
| bytes: &module_id.as_bytes(), | ||
| ext, | ||
| ); | ||
| special_placeholders: &Default::default(), | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix type mismatch: remove extra reference in bytes
Same issue here: &&[u8] passed to bytes.
Apply:
- let transform_output_file_name_params = TransformOutputFileNameParams {
+ let transform_output_file_name_params = TransformOutputFileNameParams {
filename_config: assets_filename_config,
name: file_name,
name_hash: "",
- bytes: &module_id.as_bytes(),
+ bytes: module_id.as_bytes(),
ext,
special_placeholders: &Default::default(),
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| bytes: &module_id.as_bytes(), | |
| ext, | |
| ); | |
| special_placeholders: &Default::default(), | |
| }; | |
| let transform_output_file_name_params = TransformOutputFileNameParams { | |
| filename_config: assets_filename_config, | |
| name: file_name, | |
| name_hash: "", | |
| bytes: module_id.as_bytes(), | |
| ext, | |
| special_placeholders: &Default::default(), | |
| }; |
🤖 Prompt for AI Agents
In rust-plugins/worker/src/lib.rs around lines 126 to 129, the bytes field is
being passed a &&[u8] (an extra reference) causing a type mismatch; replace the
double-referenced value with a single &[u8] by removing the extra & so that
bytes: module_id.as_bytes(), is used instead of bytes: &module_id.as_bytes(),
ensuring the bytes parameter receives the expected &[u8].
Summary by CodeRabbit
New Features
Chores
Documentation