8/2/2023 0 Comments Lerna vs yarn workspaces![]() ![]() As a result, monorepo tooling, like Yarn, will install these dependencies to the root node_modules directory, for example: node_modules - The root folder, contains apps/mobile/node_modules - The app's folder, contains modules and React Native libraries usually don't add react as a peer dependency.(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 (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. Boom.Metro has three separate stages in its bundling process, documented here. Use nvm or n and switch versions instantly with one command. Yep, re-installing Yarn in its entirety every single time you flip between projects. Run npm install -global and npm install -global as you switch between projects. You need to stop using brew ( brew uninstall yarn) and revert back to an npm install. You can specify which Yarn version(s) are compatible with your project using engines in package.json.īut what if you need to shift between projects regularly, each requiring different Yarn versions? But the lock file format is slightly different between Yarn v1.1 and Yarn v1.2. As they install and remove dependencies on a project, Yarn writes to a yarn.lock file. You can easily switch npm versions.īob has Yarn v1.1 installed, and Brenda has Yarn v1.2. I ran this three times, and speeds were pretty much the same. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |