You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a monorepo using yarn v1 with a package structure like the diagram below. The root index.js file imports a single export from packages/module-a/index.js. This import generates a import/no-extraneous-dependencies error with my current config.
From reading issues here #1174 and here #1650 I see there is a packageDiroption to handle monorepos but as far as I can tell it is not the right choice for my case where a package.json that defines a workspaces property uses one of the modules in workspaces itself.
When I do add a file:./packages/module-a dependency to my package.json, the eslint error is removed but my app behaves differently because yarn has now cached the current version of module-a in node_modules as of yarn install instead of having a simple symlink. This means my changes to packages/module-a/index.js changing the exported value are not reflected when I run the node index.js command from root. This is not the behavior I want, so adding a file:.. dependency to make this rule happy is not a good option.
Is it possible to get import/no-extraneous-dependencies working with this case? Since the module is coming from a folder in workspaces, the dependency is not truly extraneous ie it is defined in the package.json. It just isn't in dependencies et al. I see that later versions of yarn have a workspace: type dependency which might help out here, do I need to upgrade to a later version of yarn perhaps?
@kepeterson 👋 same folder structure and I had the same issue happening after upgrading to anything above 2.22.1, didn't have the error before. I'm sure I'm missing something but for now I'll stay on 2.22.1.
Another small note, in the rule I had to specify the packageDir to "./" otherwise it wouldn't work 🙂
Hello eslint-plugin-import team,
I'm working on a monorepo using yarn v1 with a package structure like the diagram below. The root
index.js
file imports a single export frompackages/module-a/index.js
. This import generates aimport/no-extraneous-dependencies
error with my current config.From reading issues here #1174 and here #1650 I see there is a
packageDir
option to handle monorepos but as far as I can tell it is not the right choice for my case where a package.json that defines aworkspaces
property uses one of the modules inworkspaces
itself.When I do add a
file:./packages/module-a
dependency to my package.json, the eslint error is removed but my app behaves differently because yarn has now cached the current version ofmodule-a
innode_modules
as ofyarn install
instead of having a simple symlink. This means my changes topackages/module-a/index.js
changing the exported value are not reflected when I run thenode index.js
command from root. This is not the behavior I want, so adding afile:..
dependency to make this rule happy is not a good option.Is it possible to get
import/no-extraneous-dependencies
working with this case? Since the module is coming from a folder inworkspaces
, the dependency is not truly extraneous ie it is defined in the package.json. It just isn't independencies
et al. I see that later versions of yarn have aworkspace:
type dependency which might help out here, do I need to upgrade to a later version of yarn perhaps?I have put together a minimal repro of the problem here in a standalone repo https://github.com/kepeterson/no-extraneous-with-workspaces
.eslintrc.js
The text was updated successfully, but these errors were encountered: