[FIX] Fix Vite plugin to handle intra-plugin sibling imports#1809
[FIX] Fix Vite plugin to handle intra-plugin sibling imports#1809hari-kuriakose merged 2 commits intomainfrom
Conversation
The optionalPluginImports Vite plugin previously only intercepted imports where the source path contained "plugins/" (e.g. "../plugins/foo"). This missed sibling relative imports within a plugin directory (e.g. "./TrialMessage" from plugins/login-form/), causing the on-prem frontend build to fail when cloud-only files like TrialMessage.jsx are removed from the build context. Fix: check the resolved path instead of the source string so both cross-plugin and intra-plugin imports are handled correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary by CodeRabbit
WalkthroughModified the conditional logic in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@frontend/vite.config.js`:
- Line 29: The check using resolved.includes("/plugins/") is platform-dependent
and fails on Windows; normalize the resolved path before checking by converting
backslashes to forward slashes (or using path.posix/path.normalize) and then
test for "/plugins/". Update the logic around the resolved variable (the result
of path.resolve()) where includes("/plugins/") is used so the path is normalized
first, then perform the includes check and return null accordingly.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to Reviews > Disable Cache setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (1)
frontend/vite.config.js
Frontend Lint Report (Biome)✅ All checks passed! No linting or formatting issues found. |
|
hari-kuriakose
left a comment
There was a problem hiding this comment.
@vishnuszipstack LGTM overall



What
optionalPluginImportsVite plugin to handle intra-plugin sibling imports (e.g../TrialMessagefrom withinplugins/login-form/)Why
Could not resolve "./TrialMessage" from "src/plugins/login-form/LoginForm.jsx"TrialMessage.jsxandSwitchRegion.jsxLoginForm.jsxusesawait import("./TrialMessage")inside a try/catch — Rollup resolves this at build time, and the Vite plugin was supposed to intercept missing files and return an empty modulesource.includes("plugins/")) only matched imports with"plugins/"in the source path (e.g.../plugins/foo), missing sibling imports like"./TrialMessage"that don't contain"plugins/"in the source stringHow
"./TrialMessage"imported fromplugins/login-form/LoginForm.jsxis/path/to/plugins/login-form/TrialMessage— which correctly contains"/plugins/"../plugins/foo) and intra-plugin sibling importsCan this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
null(normal Rollup resolution). The change only widens the filter to catch more missing-file cases within the plugins directory, so existing builds with all files present are unaffected.Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
Dependencies Versions