Izzimach / react-three-legacy

React bindings to create and control a 3D scene using three.js
Other
1.52k stars 128 forks source link

can't use as a pure commonjs modules #96

Closed lcultx closed 7 years ago

lcultx commented 7 years ago

if config webpack like this:

    //https://webpack.github.io/docs/configuration.html#externals
    "externals": [
        /^react\/lib\/.+/,  // any require that refers to internal react modules
        /^react-dom\/lib\/.+/, // any require that refers to internal react modules
        {
            "react": "React",
            "react-dom": "ReactDOM",
            "three": "THREE"
        }
    ]

it can't find some react inter component in runtime ,such as:

react-dom/lib/ReactCompositeComponent

but if i config webpack like this:

    //https://webpack.github.io/docs/configuration.html#externals
    "externals": [
        // /^react\/lib\/.+/,  // any require that refers to internal react modules
        // /^react-dom\/lib\/.+/, // any require that refers to internal react modules
        {
            "react": "React",
            "react-dom": "ReactDOM",
            "three": "THREE"
        }
    ]

i will get a error

react-three-commonjs.js:1141 Uncaught TypeError: Cannot read property 'getPooled' of null
        var transaction = _ReactUpdates2.default.ReactReconcileTransaction.getPooled();

because ReactReconcileTransaction is Inject from react-dom but this ReactUpdates is a different

Izzimach commented 7 years ago

I'm not sure I understand. Why are you rewriting the named used by require? Are you trying to use a version of React from a CDN?