Skip to content

Commit 83abe04

Browse files
arnautov-antonszuperazisekovanic
authored
fix: stream-feeds-react-tutorial-related adjustments (#191)
🎫 Ticket: https://linear.app/stream/issue/REACT-690 ### 💡 Overview React tutorial sample application had troubles running on React v18 and lower for seemingly unknown reasons and errors that kept popping up weren't really telling anything useful either. The issue was in the monorepo setup and Vite's inability to bundle only one (specified) version of React into the final application's bundle. While exploring different approaches and solutions I decided to clean things up a bit and get rid of some annoying parts, here's the full list of changes. - adjusted tsconfig setup in the client, different files with different purposes - `tsconfig.lib.json` - for client types - `tsconfig.test.json` - for test files (excluding the source files) - `tsconfig.node.json` - for `vite.config.ts` - removed @self alias imports as a part of the investigation (`tsc` does not really resolve these when it's compiling declarations and that's why I had to use `vite-plugin-dts` which is still in beta), they require some extra setup and are generally not that useful - Vite does not externalize imports with different entrypoints other than `"."`, `@stream-io/state-store` is externalized while `@stream-io/state-store/react-bindings` is treated like a separate package and gets imported, added regular expressions to prevent subpaths from being bundled - ✨main course✨: upgraded Yarn to v4 to be able to use catalog protocol and cataloged `react`/`react-dom` (types too) versions across the monorepo to prevent Vite from bundling different React versions and breaking the dev setup, published SDK works well with React >=v17 Fixes: REACT-690 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Broadened React support to include v17 and made file/image upload parameters optional for more flexible usage. * **Build & Dependencies** * Upgraded Yarn to 4.12.0 and updated workspace build/test scripts. * Reworked TypeScript project layout and build configs for improved library declaration output and Node builds. * **Refactor** * Internal module/type import and packaging config cleanup; bundling/export settings adjusted for consistent outputs. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Zita Szupera <[email protected]> Co-authored-by: Ivan Sekovanikj <[email protected]>
1 parent dad0ac3 commit 83abe04

File tree

56 files changed

+7866
-10121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+7866
-10121
lines changed

.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Lines changed: 0 additions & 541 deletions
This file was deleted.

.yarn/plugins/@yarnpkg/plugin-typescript.cjs

Lines changed: 0 additions & 9 deletions
This file was deleted.

.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Lines changed: 0 additions & 28 deletions
This file was deleted.

.yarn/releases/yarn-3.5.0.cjs

Lines changed: 0 additions & 873 deletions
This file was deleted.

.yarn/releases/yarn-4.12.0.cjs

Lines changed: 942 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
catalog:
2+
"@types/react": ~19.1.0
3+
"@types/react-dom": ~19.1.0
4+
react: 19.1.0
5+
react-dom: 19.1.0
6+
17
checksumBehavior: update
28

9+
compressionLevel: mixed
10+
11+
enableGlobalCache: false
12+
313
initScope: stream-io
414

515
nodeLinker: node-modules
616

7-
plugins:
8-
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
9-
spec: "@yarnpkg/plugin-interactive-tools"
10-
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
11-
spec: "@yarnpkg/plugin-workspace-tools"
12-
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
13-
spec: "@yarnpkg/plugin-typescript"
14-
15-
yarnPath: .yarn/releases/yarn-3.5.0.cjs
17+
yarnPath: .yarn/releases/yarn-4.12.0.cjs

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22
"name": "@stream-io/feeds-js-root",
33
"description": "Stream Feeds JS SDKs",
44
"author": "https://getstream.io",
5-
"packageManager": "yarn@3.5.0",
5+
"packageManager": "yarn@4.12.0",
66
"private": true,
77
"license": "See license in LICENSE",
88
"workspaces": [
99
"packages/*",
1010
"sample-apps/**"
1111
],
1212
"scripts": {
13-
"build:all": "yarn workspaces foreach -v --topological-dev run build",
14-
"build:libs": "yarn workspaces foreach -v --topological-dev --no-private run build",
13+
"build:all": "yarn workspaces foreach -Avp --topological-dev run build",
14+
"build:libs": "yarn workspaces foreach -Avp --topological-dev --no-private run build",
1515
"build:client": "yarn workspace @stream-io/feeds-client run build",
1616
"build:react-native-sdk": "yarn workspace @stream-io/feeds-react-native-sdk run build",
1717
"build:react-sdk": "yarn workspace @stream-io/feeds-react-sdk run build",
18-
"build:react-tutorial": "yarn build:client && yarn build:react-sdk && yarn workspace stream-feeds-react-tutorial run build",
19-
"clean:all": "yarn workspaces foreach -vt run clean",
18+
"build:react-tutorial": "yarn workspaces foreach -Avp --topological-dev --include '{packages/{feeds-client,react-sdk},sample-apps/react-tutorial}' run build",
19+
"clean:all": "yarn workspaces foreach -Avp run clean",
2020
"lint:all": "eslint --max-warnings=0 --cache '**/*.{ts,tsx}'",
2121
"lint:all:fix": "eslint --max-warnings=0 '**/*.{ts,tsx}' --fix",
22-
"test:ci:all": "yarn workspaces foreach -vt run test-ci",
23-
"test:ci:libs": "yarn workspaces foreach -vt --no-private run test-ci",
24-
"test:docs-snippets": "yarn workspaces foreach -vt --no-private run test-docs-snippets",
22+
"test:ci:all": "yarn workspaces foreach -Avt run test-ci",
23+
"test:ci:libs": "yarn workspaces foreach -Avt --no-private run test-ci",
24+
"test:docs-snippets": "yarn workspaces foreach -Avt --no-private run test-docs-snippets",
2525
"generate": "./generate-openapi.sh",
2626
"lint:gen": "eslint --fix packages/**/src/gen/**/*ts && prettier packages/**/src/gen/**/*ts --write",
2727
"release": "nx run-many --target version --parallel=1",

packages/feeds-client/package.json

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"packageManager": "[email protected]",
55
"main": "./dist/cjs/index.js",
66
"module": "./dist/es/index.mjs",
7+
"types": "./dist/types/index.d.ts",
78
"exports": {
89
".": {
910
"types": "./dist/types/index.d.ts",
@@ -13,7 +14,7 @@
1314
},
1415
"import": "./dist/es/index.mjs",
1516
"require": "./dist/cjs/index.js",
16-
"default": "./dist/es/index.mjs"
17+
"default": "./dist/cjs/index.js"
1718
},
1819
"./react-bindings": {
1920
"types": "./dist/types/bindings/react/index.d.ts",
@@ -23,15 +24,14 @@
2324
},
2425
"import": "./dist/es/react-bindings.mjs",
2526
"require": "./dist/cjs/react-bindings.js",
26-
"default": "./dist/es/react-bindings.mjs"
27+
"default": "./dist/cjs/react-bindings.js"
2728
}
2829
},
29-
"types": "./dist/types/index.d.ts",
3030
"license": "See license in LICENSE",
3131
"scripts": {
3232
"clean": "rimraf dist",
33-
"start": "vite build --watch",
34-
"build": "vite build",
33+
"start": "yarn clean; concurrently 'vite build --watch' 'tsc -p tsconfig.lib.json --watch'",
34+
"build": "yarn clean; concurrently 'vite build' 'tsc -p tsconfig.lib.json'",
3535
"test": "vitest",
3636
"test:unit": "vitest --exclude '__integration-tests__/**'",
3737
"test-ci": "vitest --exclude '__integration-tests__/docs-snippets/**' --coverage",
@@ -56,19 +56,18 @@
5656
},
5757
"devDependencies": {
5858
"@stream-io/node-sdk": "0.6.0",
59-
"@types/react": "^19.1.8",
59+
"@types/react": "catalog:",
6060
"@vitest/coverage-v8": "3.2.4",
61+
"concurrently": "^9.2.1",
6162
"dotenv": "^16.4.5",
6263
"human-id": "^4.1.1",
63-
"react": "19.0.0",
6464
"rimraf": "^6.0.1",
65-
"typescript": "^5.8.3",
66-
"vite": "^7.1.11",
67-
"vite-plugin-dts": "^4.5.4",
65+
"typescript": "^5.9.3",
66+
"vite": "^7",
6867
"vitest": "^3.2.4"
6968
},
7069
"peerDependencies": {
71-
"react": "^18 || ^19"
70+
"react": "^17 || ^18 || ^19"
7271
},
7372
"peerDependenciesMeta": {
7473
"react": {

packages/feeds-client/src/activity-with-state-updates/activity-with-state-updates.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
disconnectActivityFromFeed,
88
isAnyFeedWatched,
99
} from '../feeds-client/active-activity';
10-
import type { GetCommentsRequest } from '@self';
10+
import type { GetCommentsRequest } from '../types';
1111
import { deepEqual } from '../utils/deep-equal';
1212

1313
type GetActivityConfig = {
@@ -164,7 +164,7 @@ export class ActivityWithStateUpdates {
164164
}) {
165165
this.feed = connectActivityToFeed.call(this.feedsClient, { fid });
166166

167-
this.feed.state.partialNext({
167+
this.feed?.state.partialNext({
168168
activities: [initialState],
169169
});
170170
}

packages/feeds-client/src/bindings/react/contexts/StreamFeedContext.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createContext, useContext } from 'react';
2-
import type { Feed } from '@self';
2+
3+
import type { Feed } from '../../../feed';
34

45
export const StreamFeedContext = createContext<Feed | undefined>(undefined);
56

0 commit comments

Comments
 (0)