![]() ![]() (uses monorepo tooling like Yarn, React is installed in two different node_modules folders. apps/marketing - A simple Next.js website to attract new users.For example, let's say you have the following monorepo: This option is important for certain edge cases, such as a monorepo that includes multiple versions of the react package. Force Metro to resolve (sub)dependencies only from the `nodeModulesPaths`Ĭonfig. resolve (workspaceRoot, 'node_modules' ), ] // 3. resolve (projectRoot, 'node_modules' ) , Let Metro know where to resolve packages and in what order extraNodeModules = monorepoPackages // 2. If your monorepo tooling creates workspace symlinks in the `node_modules` folder, // you can either add symlink support to Metro or set the `extraNodeModules` to avoid the symlinks. watchFolders = // Add the monorepo workspaces as `extraNodeModules` to Metro. Watch the local app folder, and only the shared packages (limiting the scope and speeding it up) // Note how we change this from `workspaceRoot` to `projectRoot`. ![]() Typically, these are the ones that are installed with an asterisk (*) in your package.json. You can speed things up by only watching the packages your app uses. Setting this path to the root of your monorepo will force Metro to watch all files within the repository and possibly cause a slow initial startup time.Īs your monorepo increases in size, watching all files within the monorepo becomes slower. If a file is outside of that scope, Metro won't be able to find it. Each of these directories must be within the scope of the watchFolders. When using monorepos, your app dependencies splits up into different directories. This default setting works great for apps that don't use a monorepo structure. ![]() Metro does that with the watchFolders option, which is set to the project directory by default. During the first phase, Resolution, Metro resolves your app's required files and dependencies. Metro has three separate stages in its bundling process, documented here. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |