Conversation
| const main = options.mainModule[psModule.name]; | ||
|
|
||
| if (main) { | ||
| js = `${js}\nmodule.exports.${main}(module)();`; |
There was a problem hiding this comment.
Why does this call the function with module? Isn't module.exports.${main} an Eff?
|
Thanks for taking a look. I am still experimenting with this, but it seems On Wednesday, 9 November 2016, Pauan notifications@github.com wrote:
|
|
To clarify, here is the example entry I was working with: Example.pursmodule Example (Module, example) where
import Prelude (Unit, (>>=), bind, unit, void)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log)
import DOM.Node.Types (Element)
import DOM (DOM)
import React (createElement)
import ReactDOM (render, renderToString)
import Example.App (app)
example :: forall eff. Module -> Eff (dom :: DOM, console :: CONSOLE | eff) Unit
example module_ = do
let appEl = createElement app unit []
if isServerSide
then void (log (renderToString appEl))
else void (getElementById "app" >>= render appEl)
hot module_
foreign import isServerSide :: Boolean
foreign import getElementById :: forall eff. String -> Eff eff Element
foreign import hot :: forall eff. Module -> Eff eff Unit
foreign import data Module :: *Example.js'use strict';
exports.isServerSide = typeof document === 'undefined';
exports.getElementById = function(id) {
return function(){
return document.getElementById(id);
};
};
exports.hot = function(module) {
return function(){
if (module.hot) {
module.hot.accept();
}
};
}webpack.config.js...
{ test: /\.purs$/
, loader: 'purs-loader'
, query: { src: [ 'bower_components/purescript-*/src/**/*.purs', 'src/**/*.purs' ]
...
, mainModule: { Example: 'example' }
}
}
... |
@sgentle @Pauan
Sketch on resolving #33. Initial thoughts?
Thanks!