Better support for monorepos
See original GitHub issueπ bug report
On a lerna-based monorepo, there are some issues with patch-package.
Suppose I have this folder structureβ¦
.
βββ ...
βββ packages
β βββ a
β βββ patches
β βββ package.json
βββ node_modules
βββ package.json
β¦ and suppose I put patch-package dependency in the package a
together with a postinstall
script.
π€ Current Behavior
The package a
should work in isolation from the top-level folder and other packages.
- When I do a
npm i
on the top-level folder, it will install dependencies and so do a npm i ona
(if things are well configured). But probably it willhoist
dependencies ofa
in the top-levelnode_modules
instead of a local one (ie. instead of anode_modules
inside thea
folder). - So
patch-package
will be executed and tries to patch things ina/node_modules
but since dependencies are hoisted in the top-level folder, it will fail (if no symlink are present).
π Possible Solution
Add a flag to enable patching of the top-level node_modules
. ie:
- itβs very easy to find the root folder, just do a
find-up
for apackage.json
that contains aworkspaces
field and/or alerna.json
file. - From there, if you canβt patch the local
node_modules
folder (ie. for instance it doesnβt exist) tries to patch the rootnode_modules
(when flag is enabled)
π¦ Context
- I have a monorepo and I really donβt want to put the patches in the root folder, but rather in the packages, so patch-package can work for packages individually.
- Also in my setup there are no local
node_modules
ie. nonode_modules
inpackages/a
and I would like patch-package to work out-of-the-box for this kind of situation (with a flag if itβs ok). - I donβt want to patch
patch-package
π Your Environment
Software | Version(s) |
---|---|
patch-package | 6.2.2 |
Issue Analytics
- State:
- Created 3 years ago
- Reactions:28
- Comments:9
Top Results From Across the Web
11 Great Tools for a Monorepo in 2021 | Bits and Pieces
Best tools to build a monorepo. Develop, build, and publish packages, and scale development. Discover Lerna, Nx, Rush, Bit, Yarn Workspaces, and more....
Read more >What is monorepo? (and should you use it?)
Monorepos can foster rapid development workflows. ... Storage: an open-source extension for Git that adds better support for large files.
Read more >Benefits and challenges of monorepo development practices
A closer look at the benefits of monorepos β and some of the misconceptions β may help you decide if a monorepo environment...
Read more >Better support for monorepos Β· Issue #289
The major issue: We need to run the specific installed linters/formatters inside those projects. For example, we have some flake8 pluginsΒ ...
Read more >Monorepo Explained
Everything you need to know about monorepos, and the tools to build them. ... Rush supports it, leveraging the system tar command to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1
Experiencing the exact same issue. this becomes even more needed since npm 7 workspaces is out
+1