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

[2.0 Beta] Yarn PnP unable to apply resolve patch since resolve is now bundled in dist files. #1353

Closed
AlexandreBonaventure opened this issue Jan 4, 2021 · 4 comments

Comments

@AlexandreBonaventure
Copy link
Contributor

Describe the bug

Yarn PnP is patching the resolve lib : https://www.npmjs.com/package/resolve
Now with vite@2.0.0-beta being bundled by rollup, Yarn is unable to apply the patch when vite tries to resolve linked dependencies for instance here:

const depRoot = path.dirname(resolveFrom(`${dep}/package.json`, config.root))

An easy fix would be to externalize it from the bundle in the rollup options. Otherwise, a resolve hook via config would be nice to be able ro modify internal module resolution in userland.

System Info

  • required vite version: 2.0.0-beta
  • required Operating System: Mac OS
  • required Node version: 14
@AlexandreBonaventure
Copy link
Contributor Author

NB: this is a regression

@yyx990803
Copy link
Member

Can you confirm this is the only issue with Yarn PnP?

@AlexandreBonaventure
Copy link
Contributor Author

AlexandreBonaventure commented Jan 5, 2021

Thanks ! @yyx990803, I've just tried the new release and I can see another problem with linked dependencies resolution.
Suppose we have a monorepo such as:

|_ Vite App  (require A)
|_ Dep A (require B)
|_ Dep B

We need to resolve link dep recursively by resolving the dep from the importer root as opposed to config.root.
I've made a quick change here to show what I mean:
AlexandreBonaventure@ca79884

@yyx990803
Copy link
Member

Can you open a PR for that?

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants