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

build: update vite version and fix inline-chunk plugin #2722

Merged
merged 1 commit into from
Jan 2, 2025

Conversation

gimmyhehe
Copy link
Member

@gimmyhehe gimmyhehe commented Jan 2, 2025

PR

升级构建脚本的vite版本以及修复内联功能依赖插件不生效问题

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

  • Chores

    • Updated package.json for internal CLI project
    • Reorganized project dependencies
    • Added @opentiny/huicharts dependency
    • Retained vite-svg-loader
  • Refactor

    • Enhanced regex patterns for import and require statement matching to support more flexible file naming conventions

Copy link

coderabbitai bot commented Jan 2, 2025

Walkthrough

This pull request involves modifications to the internals/cli/package.json and internals/cli/src/commands/build/rollup/inline-chunks.ts files. The package.json changes include reorganizing dependencies, adding @opentiny/huicharts, and managing the private field. In the inline-chunks.ts file, the regular expressions for matching import and require statements were updated to support a broader range of characters in file names, enhancing the plugin's flexibility.

Changes

File Change Summary
internals/cli/package.json - Removed and re-added private: true field
- Retained main: "./dist/cjs/index.js"
- Added @opentiny/huicharts to dependencies
- Retained vite-svg-loader
- Re-added devDependencies section
internals/cli/src/commands/.../inline-chunks.ts - Updated regex patterns for import/require statements
- Expanded character support to include alphanumeric, underscore, and hyphen

Possibly related PRs

Suggested Reviewers

  • kagol

Poem

🐰 In the realm of code, a rabbit hops light,
Tweaking dependencies with algorithmic might
Regex patterns dance, more flexible now
Package.json shifts, with a playful bow
Coding magic unfurls, line by line so bright! 🔧


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

概要

此PR更新了构建脚本中Vite的版本,并修复了内联功能依赖插件不生效的问题。主要修改包括正则表达式的调整以匹配新的文件命名格式。

变更

文件 概要
internals/cli/package.json 更新了Vite版本,调整了相关依赖。
internals/cli/src/commands/build/rollup/inline-chunks.ts 修改了正则表达式以支持新的文件命名格式,确保内联功能正常工作。

@@ -27,7 +27,7 @@ export default function ({ deleteInlinedFiles = true }): Plugin {
if (!jsChunk.code) continue

if (format === 'es') {
const reg = /^import(\s*.+\s*from)?\s+"[./]+(.+-[a-f0-9]{8}.+)".*$/gim
const reg = /^import(\s*.+\s*from)?\s+"[./]+(.+-[A-Za-z0-9_-]{8}\.[mc]?js)".*$/gim

Choose a reason for hiding this comment

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

The regular expression has been updated to match a broader range of file name patterns, including different extensions and character sets. Ensure that this change does not inadvertently match unintended file names.

@@ -40,7 +40,7 @@ export default function ({ deleteInlinedFiles = true }): Plugin {
}

if (format === 'cjs') {
const reg = /require\("[./]+(.+-[a-f0-9]{8}.+)".*$/gim
const reg = /require\("[./]+(.+-[A-Za-z0-9_-]{8}\.[mc]?js)".*$/gim

Choose a reason for hiding this comment

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

The regular expression for 'require' statements has been updated similarly to the 'import' statements. Verify that this change aligns with the intended file patterns and does not introduce any security vulnerabilities.

@Issues-translate-bot
Copy link

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


Summary

This PR updates the version of Vite in the build script and fixes the problem that inline function dependent plug-ins do not take effect. Major modifications include adjustments to regular expressions to match the new file naming format.

Change

Documentation Summary
internals/cli/package.json Updated Vite version and adjusted related dependencies.
internals/cli/src/commands/build/rollup/inline-chunks.ts Modified regular expressions to support the new file naming format to ensure that inline functionality works properly.

Copy link

github-actions bot commented Jan 2, 2025

[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

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

🧹 Nitpick comments (2)
internals/cli/src/commands/build/rollup/inline-chunks.ts (2)

30-30: Consider supporting single quotes or dynamic imports
Current regex only matches double-quoted static imports. You might wish to handle single quotes ('./path') or dynamic imports (import('./path')) for broader compatibility.


43-43: Consider handling single quotes in CommonJS requires
Similar to the ES import pattern, require('./path') can also be written with single quotes. Updating the regex will ensure consistent handling of different quoting styles.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 23e3222 and aed1703.

📒 Files selected for processing (2)
  • internals/cli/package.json (2 hunks)
  • internals/cli/src/commands/build/rollup/inline-chunks.ts (2 hunks)
🔇 Additional comments (5)
internals/cli/package.json (5)

5-5: No immediate concerns with enabling "private"
Keeping the CLI project private is consistent with internal usage and distribution.


7-7: "main" field looks good
Pointing to "./dist/cjs/index.js" aligns with standard Node packaging conventions.


36-36: Dependency addition
Adding "@opentiny/huicharts": "~1.0.0" is fine; confirm the tilde range aligns with your version-management expectations.


44-44: No objections to "vite-svg-loader"
Upgrading or retaining "vite-svg-loader": "^3.6.0" is standard. No issues observed.


46-67: Verify necessity of devDependencies
A large devDependencies set can increase maintenance overhead. Please confirm that each entry is required and up to date.

✅ Verification successful

All devDependencies are actively used and necessary

Based on the codebase analysis, all devDependencies in internals/cli/package.json are actively used:

  • Build tools:

    • @babel/*: Used for code transpilation in build scripts
    • rollup, tsup, vite: Used as build tools in various build commands
    • typescript: Used for TypeScript compilation throughout the codebase
  • CLI and utilities:

    • commander: Used for CLI command handling in src/index.ts
    • chalk: Used for console output styling in multiple files
    • fs-extra: Used extensively for file operations
    • find-up: Used in build scripts for path resolution
    • handlebars: Used for template rendering in build scripts
    • prettier: Used for code formatting
    • semver: Used for version handling in multiple places
  • Vue/Template related:

    • @opentiny-internal/unplugin-virtual-template: Used in build configurations
    • @opentiny/vue-vite-template2jsx: Used for JSX template handling
    • @vue/tsconfig: Extended in TypeScript configurations
  • Bundler plugins:

    • @rollup/plugin-babel: Used in build configurations
    • @rollup/plugin-commonjs: Used in runtime builds

The dependencies have appropriate versions and are actively used in the codebase. No unnecessary dependencies were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Script to locate references to devDependencies in the codebase
# and confirm if they are actually in use.

# 1. List all devDependencies
devDependencies=(
"@babel/core"
"@babel/preset-env"
"@opentiny-internal/unplugin-virtual-template"
"@opentiny/vue-vite-template2jsx"
"@rollup/plugin-babel"
"@rollup/plugin-commonjs"
"@types/fs-extra"
"@vue/tsconfig"
"chalk"
"commander"
"esbuild-register"
"find-up"
"fs-extra"
"handlebars"
"prettier"
"rollup"
"semver"
"tailwindcss"
"tsup"
"typescript"
"vite"
)

# 2. Search for each devDependency usage across the repository
for dep in "${devDependencies[@]}"; do
  echo "Searching usage of $dep..."
  rg "$dep" -A 5
done

Length of output: 69601

@zzcr zzcr merged commit 6dd9fe8 into dev Jan 2, 2025
13 of 22 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