react-native icon indicating copy to clipboard operation
react-native copied to clipboard

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

Open SaiChand-Headout opened this issue 1 year ago • 19 comments

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 avatar Sep 10 '24 06:09 SaiChand-Headout

@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

SaiChand-Headout avatar Sep 10 '24 06:09 SaiChand-Headout

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

dannyhw avatar Sep 10 '24 13:09 dannyhw

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

SaiChand-Headout avatar Sep 11 '24 04:09 SaiChand-Headout

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?

dannyhw avatar Sep 11 '24 07:09 dannyhw

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

SaiChand-Headout avatar Sep 11 '24 10:09 SaiChand-Headout

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

dannyhw avatar Sep 11 '24 11:09 dannyhw

Screenshot 2024-09-11 at 6 21 42 PM

Yes, they are all same

SaiChand-Headout avatar Sep 11 '24 12:09 SaiChand-Headout

Sorry to bother you, any updates here ?

SaiChand-Headout avatar Sep 12 '24 17:09 SaiChand-Headout

do you have a reproduction I can look at?

dannyhw avatar Sep 12 '24 18:09 dannyhw

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...

SaiChand-Headout avatar Sep 13 '24 08:09 SaiChand-Headout

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

dannyhw avatar Sep 13 '24 09:09 dannyhw

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

dannyhw avatar Sep 13 '24 10:09 dannyhw

Sure @dannyhw , any luck with this ??

SaiChand-Headout avatar Sep 16 '24 05:09 SaiChand-Headout

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 avatar Sep 16 '24 14:09 dannyhw

@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

dannyhw avatar Sep 16 '24 15:09 dannyhw

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!

ktml avatar Sep 16 '24 22:09 ktml

thanks a lot @dannyhw , this worked

SaiChand-Headout avatar Sep 17 '24 06:09 SaiChand-Headout

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

hanwenbo avatar Oct 09 '24 04:10 hanwenbo

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

dannyhw avatar Oct 09 '24 07:10 dannyhw