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

Unable to use xstate in the browser #227

Closed
TimvdLippe opened this issue Nov 10, 2018 · 3 comments
Closed

Unable to use xstate in the browser #227

TimvdLippe opened this issue Nov 10, 2018 · 3 comments

Comments

@TimvdLippe
Copy link

Bug or feature request?

Bug

Description:

In StateNode.ts, there is a reference to process. Since a web browser does not have this variable, you can not load xstate using ES modules in a browser.

(Bug) Expected result:

I can load xstate using ES modules in a browser

(Bug) Actual result:

process is not defined

(Bug) Potential fix:

This is a similar issue to reduxjs/redux#2907 which I fixed in reduxjs/redux#3143 that correctly generates an ES bundle.
I went ahead and did this locally, but I saw your es/ folder output actually contains all tsc build targets. The fix would therefore be impossible if someone would directly use es/StateNode.ts.
I would propose to generate a new bundle called es/index.mjs just like Redux, but with the reference to process removed.

@davidkpiano
Copy link
Member

Fix made in master - can you please test it out and see if it works for your use-cases?

@TimvdLippe
Copy link
Author

@davidkpiano Finally had time to verify and yes it has been fixed 🎉

@davidkpiano
Copy link
Member

Awesome; this is in the latest release as well.

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

No branches or pull requests

2 participants