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

feat: support yarn pnp #28

Merged
merged 15 commits into from
Jul 14, 2022
Merged

feat: support yarn pnp #28

merged 15 commits into from
Jul 14, 2022

Conversation

JounQin
Copy link
Contributor

@JounQin JounQin commented Jul 5, 2022

close #26
close import-js/eslint-import-resolver-typescript#130

continue #27

I'll try to add a test case later, and it has been confirmed to be working as expected at https://github.com/import-js/eslint-import-resolver-typescript/pull/133 by `yarn patch`.

@JounQin
Copy link
Contributor Author

JounQin commented Jul 5, 2022

@privatenumber I don't know whether my latest commit 1febc92 (#28) a correct/good test case, it runs tests with PnP and tests without PnP, please help to review, or I can revert that commit and leave the test case for you?

@JounQin
Copy link
Contributor Author

JounQin commented Jul 8, 2022

Friendly ping @privatenumber

package.json Outdated Show resolved Hide resolved
@privatenumber
Copy link
Owner

Let's revert any unnecessary changes that has nothing to do with yarn/pnp.

@JounQin
Copy link
Contributor Author

JounQin commented Jul 13, 2022

Let's revert any unnecessary changes that has nothing to do with yarn/pnp.

They're all required changes.

@privatenumber
Copy link
Owner

Why is this required?
Screen Shot 2022-07-13 at 9 41 42 AM

@JounQin
Copy link
Contributor Author

JounQin commented Jul 13, 2022

Why is this required?
Screen Shot 2022-07-13 at 9 41 42 AM

It's fixed by ESLint.

eslint-plugin-import seems not working well with yarn PnP.

See also import-js/eslint-plugin-import#2487 (comment)

@privatenumber
Copy link
Owner

We can't move forward with this if it's unpredictably changing the way ESLint behaves.

@JounQin
Copy link
Contributor Author

JounQin commented Jul 13, 2022

We can't move forward with this if it's unpredictably changing the way ESLint behaves.

So we test with yarn PnP, lint with npm, is this acceptable?

@privatenumber
Copy link
Owner

Ideally, using yarn should be isolated to running yarn/pnp tests. Best case, yarn's resolver is imported rather than injected by running via yarn.

@JounQin
Copy link
Contributor Author

JounQin commented Jul 13, 2022

Ideally, using yarn should be isolated to running yarn/pnp tests. Best case, yarn's resolver is imported rather than injected by running via yarn.

I don't know how to implement it easily. 😅

Maybe you can try this way after merging?

I'll change to use npm run lint on CI.

@privatenumber
Copy link
Owner

privatenumber commented Jul 13, 2022

There should also be a test-case that fails without these changes.

@JounQin
Copy link
Contributor Author

JounQin commented Jul 13, 2022

There should also be a test-case that fails without these changes.

Not sure to understand, can you explain in details?

We have Test without PnP and Test with yarn PnP both.


All test cases are passing now, how do you think?

@privatenumber
Copy link
Owner

For all the tests that are running with pnp, a fixture with node_modules/dep/package.json is created, so it doesn't seem like it's testing pnp behavior.

To test the new feature, there should be a test case that fails prior to these changes, which passes after these changes.

@JounQin
Copy link
Contributor Author

JounQin commented Jul 13, 2022

To test the new feature, there should be a test case that fails prior to these changes, which passes after these changes.

I don't know how to test to revert these changes first? I believe you can add this test case later?

pnpm has PnP mode the same time, it also resolves node_modules deps and PnP both, (we're using this on CI, because tsx doesn't support yarn PnP natively for now).

@privatenumber
Copy link
Owner

I added a failing test here: #32

Can you pull it in?

@JounQin
Copy link
Contributor Author

JounQin commented Jul 14, 2022

I added a failing test here: #32

Can you pull it in?

Let me check.

@privatenumber privatenumber changed the base branch from develop to yarn-pnp-test July 14, 2022 01:13
@privatenumber
Copy link
Owner

Thanks for the PR @JounQin. It's looking really good.

I was glad to see the feature implementation is working with pnp without a node_modules directory.

I haven't actually started reviewing the implementation yet but will take a look tomorrow.

@privatenumber privatenumber changed the title fix: support yarn pnp out of box feat: support yarn pnp Jul 14, 2022
@privatenumber privatenumber merged commit 9cc2844 into privatenumber:yarn-pnp-test Jul 14, 2022
@JounQin JounQin deleted the fix/yarn_pnp branch July 14, 2022 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants