nandorojo / solito

πŸ§β€β™‚οΈ React Native + Next.js, unified.
https://solito.dev
MIT License
3.54k stars 181 forks source link

createParam seems to be bundling Next.js in native app #325

Closed LunatiqueCoder closed 1 year ago

LunatiqueCoder commented 1 year ago

Hello!

Thank you for the work you put in around the React Native community! Really an inspiration.

I'm maintaining this template: https://github.com/criszz77/luna

What I'm trying to achieve is a React Native + Next.js in one app, no monorepo. In my opinion the monorepo adds a lot of complexity and a number of fairly new React Native developers stumble across this while working with Solito for their first time.

I'm playing around with processModuleFilter from Metro bundler which helps us discard specific modules from the output. Of course, I'm trying to discard Next.js from native and here are the results:

  1. Either clone 🌘 Luna or install a new app with

    npx react-native init MyAppName --template @criszz77/luna
  2. Copy this serializer option in your metro.config.js:

    module.exports = {
    transformer: {
    ...
    },
    serializer: {
    processModuleFilter: module => {
      console.log('module', module);
      return !module.path.includes('/node_modules/next/');
    },
    },
    };
  3. Run yarn start && yarn ios

  4. In the console.logs, not only you will see that Next.js seems to be bundled in the Native app, but also the app will crash.

image

EDIT:

Or if you try to use Solito in a bare react native app:

image
nandorojo commented 1 year ago

Should be fixed in 2.2.0: https://github.com/nandorojo/solito/releases/tag/v2.2.0