Skip to content

Conversation

@wre232114
Copy link
Member

@wre232114 wre232114 commented Sep 21, 2025

Summary by CodeRabbit

  • New Features
    • None
  • Bug Fixes
    • Corrected worker output file extension for proper handling.
    • Ensured entry filename is correctly set in worker output.
    • Improved worker resource resolution to avoid missing outputs.
  • Documentation
    • Updated changelog with 2.0.0-beta.1 patch details.
  • Chores
    • Prepared release via changeset updates.
    • Bumped worker plugin version to 2.0.0-beta.1.

@coderabbitai
Copy link

coderabbitai bot commented Sep 21, 2025

Walkthrough

Introduces a patch release for @farmfe/plugin-worker: updates changeset metadata, bumps version, adds changelog entry, and modifies worker output behavior by setting entry_filename in OutputConfig and changing the resource lookup key from "<full_file_name>.mjs" to "<full_file_name>".

Changes

Cohort / File(s) Summary
Changeset metadata
\.changeset/late-moles-decide.md, \.changeset/pre.json
Adds a new changeset entry "late-moles-decide" and references it in pre.json; documents a patch fixing invalid worker output extension.
Worker plugin release metadata
rust-plugins/worker/CHANGELOG.md, rust-plugins/worker/package.json
Adds 2.0.0-beta.1 changelog entry noting fix; bumps version from 2.0.0-beta.0 to 2.0.0-beta.1.
Worker output behavior
rust-plugins/worker/src/lib.rs
Sets OutputConfig.entry_filename during builder Config init; changes resource lookup key from "<full_file_name>.mjs" to "<full_file_name>".

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant Builder as Builder Config
  participant Compiler as Worker Compiler
  participant Resources as Resource Map

  Dev->>Builder: Initialize Config
  Note right of Builder: Set OutputConfig.entry_filename
  Builder->>Compiler: Build with OutputConfig
  Compiler->>Resources: Get("<full_file_name>")
  alt Resource found
    Resources-->>Compiler: Worker resource
    Compiler-->>Dev: Emit output with correct entry filename
  else Resource missing
    Resources-->>Compiler: Not found
    Compiler-->>Dev: Error: resource not found
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • CCherry07

Poem

A patch-hop, light as thistle down,
I tweak the name, set entry crown.
No more .mjs astray at night—
The worker finds its true byte-light.
Beta binks, my ears applaud,
Version bumps with cotton-clod. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title is a concise, conventional-commit–style single sentence that clearly describes the primary change: fixing an invalid worker output extension in the rust-plugins worker. The changeset and file summaries show the resource lookup change in rust-plugins/worker/src/lib.rs, an OutputConfig entry_filename addition, and corresponding changelog and version bump, so the title accurately reflects the main change.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/worker-output-extension

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
rust-plugins/worker/src/lib.rs (1)

171-182: Inline worker cache key bug causes panic.

Cache is populated with key file_name, but the inline branch reads with resolved_path, so get(...).unwrap() will panic whenever ?inline is used.

Apply this fix:

-      let content_bytes = worker_cache.get(resolved_path).unwrap();
+      let content_bytes = worker_cache
+        .get(&file_name)
+        .unwrap_or_else(|| {
+          // Fallback: build and insert if somehow missing
+          insert_worker_cache(&worker_cache, file_name.clone(), build_worker(resolved_path, module_id, compiler_config, host_config))
+        });

Also applies to: 209-213

🧹 Nitpick comments (4)
rust-plugins/worker/src/lib.rs (4)

91-93: Resource lookup by computed filename is correct; avoid hard panics.

Using full_file_name fixes the .mjs issue. However, unwrap() will panic if the resource isn’t present. Prefer propagating an error.

Apply this minimal improvement (or wire through a Result if you prefer):

-  let resource = resources_map.get(&full_file_name).unwrap();
+  let resource = resources_map
+    .get(&full_file_name)
+    .unwrap_or_else(|| panic!("worker resource not found: {}", full_file_name));

116-121: Robust extension parsing (multi-dot names, no extension).

split_once(".") breaks on multi-dot filenames and panics on dotless names. Use rsplit_once with a safe fallback.

-  let (file_name, ext) = file_name_ext.split_once(".").unwrap();
+  let (name_stem, ext) = match file_name_ext.rsplit_once('.') {
+    Some((stem, ext)) => (stem, ext),
+    None => (file_name_ext.as_str(), "js"),
+  };

Also update the TransformOutputFileNameParams below to use name_stem.


122-129: Hash input comment vs. implementation mismatch.

Comment says “resolved_path + file_name_ext” but bytes uses module_id. Either update the comment or include resolved_path to ensure per-path uniqueness.

-    bytes: &module_id.as_bytes(),
+    bytes: format!("{}|{}", resolved_path, module_id).as_bytes(),

133-137: Handle more TS extensions.

Only .ts is normalized. Add .tsx (and optionally .mts/.cts) to avoid invalid runtime extensions.

-  let file_name = if file_name.ends_with(".ts") {
-    file_name.replace(".ts", ".js")
-  } else {
-    file_name
-  };
+  let file_name = if file_name.ends_with(".tsx") {
+    file_name.trim_end_matches(".tsx").to_string() + ".js"
+  } else if file_name.ends_with(".ts") {
+    file_name.trim_end_matches(".ts").to_string() + ".js"
+  } else {
+    file_name
+  };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5bea051 and 42e679e.

📒 Files selected for processing (5)
  • .changeset/late-moles-decide.md (1 hunks)
  • .changeset/pre.json (1 hunks)
  • rust-plugins/worker/CHANGELOG.md (1 hunks)
  • rust-plugins/worker/package.json (1 hunks)
  • rust-plugins/worker/src/lib.rs (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: call-rust-build / Build and Upload Artifacts - linux-arm64-gnu
  • GitHub Check: call-rust-build / Build and Upload Artifacts - linux-arm64-musl
  • GitHub Check: call-rust-build / Build and Upload Artifacts - win32-ia32-msvc
  • GitHub Check: call-rust-build / Build and Upload Artifacts - darwin-x64
  • GitHub Check: call-rust-build / Build and Upload Artifacts - linux-x64-musl
  • GitHub Check: call-rust-build / Build and Upload Artifacts - darwin-arm64
  • GitHub Check: call-rust-build / Build and Upload Artifacts - win32-x64-msvc
  • GitHub Check: call-rust-build / Build and Upload Artifacts - linux-x64-gnu
🔇 Additional comments (5)
rust-plugins/worker/package.json (1)

3-3: Version bump aligns with patch fix; ensure tags/publication.

Looks good. Please confirm a publish will be cut under the beta tag and that CHANGELOG/changeset are in sync.

rust-plugins/worker/CHANGELOG.md (1)

3-8: Changelog entry is clear.

Concise and matches the code changes.

.changeset/late-moles-decide.md (1)

1-5: Changeset LGTM.

Scope and summary match the patch intent.

.changeset/pre.json (1)

33-34: Pre-mode entry added correctly.

The new changeset id is included; ordering is fine.

rust-plugins/worker/src/lib.rs (1)

74-82: Setting OutputConfig.entry_filename fixes the extension/key mismatch.

Good call—this ensures the emitted resource key matches the computed filename.

Please run a local build with a worker entry whose source ends with .ts and confirm the emitted key equals the computed file_name (no extra .mjs).

@CCherry07 CCherry07 merged commit 5ad4b8e into main Sep 21, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants