diff options
author | eric thul <thul.eric@gmail.com> | 2015-08-11 21:21:47 -0400 |
---|---|---|
committer | eric thul <thul.eric@gmail.com> | 2015-08-11 21:21:47 -0400 |
commit | 07de44be15efb0ca9a2d1443ab1e91076a25409c (patch) | |
tree | 555547366ccadfe71689b95a6b16b855b6173364 /src | |
parent | 03b840cb5fb8ff5217fefc9e1240a3131db309fc (diff) | |
download | purs-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.js | 2 | ||||
-rw-r--r-- | src/PursLoader/Loader.purs | 4 |
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) { | |||
15 | exports.cwd = cwd; | 15 | exports.cwd = cwd; |
16 | 16 | ||
17 | exports.relative = relative; | 17 | exports.relative = relative; |
18 | |||
19 | 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) | |||
16 | import Data.Maybe (Maybe(..), fromMaybe, maybe) | 16 | import Data.Maybe (Maybe(..), fromMaybe, maybe) |
17 | import Data.String (joinWith) | 17 | import Data.String (joinWith) |
18 | import Data.String.Regex (match, noFlags, regex, test) | 18 | import Data.String.Regex (match, noFlags, regex, test) |
19 | import Data.Traversable (sequence) | ||
19 | 20 | ||
20 | import PursLoader.ChildProcess (ChildProcess(), spawn) | 21 | import PursLoader.ChildProcess (ChildProcess(), spawn) |
21 | import PursLoader.FS (FS(), writeFileUtf8, findFileUtf8) | 22 | import PursLoader.FS (FS(), writeFileUtf8, findFileUtf8) |
@@ -42,6 +43,8 @@ foreign import cwd :: String | |||
42 | 43 | ||
43 | foreign import relative :: String -> String -> String | 44 | foreign import relative :: String -> String -> String |
44 | 45 | ||
46 | foreign import resolve :: String -> String | ||
47 | |||
45 | mkPsci :: Array (Array String) -> Array (Array String) -> String | 48 | mkPsci :: Array (Array String) -> Array (Array String) -> String |
46 | mkPsci srcs ffis = joinWith "\n" ((loadModule <$> concat srcs) <> (loadForeign <$> concat ffis)) | 49 | mkPsci 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) |