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

Global not defined in ESM bundles. #284

Closed
dsm23 opened this issue Feb 2, 2021 · 10 comments · Fixed by #287
Closed

Global not defined in ESM bundles. #284

dsm23 opened this issue Feb 2, 2021 · 10 comments · Fixed by #287
Labels
bug Something isn't working released on @beta released in beta for review released

Comments

@dsm23
Copy link

dsm23 commented Feb 2, 2021

  • three version: 0.125.2
  • react-three-fiber version: 5.3.18
  • @react-three/drei version: 3.2.2
  • node version: 15.5.1
  • npm (or yarn) version: 2.4.0

Problem description:

It appears that importing from the @react-three/drei library in one of the 2 snowpack react templates throws the ReferenceError: global is not defined. Issues appears to be specific to this library

@dsm23 dsm23 added the bug Something isn't working label Feb 2, 2021
@joshuaellis
Copy link
Member

Hi @dsm23,

Have you seen this issue? #273

it contains a work around, however if you want to provide a fix that we can permanently implement that would be great! We currently use global as a fix for SSR.

I’m not clued up enough on Snowpack to suggest a solution for the long term yet.

@joshuaellis joshuaellis changed the title Issue when used in Snowpack templates Global not defined in ESM bundles. Feb 2, 2021
@joshuaellis joshuaellis added the help wanted Extra attention is needed label Feb 2, 2021
@joshuaellis
Copy link
Member

This is the offending line:

global['Blob'] = Blob
. I’m wondering if we need it. Whether importing Blob would simply fix our old SSR issue and now new ESM issue...

I could remove this line and release a beta tomorrow to see...

@dsm23
Copy link
Author

dsm23 commented Feb 3, 2021

I had not seen the other issue, thank you for point it out to me. If you do need the offending statement would a globalThis not also work?

@joshuaellis joshuaellis added released on @beta released in beta for review and removed help wanted Extra attention is needed labels Feb 3, 2021
@joshuaellis
Copy link
Member

Hi @dsm23,

I've released a patch on 3.2.3-beta.1 if you could try it out in snowpack that'd be great. I can test later in the day with SSR.

@joshuaellis joshuaellis mentioned this issue Feb 3, 2021
1 task
@github-actions
Copy link

github-actions bot commented Feb 3, 2021

🎉 This issue has been resolved in version 3.3.0-beta.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

github-actions bot commented Feb 3, 2021

🎉 This issue has been resolved in version 3.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@dsm23
Copy link
Author

dsm23 commented Feb 4, 2021

works well, thank you

@joshuaellis
Copy link
Member

You're welcome @dsm23 👌🏼

@cedeber
Copy link

cedeber commented Feb 12, 2021

This is good news, thanks. I confirm that it works with snowpack without the Node polyfill. Now, I'll test it with Vite too :-D

@cedeber
Copy link

cedeber commented Feb 12, 2021

Also works with Vitejs 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released on @beta released in beta for review released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants