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

Support default element when running in browser #55

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

valtism
Copy link

@valtism valtism commented Dec 28, 2021

global is only defined in Node. globalThis will work for most users, but this workaround should work for all environments.

This probably worked because I am guessing that CRA's webpack config did some transformations, but when using vite no transformation is applied and it fails in the browser.

For the future it would be best to write browser code where possible rather than relying on tooling to transform to browser code when the tooling can change over time.

`global` is only defined in Node. `globalThis` will work for most users, but this workaround should work for all
@valtism valtism changed the title Support default element when running in browserglobal is only defined in Node. globalThis will work for most users, but this workaround should work for all Support default element when running in browser Dec 28, 2021
Copy link

@igbominadeveloper igbominadeveloper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. Had to write a workaround in my current project. 👍

Copy link

@lukaselmer lukaselmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would solve the issue with vite: donavon/use-persisted-state#62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants