electrode-io / electrode-native

A platform to ease integration&delivery of React Native apps in existing mobile applications
https://native.electrode.io
Other
726 stars 113 forks source link

Bundler error in Typescript miniapps #1254

Open romanlv opened 5 years ago

romanlv commented 5 years ago

When attempting to ern run-ios miniapps created with Typescript support I'm getting

✖ Generating Container locally 11s
  ✖ Generating Container 11s
    ✔ Preparing Native Dependencies Injection 0s
    ✔ Preparing API Implementations Injection 0s
    ✔ Injecting Native Dependencies 3s
    ✔ Adding Native Dependencies Hooks 0s
    ✖ Bundling MiniApps 4s
      ✖ Running Metro Bundler 4s
  ✖ runLocalContainerGen failed: Error: Command failed: /Users/vn0epsg/.ern/versions/0.34.0/node_modules/ern-core/nod
e_modules/.bin/react-native bundle --entry-file=index.js --dev=false --platform=ios --bundle-output=/Users/vn0epsg/.e
rn/containergen/out/ios/ElectrodeContainer/Libraries/MiniApp/MiniApp.jsbundle --assets-dest=/Users/vn0epsg/.ern/conta
inergen/out/ios/ElectrodeContainer/Libraries/MiniApp 
  ✖ error Unable to resolve module `react-native/Libraries/NewAppScreen` from `/private/var/folders/w1/fr2ppby15bjb5t
6mb0hrx059h5v0_t/T/tmp-64231I2QN7RvX41xe/node_modules/ts-miniapp/App.tsx`: Module `react-native/Libraries/NewAppScree
n` does not exist in the Haste module map

It seems to be related to this react-native-template-typescript issue

ℹ ern-local-cli : 0.34.0 ℹ electrode-native : 1.0.17

Js based apps start fine

belemaire commented 5 years ago

Hi @romanlv Thanks for reporting this one and doing some initial research. As described in the issue you linked, the TypeScript template that we are using internally when generating a TypeScript MiniApp (the exact one you linked) is always targeting latest version of React Native. That is going to cause problems as Electrode Native users are using different versions of React Native and not always latest. We'll look into that ASAP and probably release a patch version of Electrode Native to include a fix. Given that react-native CLI does not currently support templates for different versions of RN, we'll have to come up with our own solution. Meanwhile, if your'e blocked, have your tried the workaround suggested in this comment ? https://github.com/react-native-community/react-native-template-typescript/issues/42#issuecomment-510827188

romanlv commented 5 years ago

Thanks, @belemaire, also, it looks like adding typescript support to existing JS miniapp works without negative side effects. So this issue maybe not so urgent then

romanlv commented 5 years ago

yes, and I tried to remove globally installed react-native, replace with ERN version 0.59.8 and it didn't work

belemaire commented 5 years ago

On one hand it's not urgent because there is a way to work-around the issue, but on the other hand it's urgent because our MiniApp TypeScript generator won't work for any users at this point (because the template we use is targeting 0.60 of RN and no other versions and we don't yet support this version of RN). We'll do the necessary to fix this and do a patch release sometime this week.

friederbluemle commented 4 years ago

@romanlv - It's been a while, but if you have a few minutes, could you check if the latest version of ERN solves this issue? Thank you!