Skip to content

Module federation Metro for Windows #4440

@DiegoSerra

Description

@DiegoSerra

Describe the bug

I have a monorepo (https://github.com/DiegoSerra/universal-turbo-monorepo/tree/feature/mf-for-windows) with turbo with microfrontends and module federation in which I have 3 “projects”:

Web part with a shell and a remote (Vite + React)
Mobile part with another shell and another remote (Rockjs + React Native)
Storybook

On the other hand, I have a series of UI packages (a library of components shared between platforms and tailwind-config).

As a side note, this error is relatively common in Windows, since Re.pack had a similar problem in the past and @module-federation/metro still has a problem related to how it resolves Windows paths.

Image

I noticed that in Windows, when running babel-transformer, the generated path looks like this:

const babelTransformer = require('C:\Users\xxxxx\universal-turbo-monorepo\node_modules\@react-native\metro-babel-transformer\src\index.js');
const babelPlugins = [["@module-federation/metro/babel-plugin",{"blacklistedPaths":["C:\\Users\\xxxxx\\universal-turbo-monorepo\\

So, by trying to create a patch so that those paths are generated with POSIX style by doing a replace(//g, ‘/’), it allows me to move forward from error to error.

What would be the best way to get it to work on both operating systems?

Thank you.

Reproduction

https://github.com/DiegoSerra/universal-turbo-monorepo/tree/feature/mf-for-windows

Used Package Manager

pnpm

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
    Memory: 2.24 GB / 15.94 GB
  Binaries:
    Node: 22.21.1 - C:\Program Files\nodejs\node.EXE     
    npm: 10.9.4 - C:\Program Files\nodejs\npm.CMD        
    pnpm: 10.28.2 - C:\Program Files\nodejs\pnpm.CMD     
  Browsers:
    Chrome: 144.0.7559.132
    Edge: Chromium (140.0.3485.54)
    Internet Explorer: 11.0.19041.5794

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions