storybookjs / react-native

📓 Storybook for React Native!
https://storybook.js.org
MIT License
1.08k stars 156 forks source link

Unexpected token: operator (?) in file node_modules/@storybook/preview-api/dist/preview-web.js. error #592

Open SaiChand-Headout opened 2 months ago

SaiChand-Headout commented 2 months ago

Describe the bug error node_modules/@storybook/preview-api/dist/preview-web.js: Unexpected token: operator (?) in file node_modules/@storybook/preview-api/dist/preview-web.js at 3139:39. Getting this error when trying to build for iOS

To Reproduce Steps to reproduce the behavior: Run yarn ./node_modules/.bin/react-native bundle \ --dev false \ --platform ios \ --reset-cache \ --entry-file index.js \ --bundle-output ./TEST_BUNDLE \ --sourcemap-output ./TEST_BUNDLE.map in root folder with storybook version (7.6.20) and RN version (0.70.5)

Screenshots

Screenshot 2024-09-10 at 12 05 14 PM
SaiChand-Headout commented 2 months ago

@dannyhw i've seen a similar issue in storybook JS repo as well, but didn't see any resolution over there. Felt this is the right repo to track hence sharing here. https://github.com/storybookjs/react-native/issues/598 for reference

dannyhw commented 2 months ago

please can you share the version of react-native and storybook etc

SaiChand-Headout commented 2 months ago

I've shared it in the description, storybook version (7.6.20) and RN version (0.70.5) here are the versions i've used

dannyhw commented 2 months ago

Can you try updating react native or is that not an option?

But also can you verify that all storybook packages are on the same version?

SaiChand-Headout commented 2 months ago

Unfortunately no, we have an update scheduled by the end of year, we can do it only then

dannyhw commented 2 months ago

what about the versions of the different storybook packages are they all aligned?

SaiChand-Headout commented 2 months ago
Screenshot 2024-09-11 at 6 21 42 PM

Yes, they are all same

SaiChand-Headout commented 2 months ago

Sorry to bother you, any updates here ?

dannyhw commented 2 months ago

do you have a reproduction I can look at?

SaiChand-Headout commented 2 months ago

unfortunately, it's a private repo.. but you can try it out with https://github.com/esbenvb/storybook-rn-minify-issue this link, they were facing the same issue and the dependency versions are pretty much similar...

dannyhw commented 2 months ago

A reproduction is a minimal recreation of the problem in a public repo it doesn't require private code to be included.

dannyhw commented 2 months ago

I don't have a lot of time to look at it right now because of work and other commitments but i will try to check this weekend

SaiChand-Headout commented 2 months ago

Sure @dannyhw , any luck with this ??

dannyhw commented 2 months ago

so far I have just confirmed that by passing --minify false it does work, so the minify step is causing the issue. Still trying out different options to try and figure out what the issue is.

dannyhw commented 2 months ago

@SaiChand-Headout Ok I found the issue, there is a ??= that seems to cause the issue, if you add '@babel/plugin-transform-logical-assignment-operators' then it successfully minifies.

heres the changes needed: https://github.com/esbenvb/storybook-rn-minify-issue/pull/1/files

ktml commented 2 months ago

I had the same issue with react native 0.69.9, spent days trying to get storybook working on android.

@dannyhw's solution works perfectly. Thanks guys!

SaiChand-Headout commented 2 months ago

thanks a lot @dannyhw , this worked

hanwenbo commented 1 month ago

error: Error: Unable to resolve module url from /Users/xxxxxx/node_modules/axios/dist/node/axios.cjs: url could not be found within the project or in these directories: -> 8.3.5 , A lot of bugs don't need to be pushed back to 7.6.20 for a while

dannyhw commented 1 month ago

@hanwenbo if you have a specific error please create a new issue describing the problem