aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authoreric thul <thul.eric@gmail.com>2015-08-11 21:21:47 -0400
committereric thul <thul.eric@gmail.com>2015-08-11 21:21:47 -0400
commit07de44be15efb0ca9a2d1443ab1e91076a25409c (patch)
tree555547366ccadfe71689b95a6b16b855b6173364 /src
parent03b840cb5fb8ff5217fefc9e1240a3131db309fc (diff)
downloadpurs-loader-07de44be15efb0ca9a2d1443ab1e91076a25409c.tar.gz
purs-loader-07de44be15efb0ca9a2d1443ab1e91076a25409c.tar.zst
purs-loader-07de44be15efb0ca9a2d1443ab1e91076a25409c.zip
Add all PureScript files as webpack dependencies
Resolves #26
Diffstat (limited to 'src')
-rw-r--r--src/PursLoader/Loader.js2
-rw-r--r--src/PursLoader/Loader.purs4
2 files changed, 6 insertions, 0 deletions
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) {
15exports.cwd = cwd; 15exports.cwd = cwd;
16 16
17exports.relative = relative; 17exports.relative = relative;
18
19exports.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)
16import Data.Maybe (Maybe(..), fromMaybe, maybe) 16import Data.Maybe (Maybe(..), fromMaybe, maybe)
17import Data.String (joinWith) 17import Data.String (joinWith)
18import Data.String.Regex (match, noFlags, regex, test) 18import Data.String.Regex (match, noFlags, regex, test)
19import Data.Traversable (sequence)
19 20
20import PursLoader.ChildProcess (ChildProcess(), spawn) 21import PursLoader.ChildProcess (ChildProcess(), spawn)
21import PursLoader.FS (FS(), writeFileUtf8, findFileUtf8) 22import PursLoader.FS (FS(), writeFileUtf8, findFileUtf8)
@@ -42,6 +43,8 @@ foreign import cwd :: String
42 43
43foreign import relative :: String -> String -> String 44foreign import relative :: String -> String -> String
44 45
46foreign import resolve :: String -> String
47
45mkPsci :: Array (Array String) -> Array (Array String) -> String 48mkPsci :: Array (Array String) -> Array (Array String) -> String
46mkPsci srcs ffis = joinWith "\n" ((loadModule <$> concat srcs) <> (loadForeign <$> concat ffis)) 49mkPsci srcs ffis = joinWith "\n" ((loadModule <$> concat srcs) <> (loadForeign <$> concat ffis))
47 where 50 where
@@ -80,6 +83,7 @@ loader' ref source = do
80 83
81 liftEff (clearDependencies ref) 84 liftEff (clearDependencies ref)
82 liftEff (addDependency ref (resourcePath ref)) 85 liftEff (addDependency ref (resourcePath ref))
86 liftEff (sequence $ (\src -> addDependency ref (resolve src)) <$> concat srcss)
83 87
84 foreignPath <- if hasForeign 88 foreignPath <- if hasForeign
85 then fromMaybe (pure Nothing) (findFFI ffiss <$> moduleName) 89 then fromMaybe (pure Nothing) (findFFI ffiss <$> moduleName)