chore: optimize package imports & remove unused imports#413
Conversation
📝 WalkthroughWalkthroughThis PR consolidates the ChangesCode and build improvements
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/fiat/page.tsx`:
- Line 20: The destructured variable setApiError from the useApiError hook is
unused (causing an ESLint no-unused-vars error); remove setApiError from the
destructuring expression where useApiError() is called (i.e., update the line
with const { uiError, setApiError, clearError, isSubmitDisabled, handleError } =
useApiError() to omit setApiError) so only used symbols (uiError, clearError,
isSubmitDisabled, handleError) are kept, or alternatively use setApiError if
intended.
In `@next.config.mjs`:
- Around line 8-16: The Next.js config is using
experimental.optimizePackageImports with per-package transform/preventFullImport
objects which is invalid; move the per-package rules into the top-level
modularizeImports key and set experimental.optimizePackageImports to an array of
package names. Specifically, replace the object entries under
experimental.optimizePackageImports with experimental.optimizePackageImports:
['lucide-react'] and add a modularizeImports object containing the
'lucide-react' and '`@/components/ui`' entries (each with transform:
'.../{{member}}' and preventFullImport: true) so modularizeImports handles the
transform/preventFullImport behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 114fe702-15ee-47ed-a9dd-11cf830bc5e9
📒 Files selected for processing (2)
app/fiat/page.tsxnext.config.mjs
| const { userId, stellarAddress } = useAuth(); | ||
| const kit = useStellarWalletsKit(); | ||
| const { uiError, setApiError, clearError, isSubmitDisabled } = useApiError(); | ||
| const { uiError, setApiError, clearError, isSubmitDisabled, handleError } = useApiError(); |
There was a problem hiding this comment.
Remove unused setApiError from hook destructuring (Line 20).
setApiError is currently unused and is flagged by ESLint (@typescript-eslint/no-unused-vars). Drop it from the destructuring (or use it) to keep CI/lint clean.
Suggested fix
- const { uiError, setApiError, clearError, isSubmitDisabled, handleError } = useApiError();
+ const { uiError, clearError, isSubmitDisabled, handleError } = useApiError();📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const { uiError, setApiError, clearError, isSubmitDisabled, handleError } = useApiError(); | |
| const { uiError, clearError, isSubmitDisabled, handleError } = useApiError(); |
🧰 Tools
🪛 ESLint
[error] 20-20: 'setApiError' is assigned a value but never used.
(@typescript-eslint/no-unused-vars)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@app/fiat/page.tsx` at line 20, The destructured variable setApiError from the
useApiError hook is unused (causing an ESLint no-unused-vars error); remove
setApiError from the destructuring expression where useApiError() is called
(i.e., update the line with const { uiError, setApiError, clearError,
isSubmitDisabled, handleError } = useApiError() to omit setApiError) so only
used symbols (uiError, clearError, isSubmitDisabled, handleError) are kept, or
alternatively use setApiError if intended.
| optimizePackageImports: { | ||
| 'lucide-react': { | ||
| transform: 'lucide-react/dist/esm/icons/{{member}}', | ||
| preventFullImport: true, | ||
| }, | ||
| '@/components/ui': { | ||
| transform: '@/components/ui/{{member}}', | ||
| preventFullImport: true, | ||
| }, |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
`For Next.js 16.0.10, what is the exact expected schema for:
- experimental.optimizePackageImports
- modularizeImports
Please include official docs/examples showing whether transform/preventFullImport are valid under optimizePackageImports.`
💡 Result:
- experimental.optimizePackageImports (Next.js 16.0.10) Exact expected schema (from the official docs): module.exports = { experimental: { optimizePackageImports: ['package-name'], }, } So, experimental.optimizePackageImports is an array of package specifiers (strings). [1] Official notes/examples about transform/preventFullImport validity under optimizePackageImports: - The optimizePackageImports docs describe only the allow-list array of package names and do not mention any per-package options such as transform or preventFullImport. [1] - In contrast, preventFullImport is explicitly documented as an option for modularizeImports (not optimizePackageImports). [2] Conclusion: transform and preventFullImport are not valid keys under experimental.optimizePackageImports based on the official optimizePackageImports documentation (which specifies only the array of package names). [1] 2) modularizeImports (Next.js 16.0.10) Exact expected schema: module.exports = { modularizeImports: { 'package-name': { transform: 'package-name/{{member}}', preventFullImport: true, }, }, } This comes directly from the official docs that show: - modularizeImports is an object keyed by package name - each key maps to an object containing at least transform - and includes an example configuration for preventFullImport: true [3] Official docs/examples showing whether transform/preventFullImport are valid under optimizePackageImports: - For modularizeImports: yes, both transform and preventFullImport are documented and used in the example config. [3] - For optimizePackageImports: only optimizePackageImports: ['package-name'] is documented; there is no documented structure supporting transform or preventFullImport under experimental.optimizePackageImports. [1] Therefore, transform and preventFullImport are valid under modularizeImports, but not under experimental.optimizePackageImports (as documented for Next.js 16). [1][3]
Citations:
- 1: https://nextjs.org/docs/app/api-reference/config/next-config-js/optimizePackageImports
- 2: modularize_imports issue for re-export from node_modules vercel/next.js#40347
- 3: sebmarkbage/next.js@1ba4140
Fix Next.js config schema: use modularizeImports for transform/preventFullImport
experimental.optimizePackageImports only supports an array of package specifiers (e.g., ['lucide-react']). The current per-package object entries with transform and preventFullImport won’t be applied there; move those rules under modularizeImports:
export default {
experimental: {
optimizePackageImports: ['lucide-react'],
},
modularizeImports: {
'lucide-react': {
transform: 'lucide-react/dist/esm/icons/{{member}}',
preventFullImport: true,
},
'`@/components/ui`': {
transform: '`@/components/ui/`{{member}}',
preventFullImport: true,
},
},
};🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@next.config.mjs` around lines 8 - 16, The Next.js config is using
experimental.optimizePackageImports with per-package transform/preventFullImport
objects which is invalid; move the per-package rules into the top-level
modularizeImports key and set experimental.optimizePackageImports to an array of
package names. Specifically, replace the object entries under
experimental.optimizePackageImports with experimental.optimizePackageImports:
['lucide-react'] and add a modularizeImports object containing the
'lucide-react' and '`@/components/ui`' entries (each with transform:
'.../{{member}}' and preventFullImport: true) so modularizeImports handles the
transform/preventFullImport behavior.
|
@hashmart138-creator Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
chore: optimize imports & remove unused imports
Summary
lucide-reactand local UI exports.scripts/find-unused-imports.cjsto help find remaining unused icons/hooks.Files changed
next.config.mjs— addedexperimental.optimizePackageImportsentriesapp/auth/wallet-setup/page.tsx— removed unusedDialog*importsapp/business/sme/page.tsx— removed unusedArrowRighticon importscripts/find-unused-imports.cjs,scripts/find-unused-imports.js— added detection scriptsTesting & Notes
fix/optimize-imports-unused-importsand pushed the changes.pnpm lint -- --fixor the test suite in this environment (pnpm not available). Please run the lint and tests locally or in CI and apply/approve any additional fixes.Recommended local steps
Checklist
experimental.optimizePackageImportstonext.config.mjspnpm lint -- --fixand apply remaining fixesclose #353 close #349