Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yarn workspaces #41

Open
igl opened this issue Apr 25, 2018 · 7 comments
Open

Yarn workspaces #41

igl opened this issue Apr 25, 2018 · 7 comments

Comments

@igl
Copy link

igl commented Apr 25, 2018

The module resolver looking for your local eslint installation seems not to be compatible with yarn workspaces.

It apparently only looks into the ./node_modules folder in the rootDir and not the repo-root node_modules.

The Error:

 FAIL   eslint  packages/api/src/index.js
  ● Test suite failed to run

    Cannot find module '/Users/igl/wubba-lubba-dub-dub/packages/api/node_modules/eslint'

      at getLocalESLint (../../node_modules/jest-runner-eslint/build/utils/getLocalESLint.js:9:10)
@ljharb
Copy link
Collaborator

ljharb commented Apr 25, 2018

With yarn workspaces, wouldn't you still want each individual project to have the proper dev deps listed?

@igl
Copy link
Author

igl commented Apr 25, 2018

You have no choice. Yarn will install everything in the repo root and create symlinks in your packages/app/node_modules/.bin/ folder pointing to it. Given that other packages have the same or a compatible semver in their devDeps.

@ljharb
Copy link
Collaborator

ljharb commented Apr 25, 2018

Right - so why wouldn’t the runner be able to find the symlink?

@igl
Copy link
Author

igl commented Apr 25, 2018

Actually found the problem already very quickly looking at the code. Find-up is not the right way.
Right now it is basically doing "../“ until it finds a node_modules folder and then stops trying.

A proper require.resolve like lookup would be better. Maybe resolve-from instead of find-up would do the trick.

@ljharb
Copy link
Collaborator

ljharb commented Apr 25, 2018

The resolve module can do it by setting a basedir; that would be far better than using resolve-from.

@igl
Copy link
Author

igl commented Apr 25, 2018

Using jest rootDir which commonly is the package root not the repo root... I think packages shouldnt explicitly know they live in a mono-repo.

Worse: if other packages have different semver of eslint and it WILL install in your package node_modules and setting the baseDir to repo-root will pick up the wrong version for you. Resolve-from picks up the closest installation starting from rootDir is the correct behaviour imo.

@ljharb
Copy link
Collaborator

ljharb commented Apr 25, 2018

I agree - I'm only saying that we won't be using the resolve-from module to do it :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants