Skip to content

chore(demo): support local reference to stream-chat-js#3205

Merged
MartinCupela merged 1 commit into
masterfrom
chore/demo/local-stream-chat-reference
Jun 3, 2026
Merged

chore(demo): support local reference to stream-chat-js#3205
MartinCupela merged 1 commit into
masterfrom
chore/demo/local-stream-chat-reference

Conversation

@MartinCupela

@MartinCupela MartinCupela commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

🎯 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

  • Chores
    • Updated Vite example configuration with enhanced dependency and filesystem handling capabilities
    • Added STREAM_CHAT_JS_PATH environment variable example to support alternative package configurations
    • Reorganized environment variable examples for improved clarity

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review Change Stack

πŸ“ Walkthrough

Walkthrough

The 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.

Changes

Local stream-chat-js Development Support

Layer / File(s) Summary
Environment variable configuration
examples/vite/.env.example
Environment example documents STREAM_CHAT_JS_PATH and VITE_USER_ID variables required for local stream-chat-js checkout support.
Module resolution and import redirection
examples/vite/vite.config.ts
Vite config becomes mode-aware and reads environment variables. At runtime, it resolves the stream-chat-react package root, detects an optional local stream-chat-js path from STREAM_CHAT_JS_PATH, validates the built entry exists, and injects a Vite plugin to redirect stream-chat imports to the local build.
Build optimization and dev server filesystem configuration
examples/vite/vite.config.ts
Vite optimizeDeps configuration explicitly includes CommonJS dependencies and conditionally excludes stream-chat when a local entry is active. Dev server filesystem allowlist expands to include rootDir, resolved stream-chat-react root, and local stream-chat-js root when available.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A rabbit hops through local builds so fine,
With env vars aligned, and imports that align!
Stream-chat paths dance where packages meet,
Dev servers welcome them both, complete! 🌿✨

πŸš₯ Pre-merge checks | βœ… 5
βœ… Passed checks (5 passed)
Check name Status Explanation
Title check βœ… Passed The title clearly and specifically describes the main change: enabling local reference support for stream-chat-js in the demo application.
Description check βœ… Passed The description includes the Goal section with clear implementation details, but is missing the Implementation details and UI Changes sections from the template.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/demo/local-stream-chat-reference

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.

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 653 kB

ℹ️ View Unchanged
Filename Size
dist/cjs/audioProcessing.js 1.74 kB
dist/cjs/emojis.js 2.54 kB
dist/cjs/index.js 256 kB
dist/cjs/mp3-encoder.js 814 B
dist/cjs/ReactPlayerWrapper.js 545 B
dist/cjs/useNotificationApi.js 46.6 kB
dist/css/emoji-picker.css 178 B
dist/css/emoji-replacement.css 456 B
dist/css/index.css 39.7 kB
dist/es/audioProcessing.mjs 1.65 kB
dist/es/emojis.mjs 2.47 kB
dist/es/index.mjs 254 kB
dist/es/mp3-encoder.mjs 768 B
dist/es/ReactPlayerWrapper.mjs 485 B
dist/es/useNotificationApi.mjs 45.4 kB

compressed-size-action

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 18dc966 and 82fbcf7.

πŸ“’ Files selected for processing (2)
  • examples/vite/.env.example
  • examples/vite/vite.config.ts

Comment on lines +46 to +51
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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚑ Quick win

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

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 83.75%. Comparing base (8c018a4) to head (82fbcf7).
⚠️ Report is 1 commits behind head on master.

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.
πŸ“’ 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.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@MartinCupela MartinCupela merged commit 32ed33e into master Jun 3, 2026
11 checks passed
@MartinCupela MartinCupela deleted the chore/demo/local-stream-chat-reference branch June 3, 2026 13:18
@stream-ci-bot

Copy link
Copy Markdown

πŸŽ‰ This PR is included in version 14.4.0 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants