Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SaiChand-Headout opened this issue Sep 10, 2024 · 19 comments

Comments

@SaiChand-Headout
Copy link

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
Copy link
Author

@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. #598 for reference

@dannyhw
Copy link
Member

dannyhw commented Sep 10, 2024

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

@SaiChand-Headout
Copy link
Author

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
Copy link
Member

dannyhw commented Sep 11, 2024

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
Copy link
Author

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

@dannyhw
Copy link
Member

dannyhw commented Sep 11, 2024

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

@SaiChand-Headout
Copy link
Author

Screenshot 2024-09-11 at 6 21 42 PM

Yes, they are all same

@SaiChand-Headout
Copy link
Author

Sorry to bother you, any updates here ?

@dannyhw
Copy link
Member

dannyhw commented Sep 12, 2024

do you have a reproduction I can look at?

@SaiChand-Headout
Copy link
Author

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
Copy link
Member

dannyhw commented Sep 13, 2024

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

@dannyhw
Copy link
Member

dannyhw commented Sep 13, 2024

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
Copy link
Author

Sure @dannyhw , any luck with this ??

@dannyhw
Copy link
Member

dannyhw commented Sep 16, 2024

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
Copy link
Member

dannyhw commented Sep 16, 2024

@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
Copy link

ktml commented Sep 16, 2024

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
Copy link
Author

thanks a lot @dannyhw , this worked

@hanwenbo
Copy link

hanwenbo commented Oct 9, 2024

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
Copy link
Member

dannyhw commented Oct 9, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants