The problem
I was trying to build my Expo app which uses this package, and I was running into problems that weren't immediately obvious. After some sleuthing I eventually found this line in the Xcode error log.
Error loading assets JSON from Metro. Ensure you've followed all
expo-updates installation steps correctly.
Unable to resolve module rescript-react-native/src/apis/Style.bs.js from
/Users/expo/workingdir/build/components/rescript /<mycomponent>.bs.js:
rescript-react-native/src/apis/Style.bs.js could not be found within the project or in these directories:
node_modules
What I eventually realized is that this package ships only with the *.res files, and you're expected to build the *.bs.js files yourself. Conversely, EAS installs your node_modules fresh after upload during the build process, so none of those files get compiled on the EAS server.
Considered solution
I was able to fix it by adding the following to my package.json:
{
// ...
"scripts": {
// ...
"eas-build-post-install": "yarn rescript clean && yarn rescript build"
}
// ...
}
This tells the EAS build system to build the rescript files after it runs yarn install (and pod install for iOS specifically).
I think the most straight forward solution is to just add this to the docs and on the website. Just save some people the headache of running into this problem and not being sure how to solve it.
Alternatives solutions
I guess the package could bundle *.bs.js files, but I don't know if that's even the right solution. I think a line in the docs is probably sufficient.
The problem
I was trying to build my Expo app which uses this package, and I was running into problems that weren't immediately obvious. After some sleuthing I eventually found this line in the Xcode error log.
What I eventually realized is that this package ships only with the
*.resfiles, and you're expected to build the*.bs.jsfiles yourself. Conversely, EAS installs yournode_modulesfresh after upload during the build process, so none of those files get compiled on the EAS server.Considered solution
I was able to fix it by adding the following to my
package.json:This tells the EAS build system to build the rescript files after it runs
yarn install(andpod installfor iOS specifically).I think the most straight forward solution is to just add this to the docs and on the website. Just save some people the headache of running into this problem and not being sure how to solve it.
Alternatives solutions
I guess the package could bundle
*.bs.jsfiles, but I don't know if that's even the right solution. I think a line in the docs is probably sufficient.