-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Building with yarn pnp (yarn 2+) ignores the 'browser' element of the package.json #6693
Comments
Is this the same as #1979? |
Sure is. I can have a look at the use of https://www.npmjs.com/package/@yarnpkg/esbuild-plugin-pnp to resolve this and look at the other problem they hit if that would be helpful. OTOH my fix proposal might be fairly robust for now given that it's pretty straightforward. Like @swandir I'm also curious about the point of the "*" thing. |
I've tried fixing this with But it turns out the root of the problem is different: I've addressed it along with the other problem from my comment in this PR: #6493 Though we still are to see what maintainers will say about these changes 🙂 |
Looks like solid work. I hope they will take this fix this quickly as having yarn 2+ broken with AWS for example will slow adoption. Closing this one since it's a dup. |
As a temporary workaround you may apply commits from the PR on top of a Vite version you need, pack a tarball and use it via |
I have done that and confirm that your PR fixes my issue, AWS works correctly with yarn pnp in the browser. Thanks for the work on this and I hope they merge it soon! |
Describe the bug
The title pretty much says it. Unfortunately I don't have the time to provide a reproduction. I can however provide a fix (see below) that I have tested in my environment.
The problem is with yarn pnp the importer ends up having a /* appended to it in some cases (I don't fully understand why). This causes the check of the idToPkgMap in the resolver to fail since it misses, so the browser-specific resolution from the package.json is never found. Solution is to add an entry with the /* to the map in the yarn pnp case.
This shows up clearly when using the aws-sdk for example in a browser app (it will fail at runtime trying to reference a nodejs module).
Reproduction
none
System Info
Used Package Manager
yarn
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: