diff options
Diffstat (limited to 'src/PursLoader/Loader.purs')
-rw-r--r-- | src/PursLoader/Loader.purs | 22 |
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 | ||
7 | import Prelude (Unit(), ($), (>>=), (<$>), (<*>), (++), (<<<), bind, const, id, pure, unit) | 7 | import Prelude (Unit(), ($), (>>=), (<$>), (<*>), (++), (<<<), bind, const, id, pure, unit) |
8 | 8 | ||
9 | import Control.Apply ((*>)) | ||
10 | import Control.Alt ((<|>)) | 9 | import Control.Alt ((<|>)) |
11 | import Control.Bind (join) | 10 | import Control.Bind (join) |
12 | import Control.Monad.Eff (Eff(), foreachE) | 11 | import 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 = |