aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authoreric thul <thul.eric@gmail.com>2016-03-13 10:00:17 -0400
committereric thul <thul.eric@gmail.com>2016-03-13 10:00:17 -0400
commit0f0403a8359f316ece009442f2b3803e897cc9f1 (patch)
tree6e6d1f0b44750997e5358a2327be29d159da69b3 /src
parentcfd5d2afba83a0082a3be638a05d1768ee73335e (diff)
downloadpurs-loader-0f0403a8359f316ece009442f2b3803e897cc9f1.tar.gz
purs-loader-0f0403a8359f316ece009442f2b3803e897cc9f1.tar.zst
purs-loader-0f0403a8359f316ece009442f2b3803e897cc9f1.zip
Defers to the plugin for writing PureScript output
Diffstat (limited to 'src')
-rw-r--r--src/PursLoader/Loader.purs14
-rw-r--r--src/PursLoader/Plugin.purs2
2 files changed, 4 insertions, 12 deletions
diff --git a/src/PursLoader/Loader.purs b/src/PursLoader/Loader.purs
index c50c63c..97954f6 100644
--- a/src/PursLoader/Loader.purs
+++ b/src/PursLoader/Loader.purs
@@ -5,12 +5,12 @@ module PursLoader.Loader
5 , loaderFn 5 , loaderFn
6 ) where 6 ) where
7 7
8import Prelude (Unit(), ($), (>>=), (<$>), (<*>), (++), (<<<), bind, const, id, pure, unit, void) 8import Prelude (Unit(), ($), (>>=), (<$>), (<*>), (++), (<<<), bind, const, id, pure, unit)
9 9
10import Control.Bind (join) 10import Control.Bind (join)
11import Control.Monad.Eff (Eff(), foreachE) 11import Control.Monad.Eff (Eff(), foreachE)
12import Control.Monad.Eff.Console (CONSOLE()) 12import Control.Monad.Eff.Console (CONSOLE())
13import Control.Monad.Eff.Exception (EXCEPTION(), Error(), error, message) 13import Control.Monad.Eff.Exception (EXCEPTION(), Error(), error)
14 14
15import Data.Array ((!!)) 15import Data.Array ((!!))
16import Data.Either (Either(..), either) 16import Data.Either (Either(..), either)
@@ -19,10 +19,6 @@ import Data.Maybe (maybe)
19import Data.Nullable (toMaybe) 19import Data.Nullable (toMaybe)
20import Data.String.Regex (Regex(), match, noFlags, regex) 20import Data.String.Regex (Regex(), match, noFlags, regex)
21 21
22import Node.Encoding (Encoding(UTF8))
23import Node.Process (stderr)
24import Node.Stream (writeString)
25
26import Unsafe.Coerce (unsafeCoerce) 22import Unsafe.Coerce (unsafeCoerce)
27 23
28import PursLoader.LoaderRef 24import PursLoader.LoaderRef
@@ -57,15 +53,11 @@ loader ref source = do
57 pluginContext = (unsafeCoerce ref).purescriptWebpackPluginContext 53 pluginContext = (unsafeCoerce ref).purescriptWebpackPluginContext
58 54
59 compile :: AsyncCallback (Effects eff) -> Plugin.Compile (Effects_ eff) 55 compile :: AsyncCallback (Effects eff) -> Plugin.Compile (Effects_ eff)
60 compile callback error' graph output = do 56 compile callback error' graph = do
61 either (const $ pure unit) (\a -> debug ("Adding PureScript dependency " ++ a)) name 57 either (const $ pure unit) (\a -> debug ("Adding PureScript dependency " ++ a)) name
62 58
63 addDependency ref (resourcePath ref) 59 addDependency ref (resourcePath ref)
64 60
65 void $ writeString stderr UTF8 output (pure unit)
66
67 maybe (pure unit) (\a -> void $ writeString stderr UTF8 (message a) (pure unit)) (toMaybe error')
68
69 either (const $ callback (pure fixedError) "") id 61 either (const $ callback (pure fixedError) "") id
70 (handle <$> name <*> dependencies <*> exports) 62 (handle <$> name <*> dependencies <*> exports)
71 where 63 where
diff --git a/src/PursLoader/Plugin.purs b/src/PursLoader/Plugin.purs
index 8bb53be..c798c83 100644
--- a/src/PursLoader/Plugin.purs
+++ b/src/PursLoader/Plugin.purs
@@ -15,7 +15,7 @@ import Data.Either (Either(..))
15import Data.Function (Fn4(), runFn4) 15import Data.Function (Fn4(), runFn4)
16import Data.Nullable (Nullable()) 16import Data.Nullable (Nullable())
17 17
18type Compile eff = Nullable Error -> DependencyGraph -> String -> Eff eff Unit 18type Compile eff = Nullable Error -> DependencyGraph -> Eff eff Unit
19 19
20type Context eff = { compile :: Compile eff -> Eff eff Unit, options :: Options } 20type Context eff = { compile :: Compile eff -> Eff eff Unit, options :: Options }
21 21