react-native
react-native copied to clipboard
feat/v8
- updated to be compatible with v8
- new ui
- ui components extracted to ui package
- better hmr (story list updates live without reloads)
breaking:
- new requirements
- @gorhom/bottom-sheet, react-native-gesture-handler, react-native-reanimated, react-native-svg
todo:
- [ ] new controls ui
- [ ] currently on rn cli a react-native-url-polyfill is needed to not crash the app, need to track this down and fix
- [x] rework the bottom sheet
- [ ] make the new ui work on web/wide screens
- [ ] refactor theme, right now its a mix between old and new (copy of web theme). Instead should update anywhere that references old theme values to use new theme values.
progress:
https://github.com/storybookjs/react-native/assets/3481514/be142218-189f-47f4-a3b6-13856a78c836
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/@adobe/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@expo/[email protected], npm/@expo/[email protected], npm/@expo/[email protected], npm/@floating-ui/[email protected], npm/@floating-ui/[email protected], npm/@floating-ui/[email protected], npm/@floating-ui/[email protected], npm/@juggle/[email protected], npm/@mdx-js/[email protected], npm/@pmmmwh/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@swc/[email protected], npm/@swc/[email protected], npm/@swc/[email protected], npm/@swc/[email protected], npm/@swc/[email protected], npm/@swc/[email protected], npm/@swc/[email protected], npm/@swc/[email protected], npm/@swc/[email protected], npm/@swc/[email protected], npm/@swc/[email protected], npm/@swc/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@vitest/[email protected], npm/@vitest/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]
👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎
This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.
Ignoring: npm/@adobe/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@expo/[email protected], npm/@expo/[email protected], npm/@mdx-js/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@storybook/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@ungap/[email protected], npm/@vitest/[email protected], npm/@vitest/[email protected], npm/@vitest/[email protected], npm/@vitest/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]
Next steps
Take a deeper look at the dependency
Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.
Remove the package
If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.
Mark a package as acceptable risk
To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/[email protected] or ignore all packages with @SocketSecurity ignore-all
@SocketSecurity ignore-all
Hey! Great work here. Just wondering what work is left to get v8 support and maybe offer assistance to move this along. Thanks!
@vstlouis Hey at this point its missing
- [ ] Updated controls ui
- [x] rework the bottom sheet
- [ ] make the new ui work on web/wide screens
- [ ] refactor theme, right now its a mix between old and new (copy of web theme). Instead should update anywhere that references old theme values to use new theme values.
Problem is I've had a lot going on in my personal/work life so haven't had any time to pick this up.
If you or anyone wants to have a go at bringing the controls ui closer to the web version of mobile ui or anything else listed then im happy to review prs
v8.2 was a bit of a setback as there was a large change to upstream apis that broke a lot in RN storybook. I've now introduced
@storybook/react-native/metro/withStorybook
That works around many issues and also provides the required metro config.
Metro config for storybook should now be done like this in 8.2.0-alpha.1
const withStorybook = require('@storybook/react-native/metro/withStorybook');
module.exports = withStorybook(defaultConfig, {
enabled: process.env.STORYBOOK_ENABLED === 'true',
configPath: path.resolve(__dirname, './.storybook'),
});
This follows the same pattern as tamagui and nativewind for metro configuration. Should also be compatible, see this tamagui example: https://github.com/dannyhw/tamagui-expo-router-sb8
Note that this is still early and until we reach RC status there can still be a few more changes. I believe this withStorybook change is actually positive and makes it easier to explain setup anyway.
v8.2 was a bit of a setback as there was a large change to upstream apis that broke a lot in RN storybook. I've now introduced
@storybook/react-native/metro/withStorybookThat works around many issues and also provides the required metro config.Metro config for storybook should now be done like this in 8.2.0-alpha.1
const withStorybook = require('@storybook/react-native/metro/withStorybook'); module.exports = withStorybook(defaultConfig, { enabled: process.env.STORYBOOK_ENABLED === 'true', configPath: path.resolve(__dirname, './.storybook'), });This follows the same pattern as tamagui and nativewind for metro configuration. Should also be compatible, see this tamagui example: https://github.com/dannyhw/tamagui-expo-router-sb8
Note that this is still early and until we reach RC status there can still be a few more changes. I believe this withStorybook change is actually positive and makes it easier to explain setup anyway.
Hey @dannyhw , wondering how this ties in to existing metro configs that select different App.tsx files based on STORYBOOK_ENABLED eg:
if (process.env.STORYBOOK_ENABLED === 'true') {
const { generate } = require('@storybook/react-native/scripts/generate')
generate({
// eslint-disable-next-line no-undef
configPath: path.resolve(__dirname, './.storybook'),
})
config.resolver.sourceExts = [
// XXX: For the App.storybook.tsx file this must be first
'storybook.tsx',
...config.resolver.sourceExts,
'mjs',
]
}
The idea is to make sure storybook isn't bundled on prod apps. p.s. appreciate the effort on updating this to 8.2 :)
@kzlar If you want to remove storybook from the bundle the easiest way is to adjust metros resolveRequest to ignore storybook files.
defaultConfig.resolver.resolveRequest = (context, moduleName, platform) => {
const defaultResolveResult = context.resolveRequest(
context,
moduleName,
platform
);
if (
process.env.STORYBOOK_ENABLED !== "true" &&
defaultResolveResult?.filePath?.includes?.(".storybook/")
) {
return {
type: "empty",
};
}
return defaultResolveResult;
};
withStorybook should respect any existing resolveRequest function.
I could add this automatically but it requires resetting cache when switching between including/not including storybook, so I'm not sure.
@kzlar If you want to remove storybook from the bundle the easiest way is to adjust metros resolveRequest to ignore storybook files.
defaultConfig.resolver.resolveRequest = (context, moduleName, platform) => { const defaultResolveResult = context.resolveRequest( context, moduleName, platform ); if ( process.env.STORYBOOK_ENABLED !== "true" && defaultResolveResult?.filePath?.includes?.(".ondevice/") ) { return { type: "empty", }; } return defaultResolveResult; };withStorybook should respect any existing resolveRequest function.
I could add this automatically but it requires resetting cache when switching between including/not including storybook, so I'm not sure.
@dannyhw ty for your reply, and please let me know if you want further discussion on discord or anywhere else so to not spam this pr :)
Wouldn't that method above still include storybook in the production app? The App.storybook.tsx file has this import for me:
import { view } from './.storybook/storybook.requires'
const StorybookApp = view.getStorybookUI({
storage: {
getItem: AsyncStorage.getItem,
setItem: AsyncStorage.setItem,
},
})
If I merge it into App.tsx and add the resolveRequest as you mentioned, it'd still bundle in everything imported from storybook.requires.ts which has a bunch of stuff that aren't useful in production. Right?
Another minor issue with the above is that my stories are shared between web and native in a package that is separate from my expo app (still using a relatively old tamagui monorepo setup with apps/next, apps/expo for the apps and packages/app for the components).
@kzlar it wouldn't bundle it in because its resolving an empty module, you'd basically have a fake empty module in its place. You can also add other filepaths here if you want and exclude everything that you think shouldn't get included.
see
if (
process.env.STORYBOOK_ENABLED !== "true" &&
defaultResolveResult?.filePath?.includes?.(".storybook/")
) {
return {
type: "empty",
};
}
Feel free to dm me on discord
added an alpha version of the expo template
to try run npx create-expo-app --template expo-template-storybook@next alphastorybook8
Hi! I'm getting
The package at "../../node_modules/jose/dist/node/esm/runtime/decrypt.js" attempted to import the Node standard library module "node:crypto".
It failed because the native React runtime does not include the Node standard library.
on 8.2.0-alpha.1
It randomly alternates between node:crypto and node:buffer not found in jose. I tried digging but have no idea which package pulls it and why.
When storybook is disabled the app builds just fine. And storybook works fine in v7.
Any pointers?
Thanks!