Repository navigation
docs: document ENTRY_FILE for Storybook release builds on React Native CLI - #951
Merged
Merged
Conversation
`STORYBOOK_ENABLED=true react-native bundle`, which is also what Xcode and Gradle run for release builds, shipped the app instead of Storybook: the swap lived only in `resolver.resolveRequest`, and Metro does not ask the resolver about the entry when it is building. It now also happens in a transform worker that chains to whichever worker the app had configured, resolved the way Metro resolves it, so `start`, `bundle` and native release builds all produce the Storybook app. Fixes #944
|
next now resolves metro 0.87.1 everywhere, so keeping the 0.84.6 pin would install a second metro just for the bundle entry swap tests. This also regenerates the lockfile, which the merge left without the metro entries.
…e CLI Replace the transform-worker entry swap with documentation. Metro's `react-native bundle` path does not resolve the entry file through the resolver, so entry-point swapping cannot apply there. Taking over `transformerPath` to work around it put a Storybook worker in front of every transform for all users to fix a case that only affects React Native CLI release builds, which React Native already lets you solve with `ENTRY_FILE`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue: #944
What I did
With the entry-point-swapping
withStorybook,STORYBOOK_ENABLED=true react-native bundleproduces the app bundle, not Storybook. Xcode and Gradle runreact-native bundlefor release builds, so this affects Storybook release builds in React Native CLI projects. Metro'sServer.build()takes the entry file as an absolute path and never callsresolveRequestfor it, so the resolver swap cannot apply there. The dev server and Expo are not affected.This PR previously fixed that by taking over Metro's
transformerPathwith a Storybook worker. That put a new worker in front of every transform for every entry-swap user, including the setups that already work, and needed a lot of code to do safely (finding the right Metro in isolated installs, chaining to Expo's and other wrappers' workers, cache keys). I've dropped that in favour of documenting what React Native already supports:ENTRY_FILE=.rnstorybook/index.tsxis honoured by bothreact-native-xcode.shand the React Native Gradle plugin, relative to the project root.--entry-file .rnstorybook/index.tsxwhen callingreact-native bundledirectly.Changes:
No package code changes, so no changeset.
How to test
docs/docs/intro/configuration/metro-configuration.md.STORYBOOK_ENABLED=true npx react-native bundle --entry-file .rnstorybook/index.tsx --platform ios --dev false --bundle-output /tmp/sb.jsand check the output containsgetStorybookUI.Fixes #944