Description
I'm running into this issue with all purescript-react
based projects (e.g. ethul/purescript-react-example
, alexmingoia/pux-starter-app
, nwolverson/purescript-thermite-example
or this repo purescript-contrib/purescript-react
):
I can build the project fine (running e.g. npm install
, pulp browserify --to dist/Main.js
) and view the app in the browser.
Then I run: bower install purescript-psci-support
and pulp repl
(or purs repl 'src/**/*.purs' 'bower_components/purescript-*/src/**/*.purs'
)
I can then use the repl and even import modules that don’t use purescript-react
, but once I import a module that imports React
, I get his error:
PSCi, version 0.11.7
Type :? for help
> import Prelude
> 1+2
3
> import Main
> 1+2
/Users/andreas.thoelke/Documents/temp/purescript-thermite-example/.psci_modules/node_modules/react/foreign.js:120
return React.createClass(result);
^
TypeError: React.createClass is not a function
at Object.createClass (.../purescript-thermite-example/.psci_modules/node_modules/react/foreign.js:120:16)
I got some initial help with this at Slack/purescript:
I have a
react
folder innode-modules
and aReact
folder in../chapter8/.psci_modules/node_modules
natefaubion [3 days ago]
Oh the React folder in node_modules is probably the bindingsnatefaubion [3 days ago]
in psci_modules/node_modulesnatefaubion [3 days ago]
its just putting the compiler output within node_modules under psci_modulesnatefaubion [3 days ago]
and then I bet there’s case insensitivity issuenatefaubion [3 days ago]
because there’s “react/index.js”natefaubion [3 days ago]
and then “React/index.js” which is the compiler outputnatefaubion [3 days ago]
so it’s doingrequire("react")
which is actually pointing back to itselfnatefaubion [3 days ago]
require react resolving to to React, ie the bindings and not the librarypaf31 [2 days ago]
.psci_modules/node_modules should existpaf31 [2 days ago]
React in there is the compiled purs code thoughpaf31 [2 days ago]
Notice though how purescript-react doesn't use requirepaf31 [2 days ago]
React.createClass
and so onpaf31 [2 days ago]
React won't be in global scope therenatefaubion [1 day ago]
FWIW, the latest react bindings don’t use a globalnatefaubion [1 day ago]
it uses a normal require
I'm still not sure if I'm missing something obvious or if this issue should be raised at https://github.com/purescript/purescript.