reactjs / react-art

React Bridge to the ART Drawing Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support CDN'd / externally bundled React

jesstelford opened this issue · comments

react-art is reaching into the lib folder of react and using internal functionality which is not exposed when React is bundled on its own (eg the cdnjs version).

See here:

var ReactInstanceMap = require('react/lib/ReactInstanceMap');
var ReactMultiChild = require('react/lib/ReactMultiChild');
var ReactUpdates = require('react/lib/ReactUpdates');

var assign = require('react/lib/Object.assign');

I would expect to be able to use a tool such as browserify-shim to indicate in my app that a global instance of React exists (eg; the cdn'd version on window.React). However, due to the references to react/lib/X, which are not exposed, it causes things to break.

When using browserify-shim with the following in my package.json:

  "browserify-shim": {
    "react": "global:React",
    "react-dom": "global:ReactDOM",
    "react-art": {
      "depends": [
        "react"
      ]
    }
  },

I get the error:

Error: Cannot find module 'react/lib/ReactInstanceMap' from '/Users/jtelford/dev/test/node_modules/react-art/lib'

How can we stop react-art from reaching into react/lib/X?

React doesn't currently have an API to build things like React ART. Supporting this is a long-term goal for us but for now (and for a while to come), it will depend on these React internals.

If you want, you can build your own bundle using browserify that just contains react, react-dom, react-art, and then shim all three modules.

This isn't really actionable for us and won't be anytime soon so I'm closing it out, but we do want to resolve this eventually.

Thanks @spicyj.

you can build your own bundle using browserify that just contains react, react-dom, react-art

Unfortunately we would only be using react-art for one small component out of a much larger, multi-page application and it would negate the benefits of using a universal CDN version of react (ie; browser cache).

This makes react-art unusable for us right now.

Keep up the excellent work, and hopefully we can re-visit in the future :)

https://github.com/Khan/react-build uses webpack to make two bundles for React and React ART – use at your own risk.

Very interesting approach. For now, we've gone with straight <svg> elements as we no longer require IE8 support (yay) :)