π 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 on a (if things are well configured). But probably it will hoist dependencies of a in the top-level node_modules instead of a local one (ie. instead of a node_modules inside the a folder).
- So
patch-package will be executed and tries to patch things in a/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 a package.json that contains a workspaces field and/or a lerna.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 root node_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. no node_modules in packages/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 |
π bug report
On a lerna-based monorepo, there are some issues with patch-package.
Suppose I have this folder structure...
... and suppose I put patch-package dependency in the package
atogether with apostinstallscript.π€ Current Behavior
The package
ashould work in isolation from the top-level folder and other packages.npm ion the top-level folder, it will install dependencies and so do a npm i ona(if things are well configured). But probably it willhoistdependencies ofain the top-levelnode_modulesinstead of a local one (ie. instead of anode_modulesinside theafolder).patch-packagewill be executed and tries to patch things ina/node_modulesbut 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:find-upfor apackage.jsonthat contains aworkspacesfield and/or alerna.jsonfile.node_modulesfolder (ie. for instance it doesn't exist) tries to patch the rootnode_modules(when flag is enabled)π¦ Context
node_modulesie. nonode_modulesinpackages/aand I would like patch-package to work out-of-the-box for this kind of situation (with a flag if it's ok).patch-packageπ Your Environment