envs icon indicating copy to clipboard operation
envs copied to clipboard

Expo Web Support

Open alanrivetta opened this issue 4 years ago • 6 comments

Good day.

I would like to create a React project, precisely with Expo, which currently has Web support.

My question is: Is this work methodology compatible with Bit? Do I need a special compiler?

I am very grateful if you will guide me along the way.

Cheers

alanrivetta avatar May 03 '20 15:05 alanrivetta

@JoshK2 I believe you play a bit with expo, correct?

GiladShoham avatar May 03 '20 18:05 GiladShoham

@GiladShoham no, I did not try it. I'll check how the environments work with Expo and write here if it can be supported. But I think is just a template framework right? @alanrivetta And also I want to know what you want to try? For React Web development or IOS/Android?

JoshK2 avatar May 04 '20 08:05 JoshK2

So far I have generated Mobile Applications with Expo. On the other hand, Web Applications with React and Create React App.

In this case I am looking to unify the code with Expo Web, where the biggest problem is dependency compatibility (Most don't work in Web and Mobile). But it can be solved.

As an example I use React Router, which has its separate Web and Mobile versions, so I unify them this way:

In the src/components/Router folder I have two files:

  • Index.js In this file I export the Mobile version
  • Index.web.js In this file I export the Web version

So by requiring the dependency (import {Router} from 'components/Router'), Expo will automatically import the file with the suffix of the platform it belongs to. (In this case it will always import the file "index.js" unless the Web platform requires it, there it will be "index.web.js")

Once this is done, we are able to integrate Web and Mobile code so that they coexist and behave according to the Platform used. Then, when compiling (yarn run build: web or yarn run build: android) it will generate the compilation, eliminating the code not required (for the other platforms)

What is not clear to me is how to perform this unification with Bit and its Envs, since when exporting a component to Bit, it compiles it, and I am not clear how it will behave and if it will continue to work as I need.

At the moment I do not have a proof of concept since I am analyzing the situation and I would like to know the opinion of the creators of Envs.

Thank you very much for your attention.

alanrivetta avatar May 04 '20 13:05 alanrivetta

Did my explanation help to clarify the picture? They need something more?

alanrivetta avatar May 05 '20 14:05 alanrivetta

@alanrivetta thanks for your explanation. @GiladShoham what do you think about the suffix support in Bit? The component main file needs to be changed in the building process depend on which target platform it will build, I'm right?

@alanrivetta did you try to use the Platform module option? https://reactnative.dev/docs/platform-specific-code#platform-module https://docs.expo.io/versions/latest/react-native/platform-specific-code/#platform-module

I know it's not the way you want, but it can be a good temporary solution.

JoshK2 avatar May 06 '20 12:05 JoshK2

I understand it may be an interim solution.

In this way I understand that I would have to export my components in different builds, for each platform.

I am looking to be able to export only one component, and that it can continue having this characteristic of requiring modules depending on the platform on which it is running.

alanrivetta avatar May 06 '20 14:05 alanrivetta