-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: onDisabledRemoveStorybook option (#622)
* feat: experiment with onDisabledRemoveStorybook option * fix: readme * v8.3.10-alpha.0 * feat: types for withstorybook * v8.3.10-alpha.1 * fix: uninitialised force render * v8.3.10-alpha.2 * fix: search results empty string error * v8.3.10
- Loading branch information
Showing
16 changed files
with
172 additions
and
51 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"npmClient": "yarn", | ||
"registry": "https://registry.npmjs.org", | ||
"version": "8.3.9" | ||
"version": "8.3.10" | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import type { InputConfigT } from 'metro-config'; | ||
|
||
/** | ||
* Options for configuring WebSockets used for syncing storybook instances or sending events to storybook. | ||
*/ | ||
interface WebsocketsOptions { | ||
/** | ||
* The port WebSocket server will listen on. Defaults to 7007. | ||
*/ | ||
port?: number; | ||
|
||
/** | ||
* The host WebSocket server will bind to. Defaults to 'localhost'. | ||
*/ | ||
host?: string; | ||
} | ||
|
||
/** | ||
* Options for configuring Storybook with React Native. | ||
*/ | ||
interface WithStorybookOptions { | ||
/** | ||
* The path to the Storybook config folder. Defaults to './.storybook'. | ||
*/ | ||
configPath?: string; | ||
|
||
/** | ||
* Whether Storybook is enabled. Defaults to true. | ||
*/ | ||
enabled?: boolean; | ||
|
||
/** | ||
* WebSocket configuration for syncing storybook instances or sending events to storybook. | ||
*/ | ||
websockets?: WebsocketsOptions; | ||
|
||
/** | ||
* Whether to use JavaScript files for Storybook configuration instead of TypeScript. Defaults to false. | ||
*/ | ||
useJs?: boolean; | ||
|
||
/** | ||
* If enabled is false and onDisabledRemoveStorybook is true, we will attempt to remove storybook from the js bundle. | ||
*/ | ||
onDisabledRemoveStorybook?: boolean; | ||
} | ||
|
||
/** | ||
* Configures Metro bundler to work with Storybook in React Native. | ||
* This function wraps a Metro configuration to enable Storybook usage. | ||
* | ||
* @param config - The Metro bundler configuration to be modified. | ||
* @param options - Options to customize the Storybook configuration. | ||
* @returns The modified Metro configuration. | ||
* | ||
* @example | ||
* const { getDefaultConfig } = require('expo/metro-config'); | ||
* const withStorybook = require('@storybook/react-native/metro/withStorybook'); | ||
* const path = require('path'); | ||
* | ||
* const projectRoot = __dirname; | ||
* const config = getDefaultConfig(projectRoot); | ||
* | ||
* module.exports = withStorybook(config, { | ||
* enabled: true, | ||
* configPath: path.resolve(projectRoot, './.storybook'), | ||
* websockets: { port: 7007, host: 'localhost' }, | ||
* useJs: false, | ||
* onDisabledRemoveStorybook: true, | ||
* }); | ||
*/ | ||
export function withStorybook(config: InputConfigT, options?: WithStorybookOptions): InputConfigT; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.