feat(storybook): compose React Native components into React Storybook#1188
Conversation
📖 Storybook Preview |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Absolute refs URL breaks on sub-path deployments
- Updated the Storybook refs URL from '/react-native' to './react-native' so composition works under sub-path hosting (e.g., GitHub Pages and PR previews).
Or push these changes by commenting:
@cursor push d23ee11abb
Preview (d23ee11abb)
diff --git a/apps/storybook-react/.storybook/main.ts b/apps/storybook-react/.storybook/main.ts
--- a/apps/storybook-react/.storybook/main.ts
+++ b/apps/storybook-react/.storybook/main.ts
@@ -24,7 +24,7 @@
// In production the RN static build is nested at /react-native on the same host.
const rnStorybookUrl =
process.env.STORYBOOK_RN_URL ??
- (process.env.NODE_ENV === 'production' ? '/react-native' : 'http://localhost:6007');
+ (process.env.NODE_ENV === 'production' ? './react-native' : 'http://localhost:6007');
const config: StorybookConfig = {
refs: {You can send follow-ups to the cloud agent here.
📖 Storybook Preview |
📖 Storybook Preview |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: CommonJS include option restricts processing to one package
- Added /node_modules/ to commonjsOptions.include so all CJS deps are processed while still explicitly handling react-native-jazzicon.
Or push these changes by commenting:
@cursor push a8c49d4954
Preview (a8c49d4954)
diff --git a/apps/storybook-react-native/.storybook/main.ts b/apps/storybook-react-native/.storybook/main.ts
--- a/apps/storybook-react-native/.storybook/main.ts
+++ b/apps/storybook-react-native/.storybook/main.ts
@@ -74,7 +74,7 @@
commonjsOptions: {
// Explicitly include CJS-only packages so Rollup's commonjs plugin
// converts them to ESM in the production bundle.
- include: [/react-native-jazzicon/],
+ include: [/react-native-jazzicon/, /node_modules/],
transformMixedEsModules: true,
},
},You can send follow-ups to the cloud agent here.
📖 Storybook Preview |
| // in both dev and production builds. | ||
| include: [ | ||
| ...(viteConfig.optimizeDeps?.include ?? []), | ||
| 'react-native-jazzicon', |
There was a problem hiding this comment.
Fixed in 89c30ab. The build.commonjsOptions.include pattern was removed entirely — setting include on @rollup/plugin-commonjs restricts the plugin to only the matched packages, silently skipping CJS→ESM conversion for every other CJS dependency in the production bundle. The default (no include filter) processes all CJS files, which is correct. CJS conversion for react-native-jazzicon in the dev server is handled by optimizeDeps.include; Rollup's default commonjs pass covers production builds.
📖 Storybook Preview |
9e2aaaf to
f4a33d5
Compare
89c30ab to
5786484
Compare
📖 Storybook Preview |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Production ref URL mis-resolved
- Configured the host Storybook build steps to export STORYBOOK_RN_URL=./react-native so the composed ref resolves to the production path during static builds.
Or push these changes by commenting:
@cursor push 66cfe4ea3f
Preview (66cfe4ea3f)
diff --git a/.github/workflows/build-storybook-main.yml b/.github/workflows/build-storybook-main.yml
--- a/.github/workflows/build-storybook-main.yml
+++ b/.github/workflows/build-storybook-main.yml
@@ -21,6 +21,8 @@
- name: Build React Storybook
working-directory: apps/storybook-react
+ env:
+ STORYBOOK_RN_URL: ./react-native
run: |
yarn build-storybook
touch storybook-static/.nojekyll
diff --git a/.github/workflows/build-storybook-pr.yml b/.github/workflows/build-storybook-pr.yml
--- a/.github/workflows/build-storybook-pr.yml
+++ b/.github/workflows/build-storybook-pr.yml
@@ -23,6 +23,8 @@
- name: Build React Storybook
working-directory: apps/storybook-react
+ env:
+ STORYBOOK_RN_URL: ./react-native
run: yarn build-storybook
- name: Build React Native web StorybookYou can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 5786484. Configure here.
📖 Storybook Preview |


Description
Adds React Native component stories to the existing React Storybook by using Storybook composition.
The React Storybook now acts as the host Storybook and includes a composed React Native Components section. This makes the React Native web Storybook available from the same Storybook UI in local development, PR preview builds, and the deployed web Storybook.
Storybook composition lets one Storybook reference another Storybook by URL so stories from both appear together in the sidebar, even when they use different renderers or project setup: https://storybook.js.org/docs/sharing/storybook-composition
What changed
react-nativeStorybookrefsentry inapps/storybook-react/.storybook/main.ts.http://localhost:6007during local development../react-nativefor static hosted builds.storybook-static/react-native/before deploying to GitHub Pages.Local dev workflow
Open
http://localhost:6006and expand React Native Components in the sidebar.Related issues
Depends on: #1134
Manual testing steps
yarn storybook:weband wait for the React Native web Storybook to run on port 6007.yarn storybookand openhttp://localhost:6006.Screenshots/Recordings
After
The hosted React Storybook includes a composed React Native Components section backed by the React Native web Storybook.
after720.mov
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Changes are limited to Storybook config and GitHub Actions; no runtime product or package publish paths are affected.
Overview
Wires Storybook composition so the React Storybook hosts React Native web stories in one sidebar (React Native Components).
apps/storybook-react/.storybook/main.tsadds arefs.react-nativeentry whose URL ishttp://localhost:6007in dev (overridable viaSTORYBOOK_RN_URL) and./react-nativefor static builds.Main and PR Storybook workflows no longer use a single default working directory for all steps. They build React Storybook and React Native web Storybook separately, copy the RN static output into
storybook-static/react-native/, then deploy or upload the combinedapps/storybook-react/storybook-staticartifact unchanged for consumers.Reviewed by Cursor Bugbot for commit e52bd25. Bugbot is set up for automated code reviews on this repo. Configure here.