diff options
-rw-r--r-- | docs/PursLoader/Debug.md | 9 | ||||
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | src/PursLoader/Debug.js | 12 | ||||
-rw-r--r-- | src/PursLoader/Debug.purs | 9 | ||||
-rw-r--r-- | src/PursLoader/Loader.purs | 6 |
5 files changed, 37 insertions, 0 deletions
diff --git a/docs/PursLoader/Debug.md b/docs/PursLoader/Debug.md new file mode 100644 index 0000000..824a9f8 --- /dev/null +++ b/docs/PursLoader/Debug.md | |||
@@ -0,0 +1,9 @@ | |||
1 | ## Module PursLoader.Debug | ||
2 | |||
3 | #### `debug` | ||
4 | |||
5 | ``` purescript | ||
6 | debug :: forall eff. String -> Eff (loader :: Loader | eff) Unit | ||
7 | ``` | ||
8 | |||
9 | |||
diff --git a/package.json b/package.json index 4d1dff2..e1a79d6 100644 --- a/package.json +++ b/package.json | |||
@@ -26,6 +26,7 @@ | |||
26 | "dependencies": { | 26 | "dependencies": { |
27 | "async": "^1.3.0", | 27 | "async": "^1.3.0", |
28 | "chalk": "^1.1.0", | 28 | "chalk": "^1.1.0", |
29 | "debug": "^2.2.0", | ||
29 | "loader-utils": "^0.2.6" | 30 | "loader-utils": "^0.2.6" |
30 | } | 31 | } |
31 | } | 32 | } |
diff --git a/src/PursLoader/Debug.js b/src/PursLoader/Debug.js new file mode 100644 index 0000000..85eca10 --- /dev/null +++ b/src/PursLoader/Debug.js | |||
@@ -0,0 +1,12 @@ | |||
1 | 'use strict'; | ||
2 | |||
3 | // module PursLoader.Debug | ||
4 | |||
5 | var debug_ = require('debug')('purs-loader'); | ||
6 | |||
7 | function debug(message) { | ||
8 | return function(){ | ||
9 | debug_(message); | ||
10 | }; | ||
11 | } | ||
12 | exports.debug = debug; | ||
diff --git a/src/PursLoader/Debug.purs b/src/PursLoader/Debug.purs new file mode 100644 index 0000000..7a02f69 --- /dev/null +++ b/src/PursLoader/Debug.purs | |||
@@ -0,0 +1,9 @@ | |||
1 | module PursLoader.Debug (debug) where | ||
2 | |||
3 | import Prelude (Unit()) | ||
4 | |||
5 | import Control.Monad.Eff (Eff()) | ||
6 | |||
7 | import PursLoader.LoaderRef (Loader()) | ||
8 | |||
9 | foreign import debug :: forall eff. String -> Eff (loader :: Loader | eff) Unit | ||
diff --git a/src/PursLoader/Loader.purs b/src/PursLoader/Loader.purs index f78153f..5e00f7e 100644 --- a/src/PursLoader/Loader.purs +++ b/src/PursLoader/Loader.purs | |||
@@ -34,6 +34,7 @@ import PursLoader.LoaderRef | |||
34 | , resourcePath | 34 | , resourcePath |
35 | ) | 35 | ) |
36 | 36 | ||
37 | import PursLoader.Debug (debug) | ||
37 | import PursLoader.LoaderUtil (parseQuery) | 38 | import PursLoader.LoaderUtil (parseQuery) |
38 | import PursLoader.Options (Options(..)) | 39 | import PursLoader.Options (Options(..)) |
39 | import PursLoader.Path (dirname, relative) | 40 | import PursLoader.Path (dirname, relative) |
@@ -47,6 +48,8 @@ loader ref source = do | |||
47 | 48 | ||
48 | cacheable ref | 49 | cacheable ref |
49 | 50 | ||
51 | debug "Invoke PureScript plugin compilation" | ||
52 | |||
50 | pluginContext.compile (compile callback) | 53 | pluginContext.compile (compile callback) |
51 | where | 54 | where |
52 | pluginContext :: Plugin.Context (Effects eff) | 55 | pluginContext :: Plugin.Context (Effects eff) |
@@ -56,6 +59,8 @@ loader ref source = do | |||
56 | compile callback error' { srcMap, ffiMap, graph } = do | 59 | compile callback error' { srcMap, ffiMap, graph } = do |
57 | clearDependencies ref | 60 | clearDependencies ref |
58 | 61 | ||
62 | either (const $ pure unit) (\a -> debug ("Adding PureScript dependency " ++ a)) name | ||
63 | |||
59 | addDependency ref (resourcePath ref) | 64 | addDependency ref (resourcePath ref) |
60 | 65 | ||
61 | either (\err -> callback (Just err) "") id | 66 | either (\err -> callback (Just err) "") id |
@@ -63,6 +68,7 @@ loader ref source = do | |||
63 | where | 68 | where |
64 | handle :: String -> Array String -> String -> Eff (Effects eff) Unit | 69 | handle :: String -> Array String -> String -> Eff (Effects eff) Unit |
65 | handle name' deps res = do | 70 | handle name' deps res = do |
71 | debug ("Adding PureScript transitive dependencies for " ++ name') | ||
66 | addTransitive name' | 72 | addTransitive name' |
67 | foreachE deps addTransitive | 73 | foreachE deps addTransitive |
68 | callback (toMaybe error') res | 74 | callback (toMaybe error') res |