diff options
author | eric thul <thul.eric@gmail.com> | 2016-03-13 10:00:17 -0400 |
---|---|---|
committer | eric thul <thul.eric@gmail.com> | 2016-03-13 10:00:17 -0400 |
commit | 0f0403a8359f316ece009442f2b3803e897cc9f1 (patch) | |
tree | 6e6d1f0b44750997e5358a2327be29d159da69b3 /src | |
parent | cfd5d2afba83a0082a3be638a05d1768ee73335e (diff) | |
download | purs-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.purs | 14 | ||||
-rw-r--r-- | src/PursLoader/Plugin.purs | 2 |
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 | ||
8 | import Prelude (Unit(), ($), (>>=), (<$>), (<*>), (++), (<<<), bind, const, id, pure, unit, void) | 8 | import Prelude (Unit(), ($), (>>=), (<$>), (<*>), (++), (<<<), bind, const, id, pure, unit) |
9 | 9 | ||
10 | import Control.Bind (join) | 10 | import Control.Bind (join) |
11 | import Control.Monad.Eff (Eff(), foreachE) | 11 | import Control.Monad.Eff (Eff(), foreachE) |
12 | import Control.Monad.Eff.Console (CONSOLE()) | 12 | import Control.Monad.Eff.Console (CONSOLE()) |
13 | import Control.Monad.Eff.Exception (EXCEPTION(), Error(), error, message) | 13 | import Control.Monad.Eff.Exception (EXCEPTION(), Error(), error) |
14 | 14 | ||
15 | import Data.Array ((!!)) | 15 | import Data.Array ((!!)) |
16 | import Data.Either (Either(..), either) | 16 | import Data.Either (Either(..), either) |
@@ -19,10 +19,6 @@ import Data.Maybe (maybe) | |||
19 | import Data.Nullable (toMaybe) | 19 | import Data.Nullable (toMaybe) |
20 | import Data.String.Regex (Regex(), match, noFlags, regex) | 20 | import Data.String.Regex (Regex(), match, noFlags, regex) |
21 | 21 | ||
22 | import Node.Encoding (Encoding(UTF8)) | ||
23 | import Node.Process (stderr) | ||
24 | import Node.Stream (writeString) | ||
25 | |||
26 | import Unsafe.Coerce (unsafeCoerce) | 22 | import Unsafe.Coerce (unsafeCoerce) |
27 | 23 | ||
28 | import PursLoader.LoaderRef | 24 | import 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(..)) | |||
15 | import Data.Function (Fn4(), runFn4) | 15 | import Data.Function (Fn4(), runFn4) |
16 | import Data.Nullable (Nullable()) | 16 | import Data.Nullable (Nullable()) |
17 | 17 | ||
18 | type Compile eff = Nullable Error -> DependencyGraph -> String -> Eff eff Unit | 18 | type Compile eff = Nullable Error -> DependencyGraph -> Eff eff Unit |
19 | 19 | ||
20 | type Context eff = { compile :: Compile eff -> Eff eff Unit, options :: Options } | 20 | type Context eff = { compile :: Compile eff -> Eff eff Unit, options :: Options } |
21 | 21 | ||