Skip to content

fix(create-farm): fix templates client types #2128

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fu050409
Copy link
Member

@fu050409 fu050409 commented Mar 22, 2025

Fixes #1996

Summary by CodeRabbit

  • New Features

    • Enhanced integration across multiple UI templates by updating type support, resulting in improved autocompletion and type checking.
    • Applied a patch to resolve inconsistencies in client template type definitions.
  • Chores

    • Removed outdated type configuration files to streamline development.
    • Updated various type references to align with the latest client libraries.

Copy link

changeset-bot bot commented Mar 22, 2025

🦋 Changeset detected

Latest commit: 51b92ab

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-farm Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

coderabbitai bot commented Mar 22, 2025

Walkthrough

This pull request introduces several changes to update TypeScript environment files across multiple templates. A new changeset file documents the “create-farm” patch that addresses farm client type definitions. In various template directories, new declaration files now include references to Svelte and the @farmfe/core/client package, while older Vite-specific environment files or references are removed or updated. Changes are applied across different framework templates (Electron, Svelte, Tauri with Preact, React, and Vue) as well as in the Tauri2 folder.

Changes

File(s) Change Summary
.changeset/kind-walls-perform.md Added a new changeset file documenting the "create-farm" patch for farm client type definitions.
crates/.../electron/svelte/src/env.d.ts
crates/.../svelte/src/env.d.ts
crates/.../tauri/preact/src/env.d.ts
crates/.../tauri/react/src/env.d.ts
crates/.../tauri/vue/src/env.d.ts
New or updated TypeScript declaration files with added references to Svelte and/or @farmfe/core/client (Vue file also declares module "*.vue").
crates/.../electron/svelte/src/vite-env.d.ts
crates/.../svelte/src/vite-env.d.ts
crates/.../tauri/preact/src/vite-env.d.ts
crates/.../tauri/react/src/vite-env.d.ts
crates/.../tauri/vue/src/vite-env.d.ts
Removed files or lines providing Vite type definitions (e.g., /// <reference types="vite/client" />), eliminating dependency on Vite for type support.
crates/.../tauri2/react/src/env.d.ts
crates/.../tauri2/vue/src/env.d.ts
Updated existing env files by replacing references from "vite/client" to "@farmfe/core/client", with the Vue file’s module declaration simplified.

Assessment against linked issues

Objective Addressed Explanation
Provide import.meta.glob types without requiring Vite as a devDependency (#1996) No alternative type definitions were introduced for import.meta.glob after removing Vite references.

Poem

I’m a rabbit hopping through the code,
Burrowing changes, lightening the load.
New type paths and references shine,
While old Vite trails fade in time.
With twitching nose and joyful heart, I celebrate every smart part!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7a69a88 and fe548eb.

📒 Files selected for processing (13)
  • .changeset/kind-walls-perform.md (1 hunks)
  • crates/create-farm-rs/templates/electron/svelte/src/env.d.ts (1 hunks)
  • crates/create-farm-rs/templates/electron/svelte/src/vite-env.d.ts (0 hunks)
  • crates/create-farm-rs/templates/svelte/src/env.d.ts (1 hunks)
  • crates/create-farm-rs/templates/svelte/src/vite-env.d.ts (0 hunks)
  • crates/create-farm-rs/templates/tauri/preact/src/env.d.ts (1 hunks)
  • crates/create-farm-rs/templates/tauri/preact/src/vite-env.d.ts (0 hunks)
  • crates/create-farm-rs/templates/tauri/react/src/env.d.ts (1 hunks)
  • crates/create-farm-rs/templates/tauri/react/src/vite-env.d.ts (0 hunks)
  • crates/create-farm-rs/templates/tauri/vue/src/env.d.ts (1 hunks)
  • crates/create-farm-rs/templates/tauri/vue/src/vite-env.d.ts (0 hunks)
  • crates/create-farm-rs/templates/tauri2/react/src/env.d.ts (1 hunks)
  • crates/create-farm-rs/templates/tauri2/vue/src/env.d.ts (1 hunks)
💤 Files with no reviewable changes (5)
  • crates/create-farm-rs/templates/svelte/src/vite-env.d.ts
  • crates/create-farm-rs/templates/electron/svelte/src/vite-env.d.ts
  • crates/create-farm-rs/templates/tauri/react/src/vite-env.d.ts
  • crates/create-farm-rs/templates/tauri/vue/src/vite-env.d.ts
  • crates/create-farm-rs/templates/tauri/preact/src/vite-env.d.ts
⏰ Context from checks skipped due to timeout of 90000ms (16)
  • GitHub Check: call-rust-build / Build and Upload Artifacts - android-arm-eabi
  • GitHub Check: call-rust-build / Build and Upload Artifacts - android-arm64
  • GitHub Check: call-rust-build / Build and Upload Artifacts - linux-arm-gnueabihf
  • GitHub Check: call-rust-build / Build and Upload Artifacts - linux-arm64-musl
  • GitHub Check: call-rust-build / Build and Upload Artifacts - win32-arm64-msvc
  • GitHub Check: call-rust-build / Build and Upload Artifacts - darwin-arm64
  • GitHub Check: call-rust-build / Build and Upload Artifacts - linux-arm64-gnu
  • GitHub Check: call-rust-build / Build and Upload Artifacts - win32-x64-msvc
  • GitHub Check: call-rust-build / Build and Upload Artifacts - win32-ia32-msvc
  • GitHub Check: call-rust-build / Build and Upload Artifacts - linux-x64-gnu
  • 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 - x86_64-unknown-freebsd
  • GitHub Check: Test - windows-latest
  • GitHub Check: Test - ubuntu-latest
  • GitHub Check: Test - macos-latest
🔇 Additional comments (10)
crates/create-farm-rs/templates/tauri2/react/src/env.d.ts (1)

1-1: Updated type reference to use Farm's client types

This change correctly updates the type reference from Vite to Farm's client types, which aligns with the PR objective of fixing template client types. This ensures that React projects created with the Tauri2 template will have proper TypeScript typings for Farm-specific APIs and behaviors.

crates/create-farm-rs/templates/tauri2/vue/src/env.d.ts (2)

1-1: Updated type reference to use Farm's client types

This change correctly updates the type reference from Vite to Farm's client types, which aligns with the PR objective of fixing template client types. This ensures that Vue projects created with the Tauri2 template will have proper TypeScript typings for Farm-specific APIs.


3-3: Simplified Vue module declaration

The Vue module declaration has been simplified to a more generic form. This approach is more flexible and follows common practices for Vue 3 TypeScript projects.

.changeset/kind-walls-perform.md (1)

1-5: Well-structured changeset with clear description

The changeset correctly documents this as a patch update to the "create-farm" package, with a clear description of the changes made. This will ensure proper versioning and changelog generation.

crates/create-farm-rs/templates/tauri/react/src/env.d.ts (1)

1-1: Added Farm client type reference

This new declaration file correctly references the Farm client types, ensuring that React projects created with the Tauri template will have proper TypeScript typings for Farm-specific APIs and behaviors.

crates/create-farm-rs/templates/tauri/preact/src/env.d.ts (1)

1-1: Approve: Correct Reference Inclusion

The addition of the triple-slash reference to @farmfe/core/client ensures that TypeScript picks up the necessary type definitions from the FarmFE core client. This update aligns perfectly with the PR objective to fix client types in the templates.

crates/create-farm-rs/templates/tauri/vue/src/env.d.ts (2)

1-1: Approve: Added Client Type Reference

The inclusion of the directive /// <reference types="@farmfe/core/client" /> guarantees that the Vue template also benefits from improved type checking with the new FarmFE core client types.


3-3: Approve: Module Declaration for Vue Files

Declaring the module for "*.vue" is an excellent addition. It enables TypeScript to properly recognize Vue single-file components, which is crucial for seamless integration in the Vue environment.

crates/create-farm-rs/templates/svelte/src/env.d.ts (1)

1-2: Approve: Comprehensive Type References

The file correctly references both Svelte types and the new @farmfe/core/client types. This dual reference ensures that both Svelte-related and farm client-specific type checks and autocompletions function as expected.

crates/create-farm-rs/templates/electron/svelte/src/env.d.ts (1)

1-2: Approve: Consistent Environment Setup for Electron/Svelte

By adding references to both the Svelte types and @farmfe/core/client, this file now aligns with the improvements made across other templates. This consistency will help maintain uniform type safety across different platform configurations.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@fu050409 fu050409 requested review from wre232114 and ErKeLost March 22, 2025 10:43
Copy link

codspeed-hq bot commented Mar 22, 2025

CodSpeed Performance Report

Merging #2128 will create unknown performance changes

Comparing fix/template-types (51b92ab) with main (a785d6f)

Summary

⚠️ No benchmarks were detected in both the base of the PR and the PR.\

@wre232114 wre232114 enabled auto-merge (squash) March 23, 2025 12:58
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.

[Bug Report]: Farm acctually missing types of import.meta.glob
3 participants