react-native-web: Module parse failed: Unexpected token

I apologise for asking what seems to be a FAQ, but I couldn’t find a working answer to this.

We have a mono-repo project containing TypeScript code organised into three packages (a main app with sub-packages for UI and storage). The app bundles and runs as expected on Android and iOS, however launching the react-native-web version fails with an error like:

Module parse failed: Unexpected token (14:7) `You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.

The error appears to be caused by the bundler trying to process a TS/TSX file as JS. I think that we need to tell it to transpile the TS files in the sub-packages. What is the proper Expo way to configure this?


To answer my own question, the problem was caused by using expo-yarn-workspaces, and not having the proper metro.config.js and webpack.config.js files. Once I followed the instructions on expo-yarn-workspaces - npm, everything started working correctly.