Skip to content
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

fix(vue2): fix vue2 dev startup error #2822

Merged
merged 1 commit into from
Jan 20, 2025
Merged

fix(vue2): fix vue2 dev startup error #2822

merged 1 commit into from
Jan 20, 2025

Conversation

zzcr
Copy link
Member

@zzcr zzcr commented Jan 18, 2025

PR

修复vue2启动报错

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Configuration Updates

    • Added new alias @mobile-root in Vite configuration
    • Updated import path handling for specific libraries
    • Refined Vue version-specific alias mapping
  • Dependency Management

    • Updated import for log function from relative path to @opentiny/utils package

Copy link

coderabbitai bot commented Jan 18, 2025

Walkthrough

The pull request introduces modifications across three files: examples/vue2/vite.config.ts, internals/cli/src/config/vite.ts, and packages/renderless/src/currency/index.ts. The changes primarily focus on refining Vite configuration, specifically adjusting alias mappings and import paths. In the renderless package, there's a minor update to the import source of the log function, switching from a relative path to an external package.

Changes

File Change Summary
examples/vue2/vite.config.ts Added new alias @mobile-root mapping to packages/mobile and updated customName function to append /index.ts to non-default import paths
internals/cli/src/config/vite.ts Modified getAlias function to conditionally assign @opentiny/vue-icon mapping based on Vue version
packages/renderless/src/currency/index.ts Changed log function import from relative path to @opentiny/utils package

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • gimmyhehe
  • kagol

Poem

🐰 In the realm of config and code,
Aliases dance, pathways reload
Vite's magic weaves its subtle spell
Imports now flow, and functions gel
A rabbit's smile at changes bright! 🚀


📜 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 3ddfaf2 and 5083d34.

📒 Files selected for processing (3)
  • examples/vue2/vite.config.ts (2 hunks)
  • internals/cli/src/config/vite.ts (1 hunks)
  • packages/renderless/src/currency/index.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/renderless/src/currency/index.ts
🔇 Additional comments (3)
internals/cli/src/config/vite.ts (1)

42-45: LGTM! The version-specific alias mapping fixes the Vue 3 startup error.

The condition ensures that the Vue 3 specific icon alias is only applied when Vue 3 is in use, preventing potential conflicts in Vue 2 environment.

Let's verify that this alias is not affecting other Vue versions:

✅ Verification successful

The Vue version-specific icon alias mapping is correctly isolated

The condition ensures that the Vue 3 specific icon alias is only applied in Vue 3 environment, while Vue 2 projects maintain their separate configurations. The codebase search confirms that this change doesn't affect Vue 2 components or examples.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for Vue version-specific icon imports across the codebase

# Search for direct imports of @opentiny/vue-icon
echo "Checking direct icon imports:"
rg "from ['\"@]opentiny/vue-icon['\"]" -l

# Search for icon-related alias usage in vite configs
echo "Checking icon alias usage in vite configs:"
rg "vue-icon.*alias" "**/*.{js,ts}"

Length of output: 302


Script:

#!/bin/bash
# Search for icon-related configurations and Vue version checks
echo "Checking icon configurations:"
fd -e js -e ts | xargs rg -l "vue-icon|icon.*alias"

echo -e "\nChecking Vue version related configurations:"
fd -e js -e ts | xargs rg -l "vueVersion.*[23]"

echo -e "\nChecking icon imports with broader patterns:"
rg "@opentiny.*icon" -l

Length of output: 46361

examples/vue2/vite.config.ts (2)

55-57: LGTM! Explicit index.ts path fixes Vite 4 module resolution.

The change ensures correct module resolution by explicitly specifying the index.ts file, addressing the Vite 4 exports syntax limitation mentioned in the comments.


87-87: Verify the necessity of @mobile-root alias.

This change appears unrelated to fixing the Vue 3 startup error. Please clarify if this alias is required for other functionality.

Let's check if this alias is being used:

Finishing Touches

  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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. (Beta)
  • @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.

Copy link

Walkthrough

此PR修复了Vue2的启动错误,主要通过调整路径和别名配置来解决与Vue3的兼容性问题。具体修改包括更新路径映射和条件逻辑以确保在不同Vue版本下的正确配置。

Changes

文件 摘要
examples/vue2/vite.config.ts 更新了路径映射和别名配置,确保在不同Vue版本下的正确配置。
internals/cli/src/config/vite.ts 修改了条件逻辑以确保在Vue3下的正确路径映射。
packages/renderless/src/currency/index.ts 更改了日志导入路径以使用公共工具库。

@github-actions github-actions bot added the bug Something isn't working label Jan 18, 2025
@@ -39,7 +39,7 @@ const getAlias = (vueVersion: string | number, theme = '', design) => {
...getComponentAlias()
}

if (!design) {
if (!design && vueVersion === 3) {

Choose a reason for hiding this comment

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

The condition if (!design && vueVersion === 3) ensures that the alias is only set for Vue 3. Ensure that this logic aligns with the intended behavior across different Vue versions.

@zzcr zzcr changed the title fix(vue2): fix vue3 dev startup erro fix(vue2): fix vue2 dev startup erro Jan 18, 2025
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Walkthrough

This PR fixes the startup error of Vue2, mainly by adjusting the path and alias configuration to solve the compatibility issue with Vue3. Specific modifications include updating path mapping and conditional logic to ensure correct configuration under different Vue versions.

Changes

Documentation Abstract
examples/vue2/vite.config.ts Updated path mapping and alias configuration to ensure correct configuration under different Vue versions.
internals/cli/src/config/vite.ts Modified conditional logic to ensure correct path mapping under Vue3.
packages/renderless/src/currency/index.ts Changed log import path to use public tool libraries.

Copy link

[e2e-test-warn]
The component to be tested is missing.

The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug".

Please make sure you've read our contributing guide

@zzcr zzcr changed the title fix(vue2): fix vue2 dev startup erro fix(vue2): fix vue2 dev startup error Jan 18, 2025
@zzcr zzcr merged commit bbe91c7 into dev Jan 20, 2025
18 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants