aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/PursLoader/Plugin.js
diff options
context:
space:
mode:
authoreric thul <thul.eric@gmail.com>2016-02-24 22:53:40 -0500
committereric thul <thul.eric@gmail.com>2016-02-24 22:53:40 -0500
commit460393439a8dd7d94fe02a2013e96c9146282bf1 (patch)
tree178492f39cc5afa716f1c403d4a28d45606336a3 /src/PursLoader/Plugin.js
parentef1525b5a0fe3f4561493aaca49907dba827dbd6 (diff)
downloadpurs-loader-460393439a8dd7d94fe02a2013e96c9146282bf1.tar.gz
purs-loader-460393439a8dd7d94fe02a2013e96c9146282bf1.tar.zst
purs-loader-460393439a8dd7d94fe02a2013e96c9146282bf1.zip
Adds dependencies of modules process by the loader.
The module file path and dependency graph information is provided by the purescript-webpack-plugin. Resolves #37
Diffstat (limited to 'src/PursLoader/Plugin.js')
-rw-r--r--src/PursLoader/Plugin.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/PursLoader/Plugin.js b/src/PursLoader/Plugin.js
new file mode 100644
index 0000000..90feb33
--- /dev/null
+++ b/src/PursLoader/Plugin.js
@@ -0,0 +1,20 @@
1'use strict';
2
3// module PursLoader.Plugin
4
5function getFn(nothing, just, map, key) {
6 var value = map.get(key);
7 return value === undefined ? nothing : just(value);
8}
9exports.getFn = getFn;
10
11function dependenciesOfFn(left, right, graph, node) {
12 try {
13 var dependencies = graph.dependenciesOf(node);
14 return right(dependencies);
15 }
16 catch (error) {
17 return left(error);
18 }
19}
20exports.dependenciesOfFn = dependenciesOfFn;