Skip to content

Commit ac7f6da

Browse files
committed
deprecate instead of removing option
1 parent 1e3956e commit ac7f6da

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

code/frameworks/react-native-web-vite/src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ import type { BabelOptions, Options as ReactOptions } from 'vite-plugin-rnw';
99

1010
export type FrameworkOptions = FrameworkOptionsBase & {
1111
pluginReactOptions?: Omit<ReactOptions, 'babel'> & { babel?: BabelOptions };
12+
/**
13+
* @deprecated These options will be ignored. Use `pluginReactOptions` now for everything and
14+
* override includes in order to transpile node_modules pluginBabelOptions will be removed in
15+
* the next major version. To configure babel, use `pluginReactOptions.babel`.
16+
*/
17+
pluginBabelOptions?: Record<string, unknown>;
1218
};
1319

1420
type FrameworkName = CompatibleString<'@storybook/react-native-web-vite'>;

docs/get-started/frameworks/react-native-web-vite.mdx

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -144,24 +144,12 @@ const config: StorybookConfig = {
144144
presets: Array<string | [string, any]>,
145145
// ... other compatible babel options
146146
}
147-
include: Array<string|RegExp>,
148-
exclude: Array<string|RegExp>,
147+
include: Array<string|RegExp>,
148+
149+
// default excludes: /\/node_modules\/(?!react-native|@react-native|expo|@expo)/;
150+
exclude: Array<string|RegExp>,
149151
// ... other compatible @vitejs/plugin-react options
150152
}
151-
152-
// these options are used to configure transpilation of node_modules via babel
153-
// in most cases, you don't need to configure these options, but they are available if you need them
154-
pluginBabelOptions: {
155-
include: Array<string|RegExp>, // default: [/node_modules\/(react-native|@react-native)/]
156-
exclude: Array<string|RegExp>, // default: undefined
157-
presets: Array<string|[string, any]>,
158-
plugins: Array<string|[string, any]>,
159-
presetReact?: {
160-
runtime?: 'automatic' | 'classic'; // default: 'automatic'
161-
importSource?: string; // default: 'react'
162-
};
163-
// ... other compatible vite-plugin-babel options
164-
}
165153
},
166154
},
167155
};
@@ -210,6 +198,26 @@ const main: StorybookConfig = {
210198
}
211199
```
212200

201+
#### Example configuration to transpile additional node_modules
202+
203+
Lets say you need to transpile a library called `my-library` that is not included in the default excludes.
204+
You can do so by overriding the `exclude` option.
205+
206+
```ts title=".storybook/main.ts"
207+
const main: StorybookConfig = {
208+
// ... rest of config
209+
210+
framework: {
211+
name: "@storybook/react-native-web-vite",
212+
options: {
213+
pluginReactOptions: {
214+
exclude: /\/node_modules\/(?!react-native|@react-native|expo|@expo|my-library)/;
215+
},
216+
},
217+
},
218+
}
219+
```
220+
213221
#### `builder`
214222

215223
Type: `Record<string, any>`

0 commit comments

Comments
 (0)