chore: add code-inspector-plugin integration - #2476
Conversation
WalkthroughThe changes integrate the code-inspector-plugin into the project by adding it as a dependency and configuring it in the Vite build tool. Additionally, i18next-cli is relocated from devDependencies to dependencies, and vite is removed from devDependencies. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
web/bun.lockis excluded by!**/*.lock
📒 Files selected for processing (2)
web/package.json(1 hunks)web/vite.config.js(2 hunks)
🔇 Additional comments (1)
web/vite.config.js (1)
24-24: LGTM - Import statement is correct.The import statement for codeInspectorPlugin is syntactically correct and follows ES module conventions.
| "@so1ve/prettier-config": "^3.1.0", | ||
| "@vitejs/plugin-react": "^4.2.1", | ||
| "autoprefixer": "^10.4.21", | ||
| "code-inspector-plugin": "^1.3.3", |
There was a problem hiding this comment.
Correct the version specifier to match the latest available release.
The latest released version of code-inspector-plugin is 1.3.0, but the package.json specifies ^1.3.3. Using the caret operator, the version ^1.3.3 expects version 1.3.3 or higher, which does not exist on npm and will cause installation to fail. Change the version to ^1.3.0.
🤖 Prompt for AI Agents
In web/package.json around line 81, the dependency "code-inspector-plugin" is
incorrectly pinned to "^1.3.3" which does not exist; update the version
specifier to "^1.3.0" in that line to match the latest released package, then
run npm install (or yarn install) to update node_modules and regenerate the
lockfile (package-lock.json or yarn.lock).
| "eslint": "8.57.0", | ||
| "eslint-plugin-header": "^3.1.1", | ||
| "eslint-plugin-react-hooks": "^5.2.0", | ||
| "i18next-cli": "^1.10.3", |
There was a problem hiding this comment.
Clarify if this change is related to the PR objective.
The addition of i18next-cli to devDependencies appears unrelated to the PR's stated objective of integrating code-inspector-plugin. The AI summary mentions this as a "relocation" but doesn't explain why it's included in this PR.
If this is an intentional refactoring, consider mentioning it in the PR description for clarity.
🤖 Prompt for AI Agents
In web/package.json around line 85, the added devDependency "i18next-cli":
"^1.10.3" looks unrelated to the PR goal (integrating code-inspector-plugin);
either remove this dependency from the current commit or explicitly document why
it was added. If intended, update the PR description to state the rationale
(e.g., required tooling for localisation, relocation of i18n scripts, or
preparatory refactor) and justify why it belongs in this PR; otherwise revert
the change and submit it in a separate commit/PR.
| "typescript": "4.4.2", | ||
| "vite": "^5.2.0", | ||
| "i18next-cli": "^1.10.3" | ||
| "vite": "^5.2.0" |
There was a problem hiding this comment.
Clarify if this change is related to the PR objective.
The addition of vite to devDependencies appears unrelated to the PR's stated objective of integrating code-inspector-plugin. The AI summary mentions vite was "removed from devDependencies" elsewhere, but this seems inconsistent.
If this is an intentional dependency restructuring, consider documenting it in the PR description.
🤖 Prompt for AI Agents
In web/package.json at line 90, the addition of "vite": "^5.2.0" looks unrelated
to the PR objective (code-inspector-plugin) and conflicts with other notes that
vite was removed; update the PR so reviewers understand intent: either remove
the vite entry if it was added accidentally, or keep it and add a short note in
the PR description explaining why vite was added/reshuffled (e.g., required for
plugin dev, build changes, or devDependency consolidation) and ensure
package.json changes are consistent across the repo (remove duplicates or
reflect removal elsewhere).
| codeInspectorPlugin({ | ||
| bundler: 'vite', | ||
| }), |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cd web && cat vite.config.jsRepository: QuantumNous/new-api
Length of output: 2838
Explicitly restrict codeInspectorPlugin to development builds.
The plugin is currently included unconditionally in the Vite configuration, which means it will be bundled in production. Add an environment check:
plugins: [
+ ...(process.env.NODE_ENV === 'development' ? [
codeInspectorPlugin({
bundler: 'vite',
}),
+ ] : []),This ensures the development-only tool does not execute or bloat production builds.
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In web/vite.config.js around lines 35-37, the codeInspectorPlugin is added
unconditionally which causes it to be bundled into production; restrict it to
development by checking the environment (e.g., const isDev =
process.env.NODE_ENV === 'development' || config.mode === 'development') and
only include the plugin when isDev is true (e.g., conditionally push or spread
the plugin into the plugins array). To avoid pulling the plugin into production
even at import time, require or import() the plugin lazily inside the isDev
branch instead of importing it at module top-level.
Add the code-inspector-plugin to quickly locate the source code position in development mode.
https://github.com/zh-lx/code-inspector
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.