From 07de44be15efb0ca9a2d1443ab1e91076a25409c Mon Sep 17 00:00:00 2001
From: eric thul <thul.eric@gmail.com>
Date: Tue, 11 Aug 2015 21:21:47 -0400
Subject: Add all PureScript files as webpack dependencies

Resolves #26
---
 src/PursLoader/Loader.js   | 2 ++
 src/PursLoader/Loader.purs | 4 ++++
 2 files changed, 6 insertions(+)

(limited to 'src')

diff --git a/src/PursLoader/Loader.js b/src/PursLoader/Loader.js
index d7b5578..98459b6 100644
--- a/src/PursLoader/Loader.js
+++ b/src/PursLoader/Loader.js
@@ -15,3 +15,5 @@ function relative(from) {
 exports.cwd = cwd;
 
 exports.relative = relative;
+
+exports.resolve = path.resolve;
diff --git a/src/PursLoader/Loader.purs b/src/PursLoader/Loader.purs
index 5373d2f..3cb99cd 100644
--- a/src/PursLoader/Loader.purs
+++ b/src/PursLoader/Loader.purs
@@ -16,6 +16,7 @@ import Data.Function (Fn2(), mkFn2)
 import Data.Maybe (Maybe(..), fromMaybe, maybe)
 import Data.String (joinWith)
 import Data.String.Regex (match, noFlags, regex, test)
+import Data.Traversable (sequence)
 
 import PursLoader.ChildProcess (ChildProcess(), spawn)
 import PursLoader.FS (FS(), writeFileUtf8, findFileUtf8)
@@ -42,6 +43,8 @@ foreign import cwd :: String
 
 foreign import relative :: String -> String -> String
 
+foreign import resolve :: String -> String
+
 mkPsci :: Array (Array String) -> Array (Array String) -> String
 mkPsci srcs ffis = joinWith "\n" ((loadModule <$> concat srcs) <> (loadForeign <$> concat ffis))
   where
@@ -80,6 +83,7 @@ loader' ref source = do
 
   liftEff (clearDependencies ref)
   liftEff (addDependency ref (resourcePath ref))
+  liftEff (sequence $ (\src -> addDependency ref (resolve src)) <$> concat srcss)
 
   foreignPath <- if hasForeign
                     then fromMaybe (pure Nothing) (findFFI ffiss <$> moduleName)
-- 
cgit v1.2.3