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

Browser-ready version #69

Closed
EtienneLem opened this issue Feb 26, 2015 · 1 comment
Closed

Browser-ready version #69

EtienneLem opened this issue Feb 26, 2015 · 1 comment

Comments

@EtienneLem
Copy link

tl;dr
Woah, sorry this turned out to be a longer issue than I expected. I have a solution but it requires manual editing of a compiled file… 👎

Issue:
I’ve been struggling to have a browser drop-in version working (without Node). I updated webpack.config.js accordingly.

I set react in externals so the compiled version looks for React instead of including it when it is required. (React doesn’t handle being required more than once)

In my app:
Uncaught TypeError: Cannot read property 'getPooled' of null: lib/Surface.js#L49

React libs (i.e. invariant & ReactUpdates) are meant to be required when needed (like you guys do) and aren’t defined on the global scope (thus no externals), so when building I let them as-is to be included in dist/react-canvas.js, yet something seems wrong for ReactUpdates.ReactReconcileTransaction is always undefined.

I’m positive that both version of React (my app & the one used to include react/lib/* in the distribution) are the same (0.13.0-rc1).

Teh question:
You who’ve been digging a lot into the core of React, do you see something obvious (or less so) that I’m missing? Is a browser-ready version something you’ve considered?

Hackish solution
I finally have a version that works!

I’ve removed React from my app and bundled it inside dist/react-canvas.js (a little bit like react-with-addons.js). For it to work though, I have to manually (post-building) add window.React = React so that dist/react-canvas.js exposes both React and ReactCanvas

🤘

@EtienneLem
Copy link
Author

Update:
I managed to find a way to expose React with webpack 💃

In my app, instead of using react.js or react-with-addons.js, I can use react-with-canvas.js or react-with-addons-and-canvas.js.

Will do the trick just fine for my use case. Files available in my fork.

Closing the issue, but feel free to consider an official version 💸

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

1 participant