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 in node-modules and a React folder in ../chapter8/.psci_modules/node_modules
natefaubion [3 days ago]
Oh the React folder in node_modules is probably the bindings
natefaubion [3 days ago]
in psci_modules/node_modules
natefaubion [3 days ago]
its just putting the compiler output within node_modules under psci_modules
natefaubion [3 days ago]
and then I bet there’s case insensitivity issue
natefaubion [3 days ago]
because there’s “react/index.js”
natefaubion [3 days ago]
and then “React/index.js” which is the compiler output
natefaubion [3 days ago]
so it’s doing require("react") which is actually pointing back to itself
natefaubion [3 days ago]
require react resolving to to React, ie the bindings and not the library
paf31 [2 days ago]
.psci_modules/node_modules should exist
paf31 [2 days ago]
React in there is the compiled purs code though
paf31 [2 days ago]
Notice though how purescript-react doesn't use require
paf31 [2 days ago]
React.createClass and so on
paf31 [2 days ago]
React won't be in global scope there
natefaubion [1 day ago]
FWIW, the latest react bindings don’t use a global
natefaubion [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.
I'm running into this issue with all
purescript-reactbased projects (e.g.ethul/purescript-react-example,alexmingoia/pux-starter-app,nwolverson/purescript-thermite-exampleor this repopurescript-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-supportandpulp repl(orpurs 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 importsReact, I get his error:I got some initial help with this at Slack/purescript:
I'm still not sure if I'm missing something obvious or if this issue should be raised at https://github.com/purescript/purescript.