If you run
npx degit vercel/turbo/examples/with-react-native-web with-react-native-web
cd with-react-native-web
yarn install
To create a basic Turborepo that has a Nextjs application, a react-native mobile app with Expo and a ui package to share components between apps (there is a Button as an example already shared between the two apps), it works. But my ui package needs other dependencies, for example:
@fortawesome/fontawesome-svg-core,
@fortawesome/free-solid-svg-icons,
@fortawesome/react-native-fontawesome,
This is because the buttons that I want to render icons on my buttons. Once I install this dependency and try to use the button that has an icon, the Next.js app throws:
Unexpected token 'export'.
I understand this is because @fortawesome/react-native-fontawesome
is using import/export
syntax and needs to be transpiled to be used on the Next.js app, and I cannot make it work. I am trying to do this by adding this to my next.config.js
:
transpilePackages: ['ui'],
I also tried using next-transpile-modules
which i don't think is the right solution since next now supports what that package used to be for through transpilePackages
I also tried to specify that the ui
package was "type": "module"
but still, I am getting the same error.
How can you specify that those dependencies that belong to the ui package must be transpiled to be run by the browser?