-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial sketch of main function support #72
base: master
Are you sure you want to change the base?
Conversation
const main = options.mainModule[psModule.name]; | ||
|
||
if (main) { | ||
js = `${js}\nmodule.exports.${main}(module)();`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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!