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

perf: optimize local startup speed and add header Class configuration to drawer #4840

Merged
merged 1 commit into from
Nov 9, 2024

Conversation

anncwb
Copy link
Collaborator

@anncwb anncwb commented Nov 9, 2024

Description

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Checklist

ℹ️ Check all checkboxes - this will indicate that you have done everything in accordance with the rules in CONTRIBUTING.

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs:dev command.
  • Run the tests with pnpm test.
  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced customization options for the drawer component with new footerClass and headerClass properties.
  • Bug Fixes

    • Improved CSS preprocessing capabilities by updating SCSS options in the configuration.
  • Chores

    • Updated various package versions for improved performance and compatibility.

@anncwb anncwb requested review from vince292007 and a team as code owners November 9, 2024 03:04
Copy link

changeset-bot bot commented Nov 9, 2024

⚠️ No Changeset found

Latest commit: 550b0f9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link
Contributor

coderabbitai bot commented Nov 9, 2024

Walkthrough

The pull request introduces several modifications across multiple files, primarily enhancing the configuration for VitePress and Vite applications. Key changes include the addition of SCSS preprocessing options and new properties in the drawer component for better styling. Additionally, package versions in the pnpm-workspace.yaml file have been updated. Overall, the changes focus on improving CSS processing capabilities and enhancing component customization without altering existing functionalities.

Changes

File Path Change Summary
docs/.vitepress/config/shared.mts Added preprocessorOptions for SCSS with api: 'modern' under vite.css.
internal/vite-config/src/config/application.ts Added import for NodePackageImporter, updated createCssOptions to include importers, and changed SCSS api to 'modern'. Modified warmup.clientFiles array.
internal/vite-config/src/plugins/vxe-table.ts Removed commented-out configuration block from viteVxeTableImportsPlugin function.
packages/@core/ui-kit/popup-ui/src/drawer/drawer.ts Updated DrawerProps interface: changed class type to any, added footerClass and headerClass.
packages/@core/ui-kit/popup-ui/src/drawer/drawer.vue Added footerClass and headerClass to props, updated withDefaults and class bindings in template.
pnpm-workspace.yaml Updated versions for several packages: @vee-validate/zod, cz-git, eslint-plugin-jsonc, etc.

Possibly related PRs

Suggested labels

enhancement, perf

Suggested reviewers

  • vince292007

🐰 In the meadow, changes bloom,
New styles for drawers make room.
SCSS flows with modern grace,
VitePress shines in its new place.
With packages fresh, we hop along,
Enhancements here, let’s sing a song! 🎶


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 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
Contributor

@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: 3

🧹 Outside diff range and nitpick comments (6)
internal/vite-config/src/config/application.ts (2)

89-89: Performance enhancement: Additional paths for server warmup

The addition of adapter to the warmup paths will help optimize local startup speed by pre-warming these files. This aligns well with the PR's performance optimization goals.

Consider monitoring the startup time impact. If it becomes too slow, you might want to be more selective about which files to pre-warm.


117-118: LGTM: Enhanced SCSS processing configuration

The changes improve SCSS processing by:

  1. Using the modern Sass API
  2. Adding NodePackageImporter for better package resolution

This configuration enables more efficient SCSS processing and better package imports handling.

The modern API provides better performance, but ensure all your SCSS features are compatible with it. The NodePackageImporter might slightly impact build time but provides better maintainability for package imports.

docs/.vitepress/config/shared.mts (2)

62-64: Consider optimizing PostCSS configuration

While adding Sass optimization, consider also optimizing the PostCSS pipeline. The current setup with Tailwind and isolation could benefit from caching:

     css: {
       postcss: {
+        postcssOptions: {
+          config: false,
+        },
         plugins: [
           tailwind(),
           postcssIsolateStyles({ includeFiles: [/vp-doc\.css/] }),
         ],
       },

Also applies to: 70-73


Line range hint 62-105: Consider chunking optimization for better startup performance

Since this PR focuses on startup performance, the build configuration could be further optimized:

     build: {
       chunkSizeWarningLimit: Infinity,
       minify: 'terser',
+      rollupOptions: {
+        output: {
+          manualChunks: {
+            'vue-libs': ['vue', '@vue/repl'],
+            'markdown': ['markdown-it'],
+          }
+        }
+      }
     },

This would help with:

  • Better code splitting
  • Improved caching
  • Faster initial page loads
packages/@core/ui-kit/popup-ui/src/drawer/drawer.vue (2)

135-141: Consider extracting complex class binding to a computed property.

While the implementation is correct, the template's readability could be improved by moving the complex class binding logic to a computed property.

Here's a suggested refactor:

+ const headerClasses = computed(() => 
+   cn(
+     '!flex flex-row items-center justify-between border-b px-6 py-5',
+     headerClass,
+     {
+       'px-4 py-3': closable,
+     },
+   )
+ )

  <SheetHeader
-   :class="cn('!flex flex-row items-center justify-between border-b px-6 py-5',
-     headerClass,
-     {
-       'px-4 py-3': closable,
-     },
-   )"
+   :class="headerClasses"
  >

195-200: Apply consistent pattern for footer class binding.

For consistency with the header section, consider extracting the footer's class binding logic to a computed property as well.

Here's a suggested refactor:

+ const footerClasses = computed(() => 
+   cn(
+     'w-full flex-row items-center justify-end border-t p-2 px-3',
+     footerClass
+   )
+ )

  <SheetFooter
    v-if="showFooter"
-   :class="cn(
-     'w-full flex-row items-center justify-end border-t p-2 px-3',
-     footerClass,
-   )"
+   :class="footerClasses"
  >
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between da7d61b and 550b0f9.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • docs/.vitepress/config/shared.mts (2 hunks)
  • internal/vite-config/src/config/application.ts (3 hunks)
  • internal/vite-config/src/plugins/vxe-table.ts (0 hunks)
  • packages/@core/ui-kit/popup-ui/src/drawer/drawer.ts (2 hunks)
  • packages/@core/ui-kit/popup-ui/src/drawer/drawer.vue (3 hunks)
  • pnpm-workspace.yaml (7 hunks)
💤 Files with no reviewable changes (1)
  • internal/vite-config/src/plugins/vxe-table.ts
🔇 Additional comments (5)
internal/vite-config/src/config/application.ts (1)

9-9: LGTM: Import statement aligns with SCSS configuration changes

The import of NodePackageImporter is necessary for the enhanced SCSS processing configuration.

pnpm-workspace.yaml (3)

54-54: LGTM: Synchronized package versions.

Good practice maintaining version parity between related packages:

  • vee-validate and @vee-validate/zod both updated to ^4.14.7

Also applies to: 161-161


79-80: Verify package updates impact on startup performance.

The updates appear to be minor version bumps or patches. However, since the PR's objective is to optimize local startup speed, please ensure these updates contribute to or at least don't negatively impact the performance goals.

#!/bin/bash
# Description: Check for performance-related changes in package usage

# Test: Look for performance-sensitive imports or configurations
echo "Checking for dynamic imports and lazy loading patterns..."
rg "import\((.*?)\)" --type ts --type vue

# Test: Search for any performance-related configurations
echo "Searching for build and performance configurations..."
fd "vite\.config\.(ts|js)$|\.env.*"

Also applies to: 93-93, 117-117, 120-120, 124-124, 137-137


177-178: Verify the significant patch update for vxe-table.

The vxe-table package has been updated from ^4.8.2 to ^4.8.8, which includes multiple patch versions. Since this is a UI component library that could affect startup performance, please ensure these changes have been tested thoroughly.

✅ Verification successful

Based on the search results, I can now generate the final response since we have enough context about the vxe-table usage in the codebase:

The vxe-table update appears safe to proceed with.

The package is used in a modular way within the @vben/plugins package, specifically in the packages/effects/plugins/src/vxe-table/ directory. The implementation is well-encapsulated with proper type definitions and initialization handling. Since this is a patch version update (4.8.2 to 4.8.8) and the package is used in a controlled manner through a plugin system, the update is unlikely to cause breaking changes or performance regressions.

Key observations:

  • Usage is isolated to a dedicated plugin module
  • Proper type definitions are maintained
  • The update follows semantic versioning (patch version)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any breaking changes or performance improvements in the changelog

# Test: Search for vxe-table usage and potential breaking changes
echo "Searching for vxe-table usage in the codebase..."
rg "vxe-table" -A 5

# Test: Check if there are any configuration files specific to vxe-table
echo "Checking for vxe-table configuration files..."
fd "vxe.*\.(ts|js|json)$"

Length of output: 351


Script:

#!/bin/bash
# Let's try a different approach to find vxe-table usage

# Search for imports of vxe-table
echo "Searching for vxe-table imports..."
rg "from ['\"](vxe-table|vxe-pc-ui)" -A 2

# Search for VXETable component usage
echo "Searching for VXETable component usage..."
rg "VXETable" -A 2

# Search for package.json files to understand the dependency structure
echo "Checking package.json files..."
fd "package.json" --exec cat {}

Length of output: 48786

packages/@core/ui-kit/popup-ui/src/drawer/drawer.vue (1)

59-60: LGTM: Props addition aligns with requirements.

The addition of footerClass and headerClass props enhances the component's customization capabilities, aligning with the PR's objective to support header Class configuration.

@anncwb anncwb merged commit 9cf0573 into main Nov 9, 2024
14 checks passed
@anncwb anncwb deleted the perf/drawer-header branch November 9, 2024 03:12
@anncwb anncwb added the perf label Nov 9, 2024
This was referenced Nov 27, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Dec 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant