chore(demo): support local reference to stream-chat-js#3205
Conversation
π WalkthroughWalkthroughThe Vite example app configuration is updated to support optional local development with stream-chat-js. Environment variables document the new STREAM_CHAT_JS_PATH setting alongside VITE_USER_ID. The Vite config becomes mode-aware, dynamically resolves package roots at runtime, detects a local stream-chat-js checkout, injects import redirection, and adjusts optimization and filesystem settings accordingly. ChangesLocal stream-chat-js Development Support
Estimated code review effortπ― 2 (Simple) | β±οΈ ~12 minutes Poem
π₯ Pre-merge checks | β 5β Passed checks (5 passed)
βοΈ Tip: You can configure your own custom pre-merge checks in the settings. β¨ Finishing Touchesπ Generate docstrings
π§ͺ 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 |
|
Size Change: 0 B Total Size: 653 kB βΉοΈ View Unchanged
|
There was a problem hiding this comment.
Actionable comments posted: 1
π€ 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 `@examples/vite/vite.config.ts`:
- Around line 46-51: The code only sets streamChatJsRoot from
env.STREAM_CHAT_JS_PATH; add the documented sibling-checkout fallback so that
when env.STREAM_CHAT_JS_PATH is undefined you also try resolving
'../../../stream-chat-js/src/index.ts' relative to rootDir (or the containing
repo) before leaving it undefined; update the streamChatJsRoot resolution logic
(the variable named streamChatJsRoot used to compute localStreamChatEntry) to
prefer env.STREAM_CHAT_JS_PATH and then fall back to the sibling checkout path,
then compute localStreamChatEntry from that resolved path as before.
πͺ 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: a53d9495-b080-4d70-a9f4-3993f6bc0591
π Files selected for processing (2)
examples/vite/.env.exampleexamples/vite/vite.config.ts
| const streamChatJsRoot = env.STREAM_CHAT_JS_PATH | ||
| ? resolve(rootDir, env.STREAM_CHAT_JS_PATH) | ||
| : undefined; | ||
| const localStreamChatEntry = streamChatJsRoot | ||
| ? resolve(streamChatJsRoot, 'dist/esm/index.mjs') | ||
| : undefined; |
There was a problem hiding this comment.
Missing sibling-checkout fallback in stream-chat-js resolution
The config currently resolves streamChatJsRoot only from STREAM_CHAT_JS_PATH. The documented workflow for this PR includes an automatic fallback to ../../../stream-chat-js/src/index.ts when env var is absent, but that branch is missing here.
Suggested patch
- const streamChatJsRoot = env.STREAM_CHAT_JS_PATH
- ? resolve(rootDir, env.STREAM_CHAT_JS_PATH)
- : undefined;
- const localStreamChatEntry = streamChatJsRoot
- ? resolve(streamChatJsRoot, 'dist/esm/index.mjs')
- : undefined;
+ const siblingStreamChatRoot = resolve(rootDir, '../../../stream-chat-js');
+ const streamChatJsRoot = env.STREAM_CHAT_JS_PATH
+ ? resolve(rootDir, env.STREAM_CHAT_JS_PATH)
+ : existsSync(resolve(siblingStreamChatRoot, 'src/index.ts'))
+ ? siblingStreamChatRoot
+ : undefined;
+ const localStreamChatEntry = streamChatJsRoot
+ ? env.STREAM_CHAT_JS_PATH
+ ? resolve(streamChatJsRoot, 'dist/esm/index.mjs')
+ : resolve(streamChatJsRoot, 'src/index.ts')
+ : undefined;π€ 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 `@examples/vite/vite.config.ts` around lines 46 - 51, The code only sets
streamChatJsRoot from env.STREAM_CHAT_JS_PATH; add the documented
sibling-checkout fallback so that when env.STREAM_CHAT_JS_PATH is undefined you
also try resolving '../../../stream-chat-js/src/index.ts' relative to rootDir
(or the containing repo) before leaving it undefined; update the
streamChatJsRoot resolution logic (the variable named streamChatJsRoot used to
compute localStreamChatEntry) to prefer env.STREAM_CHAT_JS_PATH and then fall
back to the sibling checkout path, then compute localStreamChatEntry from that
resolved path as before.
Codecov Reportβ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3205 +/- ##
==========================================
+ Coverage 83.70% 83.75% +0.04%
==========================================
Files 437 438 +1
Lines 13145 13148 +3
Branches 4255 4256 +1
==========================================
+ Hits 11003 11012 +9
+ Misses 2142 2136 -6 β View full report in Codecov by Sentry. π New features to boost your workflow:
|
|
π This PR is included in version 14.4.0 π The release is available on: Your semantic-release bot π¦π |
π― Goal
Enabled referencing the local copy of stream-chat-js to run demo app. The resolution logic is:
if .env has VITE_STREAM_CHAT_JS_PATH, it wins. If not, Vite tries the expected sibling checkout at ../../../stream-chat-js/src/index.ts (sibling of stream-chat-react folder). If that repo is not present, it falls back to the installed stream-chat dependency.
Summary by CodeRabbit
STREAM_CHAT_JS_PATHenvironment variable example to support alternative package configurations