aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/PursLoader/Loader.purs
diff options
context:
space:
mode:
authoreric thul <thul.eric@gmail.com>2016-03-12 14:33:55 -0500
committereric thul <thul.eric@gmail.com>2016-03-12 14:33:55 -0500
commit845f3ec3c5b13a47d60b9ff2be14bf41fb5c4734 (patch)
treef27800de3576466ea4d5502d9adb9cd57a583715 /src/PursLoader/Loader.purs
parent87145c4d29e9ab45d04c62d19e8697527728549f (diff)
downloadpurs-loader-845f3ec3c5b13a47d60b9ff2be14bf41fb5c4734.tar.gz
purs-loader-845f3ec3c5b13a47d60b9ff2be14bf41fb5c4734.tar.zst
purs-loader-845f3ec3c5b13a47d60b9ff2be14bf41fb5c4734.zip
Handling dependencies
Diffstat (limited to 'src/PursLoader/Loader.purs')
-rw-r--r--src/PursLoader/Loader.purs22
1 files changed, 4 insertions, 18 deletions
diff --git a/src/PursLoader/Loader.purs b/src/PursLoader/Loader.purs
index 0dfa20e..402e805 100644
--- a/src/PursLoader/Loader.purs
+++ b/src/PursLoader/Loader.purs
@@ -6,7 +6,6 @@ module PursLoader.Loader
6 6
7import Prelude (Unit(), ($), (>>=), (<$>), (<*>), (++), (<<<), bind, const, id, pure, unit) 7import Prelude (Unit(), ($), (>>=), (<$>), (<*>), (++), (<<<), bind, const, id, pure, unit)
8 8
9import Control.Apply ((*>))
10import Control.Alt ((<|>)) 9import Control.Alt ((<|>))
11import Control.Bind (join) 10import Control.Bind (join)
12import Control.Monad.Eff (Eff(), foreachE) 11import Control.Monad.Eff (Eff(), foreachE)
@@ -27,7 +26,6 @@ import PursLoader.LoaderRef
27 , Loader() 26 , Loader()
28 , async 27 , async
29 , cacheable 28 , cacheable
30 , clearDependencies
31 , addDependency 29 , addDependency
32 , resourcePath 30 , resourcePath
33 ) 31 )
@@ -52,9 +50,7 @@ loader ref source = do
52 pluginContext = (unsafeCoerce ref).purescriptWebpackPluginContext 50 pluginContext = (unsafeCoerce ref).purescriptWebpackPluginContext
53 51
54 compile :: AsyncCallback eff -> Plugin.Compile (Effects eff) 52 compile :: AsyncCallback eff -> Plugin.Compile (Effects eff)
55 compile callback error' { srcMap, ffiMap, graph } = do 53 compile callback error' graph = do
56 clearDependencies ref
57
58 either (const $ pure unit) (\a -> debug ("Adding PureScript dependency " ++ a)) name 54 either (const $ pure unit) (\a -> debug ("Adding PureScript dependency " ++ a)) name
59 55
60 addDependency ref (resourcePath ref) 56 addDependency ref (resourcePath ref)
@@ -64,9 +60,8 @@ loader ref source = do
64 where 60 where
65 handle :: String -> Array String -> String -> Eff (Effects eff) Unit 61 handle :: String -> Array String -> String -> Eff (Effects eff) Unit
66 handle name' deps res = do 62 handle name' deps res = do
67 debug ("Adding PureScript transitive dependencies for " ++ name') 63 debug ("Adding PureScript dependencies for " ++ name')
68 addTransitive name' 64 foreachE deps (addDependency ref)
69 foreachE deps addTransitive
70 debug "Generated loader result" 65 debug "Generated loader result"
71 debug res 66 debug res
72 callback (toMaybe error') res 67 callback (toMaybe error') res
@@ -93,16 +88,7 @@ loader ref source = do
93 resourceDir = dirname (resourcePath ref) 88 resourceDir = dirname (resourcePath ref)
94 89
95 dependencies :: Either Error (Array String) 90 dependencies :: Either Error (Array String)
96 dependencies = 91 dependencies = Plugin.dependenciesOf graph (resourcePath ref)
97 if pluginContext.options.bundle
98 then name >>= Plugin.dependenciesOf graph
99 else pure []
100
101 addTransitive :: String -> Eff (Effects eff) Unit
102 addTransitive dep = addDep (Plugin.get srcMap dep) *> addDep (Plugin.get ffiMap dep)
103 where
104 addDep :: Maybe String -> Eff (Effects eff) Unit
105 addDep = maybe (pure unit) (addDependency ref)
106 92
107 name :: Either Error String 93 name :: Either Error String
108 name = 94 name =