Monorepo module-resolver

I have a monorepo with a source folder outside of the project directory.

project1/
         App.tsx
         ...

project2/
         App.tsx
         ...

source/
       ...

I’ve found that Expo/RN has no problem resolving the imports in source when using an emulator with this babel config:

var path = require("path");

module.exports = function(api) {
    api.cache(true);
    return {
        presets: [
            "babel-preset-expo",
            "module:metro-react-native-babel-preset",
        ],
        plugins: [
            "react-native-reanimated/plugin",
            [
                "module-resolver",
                {
                    extensions : [".js", ".ios.js", ".android.js", ".json"],
                    alias      : {
                        "@source" : "../source",
                    },
                },
            ],
        ],
    };
};

but Expo Web doesn’t seem to resolve @source into ../source for files inside of the source folder:

Failed to compile.
/Users/.../project1/RootApp.js
Module not found: Can't resolve '@source/Button' in '/Users/.../source/RootReactNativeApp'

Similarly, it also seems like the files inside of the source folder can’t access the node_modules in project1:

Failed to compile.
/Users/.../project1/RootApp.js
Module not found: Can't resolve 'react' in '/Users/.../source/RootReactNativeApp'

Both of these cases work when running this same project with Android / iOS emulators.

Any suggestions?
Thanks

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.