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 | |
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
-rw-r--r-- | example/src/entry.js | 4 | ||||
-rw-r--r-- | src/PursLoader/Loader.js | 2 | ||||
-rw-r--r-- | src/PursLoader/Loader.purs | 4 |
3 files changed, 7 insertions, 3 deletions
diff --git a/example/src/entry.js b/example/src/entry.js index a41536c..cde8507 100644 --- a/example/src/entry.js +++ b/example/src/entry.js | |||
@@ -6,6 +6,4 @@ var foo = require('./Foo.purs'); | |||
6 | 6 | ||
7 | var baz = require('./Foo/Baz.purs'); | 7 | var baz = require('./Foo/Baz.purs'); |
8 | 8 | ||
9 | var bar = require('./Foo/Bar.purs'); | 9 | console.log(Prelude, test, foo, baz); |
10 | |||
11 | console.log(Prelude, test, foo, baz, bar); | ||
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) |