teambit / envs

Component development environments for the Bit community
https://bit.dev/bit/envs
Other
63 stars 9 forks source link

Expo: Package conflict after adding react-native compiler to the project #140

Closed samuelpismel closed 4 years ago

samuelpismel commented 4 years ago

Describe the bug

With a brand new expo project, if I import the react-native compiler with bit import bit.envs/compilers/react-native -c I got this error when I run the project:

While trying to resolve module `react-native` from file `/home/samuel/dev/project2/App.js`, the package `/home/samuel/dev/project2/.git/bit/components/compilers/react-native/bit.envs/1.0.16/react-native/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/home/samuel/dev/project2/.git/bit/components/compilers/react-native/bit.envs/1.0.16/react-native/dist/index.js`. Indeed, none of these files exist:

  * /home/samuel/dev/project2/.git/bit/components/compilers/react-native/bit.envs/1.0.16/react-native/dist/index.js(.native|.android.expo.ts|.native.expo.ts|.expo.ts|.android.expo.tsx|.native.expo.tsx|.expo.tsx|.android.expo.js|.native.expo.js|.expo.js|.android.expo.jsx|.native.expo.jsx|.expo.jsx|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.wasm|.native.wasm|.wasm)
  * /home/samuel/dev/project2/.git/bit/components/compilers/react-native/bit.envs/1.0.16/react-native/dist/index.js/index(.native|.android.expo.ts|.native.expo.ts|.expo.ts|.android.expo.tsx|.native.expo.tsx|.expo.tsx|.android.expo.js|.native.expo.js|.expo.js|.android.expo.jsx|.native.expo.jsx|.expo.jsx|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.wasm|.native.wasm|.wasm)
Failed building JavaScript bundle.

Steps to Reproduce

  1. Create a new expo project: expo init -t blank expo-project cd expo-project

  2. Initialize bit: bit init --package-manager yarn

  3. Import the react-native compiler: bit import bit.envs/compilers/react-native -c

  4. Run expo server: expo start

  5. Connect to the server: Copy the url expo gives you. Open it in expo client app in your emulator (android in my case)

Expected Behavior

Be able to use the bit tool in the project.

Screenshots, exceptions and logs

Screenshot from 2020-05-28 13-34-52 Screenshot from 2020-05-28 13-35-02

Specifications

Additional context

We should have a section for react-native and expo in the documentation. They are super popular.

samuelpismel commented 4 years ago

The same happens if I add the react compiler via bit import bit.envs/compilers/react -c

JoshK2 commented 4 years ago

Hi, I solved the issue by expending the metro config file. https://github.com/teambit/envs/tree/master/packages/react-native#metro-has-encountered-an-error-while-trying-to-resolve-module-react-native