Skip to content

On website, use recharts from the source code instead of npm registry#6725

Merged
ckifer merged 1 commit into
mainfrom
www-inline
Dec 4, 2025
Merged

On website, use recharts from the source code instead of npm registry#6725
ckifer merged 1 commit into
mainfrom
www-inline

Conversation

@PavelVanecek

@PavelVanecek PavelVanecek commented Dec 3, 2025

Copy link
Copy Markdown
Collaborator

Description

We already had this for local dev, now the same config applies for prod as well.

Related Issue

The zIndex fiasco.

Motivation and Context

This allows us to write examples and guides for not-yet-released features. Same as we were doing with Storybook.

Summary by CodeRabbit

  • Chores
    • Updated recharts dependency to the latest version
    • Streamlined development build configuration

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Updates the recharts dependency to latest, simplifies the vite config factory signature to remove mode-based parameter, makes the recharts alias unconditional in the build configuration, and adds explanatory comments to tsconfig.json regarding type mappings.

Changes

Cohort / File(s) Summary
Dependency Management
www/package.json
Changed recharts from version ^3.5.1 to latest for automatic latest release tracking
Build Configuration
www/vite.config.ts
Simplified config factory from mode-based parameter to parameterless form; made recharts alias unconditional (always resolves to local ../src), eliminating development-mode-only branching
Documentation
www/tsconfig.json
Added multi-line explanatory comment in paths section describing Recharts type mapping rationale and build-types step; no functional changes to configuration

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • www/vite.config.ts: Verify that removing the mode-based conditional alias doesn't affect production builds or break build-time behavior in non-development environments
  • www/package.json: Confirm that pinning to latest is intentional and won't introduce unexpected breaking changes from future recharts releases

Possibly related PRs

Suggested reviewers

  • ckifer

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The description is incomplete and vague, missing required sections like 'Related Issue' link, testing details, and change type checkboxes. Add a direct link to the related issue, describe testing procedures, and complete the 'Types of changes' and 'Checklist' sections from the template.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: using recharts from source code instead of npm registry on the website.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch www-inline

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
www/tsconfig.json (1)

26-35: Helpful documentation, but consider automating the build-types step.

The comment clearly explains the type mapping rationale. However, requiring developers to manually run npm run build-types from the main package could lead to type/implementation mismatches if forgotten.

Consider one of these improvements:

  1. Add a postinstall or prepare script to the main package.json that runs build-types automatically
  2. Document this requirement in the www README or CONTRIBUTING guide
  3. Add a pre-commit hook or CI check to ensure types are up-to-date
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c3bd1a0 and ce15526.

📒 Files selected for processing (3)
  • www/package.json (1 hunks)
  • www/tsconfig.json (1 hunks)
  • www/vite.config.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (DEVELOPING.md)

Run type checking on the codebase using npm run check-types

**/*.{ts,tsx}: Never use any type (implicit or explicit) in TypeScript code
Prefer unknown over any and refine the type in TypeScript
Type function parameters and return values explicitly in TypeScript, do not rely on implicit any or inference; exceptions are React components and trivial functions
Do not use as type assertions in TypeScript; the only exception is as const

Files:

  • www/vite.config.ts
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Ensure code lints by running npm run lint and follows Airbnb's Style Guide

Files:

  • www/vite.config.ts
🧠 Learnings (6)
📚 Learning: 2025-11-19T14:08:01.728Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6659
File: www/src/components/GuideView/Performance/index.tsx:232-250
Timestamp: 2025-11-19T14:08:01.728Z
Learning: In Recharts version 3.4.2, object-as-prop optimizations were introduced to reduce unnecessary re-renders when new object references are passed as props. This affects the recommendation for the `react-perf/jsx-no-new-object-as-prop` ESLint rule.

Applied to files:

  • www/package.json
📚 Learning: 2025-11-25T01:22:48.289Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: DEVELOPING.md:0-0
Timestamp: 2025-11-25T01:22:48.289Z
Learning: Applies to **/*.{ts,tsx} : Run type checking on the codebase using `npm run check-types`

Applied to files:

  • www/tsconfig.json
📚 Learning: 2025-11-25T01:22:59.729Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-25T01:22:59.729Z
Learning: Applies to **/*.{ts,tsx} : Type function parameters and return values explicitly in TypeScript, do not rely on implicit any or inference; exceptions are React components and trivial functions

Applied to files:

  • www/tsconfig.json
📚 Learning: 2025-11-25T01:22:59.729Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-25T01:22:59.729Z
Learning: Applies to **/*.{ts,tsx} : Do not use `as` type assertions in TypeScript; the only exception is `as const`

Applied to files:

  • www/tsconfig.json
📚 Learning: 2025-11-23T13:30:10.395Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6669
File: www/src/docs/exampleComponents/ScatterChart/ScatterChartWithLabels.tsx:2-2
Timestamp: 2025-11-23T13:30:10.395Z
Learning: The `TooltipIndex` type from recharts is defined in `src/state/tooltipSlice.ts` but is not currently exported from the public API entry points. It should not be imported from `recharts/types/state/tooltipSlice` as this is an internal implementation path. An ESLint rule is needed to prevent regressions.

Applied to files:

  • www/tsconfig.json
📚 Learning: 2025-11-25T01:22:48.289Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: DEVELOPING.md:0-0
Timestamp: 2025-11-25T01:22:48.289Z
Learning: Applies to {test,www/test}/**/*.spec.{ts,tsx} : Write unit tests in the `test` or `www/test` directories with `.spec.tsx` file extension

Applied to files:

  • www/tsconfig.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build, Test, Pack
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
www/vite.config.ts (2)

8-8: LGTM: Correctly removed unused parameter.

The mode parameter is no longer needed since the alias is now unconditional. This simplifies the function signature appropriately.


44-54: This configuration is appropriate for the monorepo structure.

The ../src alias in www/vite.config.ts is specifically for building the documentation website, not the npm package distribution. The repository structure ensures that src is always available relative to www during builds. The root package.json build scripts compile the actual npm package independently—they are unaffected by this website configuration. Production website deployments will work correctly as long as the monorepo structure is maintained, which is guaranteed during the build process.

Comment thread www/package.json
"react-router-dom": "^7.9.5",
"react-runner": "^1.0.5",
"recharts": "^3.5.1",
"recharts": "latest",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Check the vite config for alias configuration
cd www && cat -n vite.config.ts

Repository: recharts/recharts

Length of output: 2152


🏁 Script executed:

# Check if node_modules/recharts is referenced anywhere
rg "node_modules/recharts" --type-add 'config:*.{json,ts,js,mts}' -i

Repository: recharts/recharts

Length of output: 168


🏁 Script executed:

# Check current package.json for recharts version
grep -A2 -B2 '"recharts"' www/package.json

Repository: recharts/recharts

Length of output: 189


🏁 Script executed:

# Look for any imports of recharts from node_modules or understanding build setup
rg "from ['\"]recharts['\"]" www/src --type ts --type tsx --type js --type jsx -c

Repository: recharts/recharts

Length of output: 88


🏁 Script executed:

# Search for recharts imports with correct syntax
rg "from ['\"]recharts" www/src -A 2

Repository: recharts/recharts

Length of output: 45157


🏁 Script executed:

# Check if www is a published package or just docs
cat www/package.json | head -20

Repository: recharts/recharts

Length of output: 716


🏁 Script executed:

# See if www build output or any process uses node_modules/recharts
rg "node_modules" www --type json --type js --type ts

Repository: recharts/recharts

Length of output: 213


🏁 Script executed:

# Check the root package.json to understand project structure
cat package.json | grep -A 5 '"name"'

Repository: recharts/recharts

Length of output: 389


🏁 Script executed:

# Check if www package is published or deployed anywhere
grep -r "recharts.github.io" . --include="*.json" --include="*.md" --include="*.yml" --include="*.yaml" 2>/dev/null | head -20

Repository: recharts/recharts

Length of output: 1878


🏁 Script executed:

# Check the CI/CD or deployment config to see if www is built/deployed
find . -name ".github" -o -name ".gitlab-ci.yml" -o -name ".circleci" -o -name "netlify.toml" -o -name "vercel.json" 2>/dev/null | head -5

Repository: recharts/recharts

Length of output: 70


🏁 Script executed:

# Verify what versions of recharts might be needed if alias fails
cat www/package-lock.json | grep -A 10 '"recharts"' | head -20

Repository: recharts/recharts

Length of output: 114


Replace "latest" with a pinned version to ensure reproducible builds.

The "latest" version specifier can lead to non-deterministic builds, as different environments may install different versions. Although www/vite.config.ts unconditionally aliases recharts to the local ../src directory (which serves the website's development and production builds), the npm dependency in www/package.json should still specify an exact or caret version to maintain reproducibility and provide a clear fallback reference.

Consider pinning to the version matching the main package (e.g., "^3.5.1") for consistency and clarity, even if the alias always takes precedence.

🤖 Prompt for AI Agents
In www/package.json around line 45, the dependency "recharts": "latest" should
be replaced with a pinned or careted version (for example "recharts": "^3.5.1")
to ensure reproducible builds and a clear fallback; update that entry to the
chosen exact/caret version and then regenerate the lockfile (npm/yarn/pnpm
install) so the lockfile reflects the pinned dependency.

@codecov

codecov Bot commented Dec 3, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.02%. Comparing base (c3bd1a0) to head (ce15526).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6725   +/-   ##
=======================================
  Coverage   94.02%   94.02%           
=======================================
  Files         500      500           
  Lines       42684    42684           
  Branches     4917     4917           
=======================================
  Hits        40135    40135           
  Misses       2544     2544           
  Partials        5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codecov

codecov Bot commented Dec 3, 2025

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@ckifer
ckifer merged commit 6aec882 into main Dec 4, 2025
39 checks passed
@ckifer
ckifer deleted the www-inline branch December 4, 2025 05:59
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.

2 participants