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 2] Browser polyfills from package.json not used #1778

Closed
3 tasks done
mariusheine opened this issue Jan 28, 2021 · 3 comments
Closed
3 tasks done

[yarn 2] Browser polyfills from package.json not used #1778

mariusheine opened this issue Jan 28, 2021 · 3 comments

Comments

@mariusheine
Copy link

mariusheine commented Jan 28, 2021

⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.

  • Read the docs.
  • Use Vite >=2.0. (1.x is no longer supported)
  • If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.

Describe the bug

A clear and concise description of what the bug is.

When serving or building an app the browser flag in the package.json of indirect dependencies seems not to be used, so that provided polyfills are not used.

E.g. the internal globalThis polyfill of the package engine.io-client, where globalThis.js shall be replaced by globalThis.browser.js:

globalThis.js:1 Uncaught ReferenceError: global is not defined
    at globalThis.js:1
    at wrapper.js?v=79ef5480:11
    at polling-xhr.js:7
    at wrapper.js?v=79ef5480:11
    at index.js:2
    at wrapper.js?v=79ef5480:11
    at socket.js:1
    at wrapper.js?v=79ef5480:11
    at index.js:1
    at wrapper.js?v=79ef5480:11

I am quite unsure if this is really in the scope of vite or if it is maybe inside esbuild...

Reproduction

Thise repo can be used the reproduce the behavior. In the README there is some more information.

System Info

  • vite version: 2.0.0-beta.52
  • Operating System: Linux bda0852ab5e1 4.19.104-microsoft-standard (Docker in WSL.2 under Windows 10)
  • Node version: v14.15.4
  • Package manager yarn and version: 2.4.0
@yyx990803
Copy link
Member

yyx990803 commented Jan 28, 2021

Yet another Yarn 2 only bug :/
It works fine with all other package managers.

@yyx990803 yyx990803 changed the title Browser polyfills from package.json not used [yarn 2] Browser polyfills from package.json not used Jan 28, 2021
@mariusheine
Copy link
Author

Yes I know... Sorry for that. But I thought this might not be that tightly coupled to yarn 2 as it was inside the compiled code.

Anyway big thanks to that fast answer and fix!

Keep on with this great work!

@merceyz
Copy link
Contributor

merceyz commented Jan 28, 2021

Yet another Yarn 2 only bug :/

Just to reiterate, again, Yarn 2 !== Yarn PnP. Both Yarn 1 and Yarn 2 support both PnP and node_modules

@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

3 participants