aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--README.md34
-rw-r--r--bower.json3
-rw-r--r--docs/PursLoader/Plugin.md2
-rw-r--r--example/README.md6
-rw-r--r--example/bower.json7
-rw-r--r--example/package.json18
-rw-r--r--example/src/Bar.purs3
-rw-r--r--example/src/Foo.purs15
-rw-r--r--example/src/Foo/Bar.purs13
-rw-r--r--example/src/Foo/Baz.purs3
-rw-r--r--example/src/Foo/Boz.purs5
-rw-r--r--example/src/FooFFI.js5
-rw-r--r--example/src/Test.purs7
-rw-r--r--example/src/TestFFI.js7
-rw-r--r--example/src/entry.js11
-rw-r--r--example/src/jam.js5
-rw-r--r--example/webpack.config.js28
-rw-r--r--src/PursLoader/Loader.purs14
-rw-r--r--src/PursLoader/Plugin.purs2
20 files changed, 7 insertions, 185 deletions
diff --git a/.gitignore b/.gitignore
index 6c930c3..0a05586 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,8 +6,4 @@ index.js
6node_modules/ 6node_modules/
7bower_components/ 7bower_components/
8build/ 8build/
9example/bundle.js
10example/node_modules/
11example/bower_components/
12example/output/
13tmp/ 9tmp/
diff --git a/README.md b/README.md
index e93e969..df92e69 100644
--- a/README.md
+++ b/README.md
@@ -14,36 +14,4 @@ npm install purs-loader --save-dev
14 14
15## Example 15## Example
16 16
17```js 17Refer to the [purescript-webpack-example](https://github.com/ethul/purescript-webpack-example) for an example.
18// webpack.config.js
19'use strict';
20
21var PurescriptWebpackPlugin = require('purescript-webpack-plugin');
22
23var src = ['bower_components/purescript-*/src/**/*.purs', 'src/**/*.purs'];
24
25var ffi = ['bower_components/purescript-*/src/**/*.js', 'src/**/*FFI.js'];
26
27var modulesDirectories = [
28 'node_modules',
29 'bower_components'
30];
31
32var config
33 = { entry: './src/entry'
34 , output: { path: __dirname
35 , pathinfo: true
36 , filename: 'bundle.js'
37 }
38 , module: { loaders: [ { test: /\.purs$/
39 , loader: 'purs-loader'
40 } ] }
41 , resolve: { modulesDirectories: modulesDirectories }
42 , plugins: [ new PurescriptWebpackPlugin({src: src, ffi: ffi}) ]
43 }
44 ;
45
46module.exports = config;
47```
48
49See the [example](https://github.com/ethul/purs-loader/tree/master/example) directory for a complete example.
diff --git a/bower.json b/bower.json
index 681612d..761c24c 100644
--- a/bower.json
+++ b/bower.json
@@ -5,7 +5,6 @@
5 "purescript-aff": "^0.13.0", 5 "purescript-aff": "^0.13.0",
6 "purescript-foreign": "^0.7.0", 6 "purescript-foreign": "^0.7.0",
7 "purescript-unsafe-coerce": "~0.1.0", 7 "purescript-unsafe-coerce": "~0.1.0",
8 "purescript-nullable": "~0.2.1", 8 "purescript-nullable": "~0.2.1"
9 "purescript-node-process": "~0.4.1"
10 } 9 }
11} 10}
diff --git a/docs/PursLoader/Plugin.md b/docs/PursLoader/Plugin.md
index 9f9f852..7a524da 100644
--- a/docs/PursLoader/Plugin.md
+++ b/docs/PursLoader/Plugin.md
@@ -3,7 +3,7 @@
3#### `Compile` 3#### `Compile`
4 4
5``` purescript 5``` purescript
6type Compile eff = Nullable Error -> DependencyGraph -> String -> Eff eff Unit 6type Compile eff = Nullable Error -> DependencyGraph -> Eff eff Unit
7``` 7```
8 8
9#### `Context` 9#### `Context`
diff --git a/example/README.md b/example/README.md
deleted file mode 100644
index bac4f6c..0000000
--- a/example/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
1```bash
2bower install
3npm install
4npm run-script build
5npm run-script run
6```
diff --git a/example/bower.json b/example/bower.json
deleted file mode 100644
index c83e735..0000000
--- a/example/bower.json
+++ /dev/null
@@ -1,7 +0,0 @@
1{
2 "name": "example",
3 "private": true,
4 "devDependencies": {
5 "purescript-prelude": "~0.1.0"
6 }
7}
diff --git a/example/package.json b/example/package.json
deleted file mode 100644
index e256de8..0000000
--- a/example/package.json
+++ /dev/null
@@ -1,18 +0,0 @@
1{
2 "name": "example",
3 "version": "0.0.0",
4 "private": true,
5 "scripts": {
6 "build": "webpack --progress --colors --bail",
7 "build:watch": "webpack --progress --colors --watch",
8 "run": "node bundle.js",
9 "clean": "rm -rf bower_components && rm -rf bundle.js && rm -rf node_modules && rm -rf output"
10 },
11 "license": "MIT",
12 "devDependencies": {
13 "node-libs-browser": "^0.5.2",
14 "purescript-webpack-plugin": "^0.1.1",
15 "purs-loader": "file:../",
16 "webpack": "^1.12.9"
17 }
18}
diff --git a/example/src/Bar.purs b/example/src/Bar.purs
deleted file mode 100644
index a37171f..0000000
--- a/example/src/Bar.purs
+++ /dev/null
@@ -1,3 +0,0 @@
1module Bar where
2
3test = "b"
diff --git a/example/src/Foo.purs b/example/src/Foo.purs
deleted file mode 100644
index a715be0..0000000
--- a/example/src/Foo.purs
+++ /dev/null
@@ -1,15 +0,0 @@
1module Foo where
2
3import Prelude
4
5import qualified Foo.Bar as B
6
7foo = "A"
8
9bar = "B"
10
11jaz = "D" ++ B.jar ++ B.jee
12
13foreign import foot :: String
14
15foreign import meter :: String
diff --git a/example/src/Foo/Bar.purs b/example/src/Foo/Bar.purs
deleted file mode 100644
index 1b0919c..0000000
--- a/example/src/Foo/Bar.purs
+++ /dev/null
@@ -1,13 +0,0 @@
1module Foo.Bar (bar, jar, jee) where
2
3import Foo.Boz
4
5bar = "u"
6
7bar' = "d"
8
9jam = "c"
10
11jar = "xyzw"
12
13jee = "abcde"
diff --git a/example/src/Foo/Baz.purs b/example/src/Foo/Baz.purs
deleted file mode 100644
index 7b0451e..0000000
--- a/example/src/Foo/Baz.purs
+++ /dev/null
@@ -1,3 +0,0 @@
1module Foo.Baz (baz) where
2
3baz = "d"
diff --git a/example/src/Foo/Boz.purs b/example/src/Foo/Boz.purs
deleted file mode 100644
index c802e47..0000000
--- a/example/src/Foo/Boz.purs
+++ /dev/null
@@ -1,5 +0,0 @@
1module Foo.Boz where
2
3a = "a"
4
5b = "b"
diff --git a/example/src/FooFFI.js b/example/src/FooFFI.js
deleted file mode 100644
index a2681c8..0000000
--- a/example/src/FooFFI.js
+++ /dev/null
@@ -1,5 +0,0 @@
1// module Foo
2
3exports.foot = "a";
4
5exports.meter = "b";
diff --git a/example/src/Test.purs b/example/src/Test.purs
deleted file mode 100644
index 3a92681..0000000
--- a/example/src/Test.purs
+++ /dev/null
@@ -1,7 +0,0 @@
1module Test (testing) where
2
3bar = "c"
4
5goo = "a"
6
7foreign import testing :: String
diff --git a/example/src/TestFFI.js b/example/src/TestFFI.js
deleted file mode 100644
index dc2f04f..0000000
--- a/example/src/TestFFI.js
+++ /dev/null
@@ -1,7 +0,0 @@
1'use strict';
2
3// module Test
4
5var testing = 'abcde';
6
7exports.testing = testing;
diff --git a/example/src/entry.js b/example/src/entry.js
deleted file mode 100644
index a1e2a99..0000000
--- a/example/src/entry.js
+++ /dev/null
@@ -1,11 +0,0 @@
1var Prelude = require('purescript-prelude/src/Prelude');
2
3var test = require('./Test');
4
5var foo = require('./Foo.purs');
6
7var baz = require('./Foo/Baz');
8
9var jam = require('./jam');
10
11console.log(Prelude, test, foo, baz, jam);
diff --git a/example/src/jam.js b/example/src/jam.js
deleted file mode 100644
index 8889a69..0000000
--- a/example/src/jam.js
+++ /dev/null
@@ -1,5 +0,0 @@
1var x = 'a';
2
3var abcde = require('./Bar');
4
5module.exports = abcde;
diff --git a/example/webpack.config.js b/example/webpack.config.js
deleted file mode 100644
index 602de84..0000000
--- a/example/webpack.config.js
+++ /dev/null
@@ -1,28 +0,0 @@
1'use strict';
2
3var PurescriptWebpackPlugin = require('purescript-webpack-plugin');
4
5var src = ['bower_components/purescript-*/src/**/*.purs', 'src/**/*.purs'];
6
7var ffi = ['bower_components/purescript-*/src/**/*.js', 'src/**/*FFI.js'];
8
9var modulesDirectories = [
10 'node_modules',
11 'bower_components'
12];
13
14var config
15 = { entry: './src/entry'
16 , output: { path: __dirname
17 , pathinfo: true
18 , filename: 'bundle.js'
19 }
20 , module: { loaders: [ { test: /\.purs$/
21 , loader: 'purs-loader'
22 } ] }
23 , resolve: { modulesDirectories: modulesDirectories, extensions: [ '', '.js', '.purs'] }
24 , plugins: [ new PurescriptWebpackPlugin({src: src, ffi: ffi}) ]
25 }
26 ;
27
28module.exports = config;
diff --git a/src/PursLoader/Loader.purs b/src/PursLoader/Loader.purs
index c50c63c..97954f6 100644
--- a/src/PursLoader/Loader.purs
+++ b/src/PursLoader/Loader.purs
@@ -5,12 +5,12 @@ module PursLoader.Loader
5 , loaderFn 5 , loaderFn
6 ) where 6 ) where
7 7
8import Prelude (Unit(), ($), (>>=), (<$>), (<*>), (++), (<<<), bind, const, id, pure, unit, void) 8import Prelude (Unit(), ($), (>>=), (<$>), (<*>), (++), (<<<), bind, const, id, pure, unit)
9 9
10import Control.Bind (join) 10import Control.Bind (join)
11import Control.Monad.Eff (Eff(), foreachE) 11import Control.Monad.Eff (Eff(), foreachE)
12import Control.Monad.Eff.Console (CONSOLE()) 12import Control.Monad.Eff.Console (CONSOLE())
13import Control.Monad.Eff.Exception (EXCEPTION(), Error(), error, message) 13import Control.Monad.Eff.Exception (EXCEPTION(), Error(), error)
14 14
15import Data.Array ((!!)) 15import Data.Array ((!!))
16import Data.Either (Either(..), either) 16import Data.Either (Either(..), either)
@@ -19,10 +19,6 @@ import Data.Maybe (maybe)
19import Data.Nullable (toMaybe) 19import Data.Nullable (toMaybe)
20import Data.String.Regex (Regex(), match, noFlags, regex) 20import Data.String.Regex (Regex(), match, noFlags, regex)
21 21
22import Node.Encoding (Encoding(UTF8))
23import Node.Process (stderr)
24import Node.Stream (writeString)
25
26import Unsafe.Coerce (unsafeCoerce) 22import Unsafe.Coerce (unsafeCoerce)
27 23
28import PursLoader.LoaderRef 24import PursLoader.LoaderRef
@@ -57,15 +53,11 @@ loader ref source = do
57 pluginContext = (unsafeCoerce ref).purescriptWebpackPluginContext 53 pluginContext = (unsafeCoerce ref).purescriptWebpackPluginContext
58 54
59 compile :: AsyncCallback (Effects eff) -> Plugin.Compile (Effects_ eff) 55 compile :: AsyncCallback (Effects eff) -> Plugin.Compile (Effects_ eff)
60 compile callback error' graph output = do 56 compile callback error' graph = do
61 either (const $ pure unit) (\a -> debug ("Adding PureScript dependency " ++ a)) name 57 either (const $ pure unit) (\a -> debug ("Adding PureScript dependency " ++ a)) name
62 58
63 addDependency ref (resourcePath ref) 59 addDependency ref (resourcePath ref)
64 60
65 void $ writeString stderr UTF8 output (pure unit)
66
67 maybe (pure unit) (\a -> void $ writeString stderr UTF8 (message a) (pure unit)) (toMaybe error')
68
69 either (const $ callback (pure fixedError) "") id 61 either (const $ callback (pure fixedError) "") id
70 (handle <$> name <*> dependencies <*> exports) 62 (handle <$> name <*> dependencies <*> exports)
71 where 63 where
diff --git a/src/PursLoader/Plugin.purs b/src/PursLoader/Plugin.purs
index 8bb53be..c798c83 100644
--- a/src/PursLoader/Plugin.purs
+++ b/src/PursLoader/Plugin.purs
@@ -15,7 +15,7 @@ import Data.Either (Either(..))
15import Data.Function (Fn4(), runFn4) 15import Data.Function (Fn4(), runFn4)
16import Data.Nullable (Nullable()) 16import Data.Nullable (Nullable())
17 17
18type Compile eff = Nullable Error -> DependencyGraph -> String -> Eff eff Unit 18type Compile eff = Nullable Error -> DependencyGraph -> Eff eff Unit
19 19
20type Context eff = { compile :: Compile eff -> Eff eff Unit, options :: Options } 20type Context eff = { compile :: Compile eff -> Eff eff Unit, options :: Options }
21 21