Skip to content

Conversation

@everettbu
Copy link

Recreation of PR: N/A

Benchmark PR storybook-5730da9-0.

@greptile-apps
Copy link

greptile-apps bot commented Nov 20, 2025

Greptile Overview

Greptile Summary

This PR implements a performance optimization for Storybook's Vite builder by refactoring dependency optimization configuration. The main change extracts a large constant array (INCLUDE_CANDIDATES) containing 143 dependency names from the optimizeDeps logic into a dedicated constants file. This constant defines packages that need pre-optimization by Vite to convert from CommonJS to ESM format, preventing startup delays. The refactoring improves code organization by separating configuration data from business logic, making the optimizeDeps module more focused and maintainable. Additionally, the Vitest plugin is updated to leverage these same optimization candidates, ensuring consistent dependency handling across both build and test environments.

Important Files Changed

Filename Score Overview
code/builders/builder-vite/src/constants.ts 5/5 New file containing 143 dependency candidates for Vite optimization with clear documentation
code/builders/builder-vite/src/optimizeDeps.ts 5/5 Refactored to import INCLUDE_CANDIDATES from constants file, maintaining identical functionality
code/addons/vitest/src/vitest-plugin/index.ts 4/5 Enhanced to include Vite optimization candidates for improved test performance

Confidence score: 5/5

  • This PR is safe to merge with minimal risk as it primarily involves code organization and performance optimization
  • Score reflects clean refactoring with no functional changes to core logic, proper import structure, and consistent application across related modules
  • No files require special attention as the changes are straightforward constant extraction and consistent usage patterns

Sequence Diagram

sequenceDiagram
    participant User
    participant VitestPlugin as "Vitest Plugin"
    participant StorybookLoader as "Storybook Loader"
    participant ViteConfig as "Vite Config"
    participant OptimizeDeps as "Optimize Deps"
    participant Constants as "Constants"

    User->>VitestPlugin: "Initialize storybookTest plugin"
    VitestPlugin->>StorybookLoader: "experimental_loadStorybook(configDir)"
    StorybookLoader-->>VitestPlugin: "Return presets"
    
    VitestPlugin->>VitestPlugin: "Apply presets for stories, framework, env, etc."
    
    VitestPlugin->>Constants: "Import INCLUDE_CANDIDATES"
    Constants-->>VitestPlugin: "Return predefined dependencies list"
    
    VitestPlugin->>VitestPlugin: "Configure optimizeDeps with INCLUDE_CANDIDATES"
    
    VitestPlugin->>ViteConfig: "Return plugin configuration"
    ViteConfig->>OptimizeDeps: "getOptimizeDeps(config, options)"
    
    OptimizeDeps->>Constants: "Use INCLUDE_CANDIDATES"
    Constants-->>OptimizeDeps: "Return dependency candidates"
    
    OptimizeDeps->>OptimizeDeps: "Filter and resolve dependencies"
    OptimizeDeps-->>ViteConfig: "Return optimized dependencies config"
    
    ViteConfig-->>User: "Plugin configuration complete"
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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