From 0f0403a8359f316ece009442f2b3803e897cc9f1 Mon Sep 17 00:00:00 2001 From: eric thul Date: Sun, 13 Mar 2016 10:00:17 -0400 Subject: Defers to the plugin for writing PureScript output --- bower.json | 3 +-- docs/PursLoader/Plugin.md | 2 +- src/PursLoader/Loader.purs | 14 +++----------- src/PursLoader/Plugin.purs | 2 +- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/bower.json b/bower.json index 681612d..761c24c 100644 --- a/bower.json +++ b/bower.json @@ -5,7 +5,6 @@ "purescript-aff": "^0.13.0", "purescript-foreign": "^0.7.0", "purescript-unsafe-coerce": "~0.1.0", - "purescript-nullable": "~0.2.1", - "purescript-node-process": "~0.4.1" + "purescript-nullable": "~0.2.1" } } 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 @@ #### `Compile` ``` purescript -type Compile eff = Nullable Error -> DependencyGraph -> String -> Eff eff Unit +type Compile eff = Nullable Error -> DependencyGraph -> Eff eff Unit ``` #### `Context` 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 , loaderFn ) where -import Prelude (Unit(), ($), (>>=), (<$>), (<*>), (++), (<<<), bind, const, id, pure, unit, void) +import Prelude (Unit(), ($), (>>=), (<$>), (<*>), (++), (<<<), bind, const, id, pure, unit) import Control.Bind (join) import Control.Monad.Eff (Eff(), foreachE) import Control.Monad.Eff.Console (CONSOLE()) -import Control.Monad.Eff.Exception (EXCEPTION(), Error(), error, message) +import Control.Monad.Eff.Exception (EXCEPTION(), Error(), error) import Data.Array ((!!)) import Data.Either (Either(..), either) @@ -19,10 +19,6 @@ import Data.Maybe (maybe) import Data.Nullable (toMaybe) import Data.String.Regex (Regex(), match, noFlags, regex) -import Node.Encoding (Encoding(UTF8)) -import Node.Process (stderr) -import Node.Stream (writeString) - import Unsafe.Coerce (unsafeCoerce) import PursLoader.LoaderRef @@ -57,15 +53,11 @@ loader ref source = do pluginContext = (unsafeCoerce ref).purescriptWebpackPluginContext compile :: AsyncCallback (Effects eff) -> Plugin.Compile (Effects_ eff) - compile callback error' graph output = do + compile callback error' graph = do either (const $ pure unit) (\a -> debug ("Adding PureScript dependency " ++ a)) name addDependency ref (resourcePath ref) - void $ writeString stderr UTF8 output (pure unit) - - maybe (pure unit) (\a -> void $ writeString stderr UTF8 (message a) (pure unit)) (toMaybe error') - either (const $ callback (pure fixedError) "") id (handle <$> name <*> dependencies <*> exports) 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(..)) import Data.Function (Fn4(), runFn4) import Data.Nullable (Nullable()) -type Compile eff = Nullable Error -> DependencyGraph -> String -> Eff eff Unit +type Compile eff = Nullable Error -> DependencyGraph -> Eff eff Unit type Context eff = { compile :: Compile eff -> Eff eff Unit, options :: Options } -- cgit v1.2.3 From 1a7a07b7a4fa93a55a600ca9d466020f3e11ab5a Mon Sep 17 00:00:00 2001 From: eric thul Date: Sun, 13 Mar 2016 10:06:11 -0400 Subject: Extracting out the example --- .gitignore | 4 ---- README.md | 34 +--------------------------------- example/README.md | 6 ------ example/bower.json | 7 ------- example/package.json | 18 ------------------ example/src/Bar.purs | 3 --- example/src/Foo.purs | 15 --------------- example/src/Foo/Bar.purs | 13 ------------- example/src/Foo/Baz.purs | 3 --- example/src/Foo/Boz.purs | 5 ----- example/src/FooFFI.js | 5 ----- example/src/Test.purs | 7 ------- example/src/TestFFI.js | 7 ------- example/src/entry.js | 11 ----------- example/src/jam.js | 5 ----- example/webpack.config.js | 28 ---------------------------- 16 files changed, 1 insertion(+), 170 deletions(-) delete mode 100644 example/README.md delete mode 100644 example/bower.json delete mode 100644 example/package.json delete mode 100644 example/src/Bar.purs delete mode 100644 example/src/Foo.purs delete mode 100644 example/src/Foo/Bar.purs delete mode 100644 example/src/Foo/Baz.purs delete mode 100644 example/src/Foo/Boz.purs delete mode 100644 example/src/FooFFI.js delete mode 100644 example/src/Test.purs delete mode 100644 example/src/TestFFI.js delete mode 100644 example/src/entry.js delete mode 100644 example/src/jam.js delete mode 100644 example/webpack.config.js diff --git a/.gitignore b/.gitignore index 6c930c3..0a05586 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,4 @@ index.js node_modules/ bower_components/ build/ -example/bundle.js -example/node_modules/ -example/bower_components/ -example/output/ tmp/ 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 ## Example -```js -// webpack.config.js -'use strict'; - -var PurescriptWebpackPlugin = require('purescript-webpack-plugin'); - -var src = ['bower_components/purescript-*/src/**/*.purs', 'src/**/*.purs']; - -var ffi = ['bower_components/purescript-*/src/**/*.js', 'src/**/*FFI.js']; - -var modulesDirectories = [ - 'node_modules', - 'bower_components' -]; - -var config - = { entry: './src/entry' - , output: { path: __dirname - , pathinfo: true - , filename: 'bundle.js' - } - , module: { loaders: [ { test: /\.purs$/ - , loader: 'purs-loader' - } ] } - , resolve: { modulesDirectories: modulesDirectories } - , plugins: [ new PurescriptWebpackPlugin({src: src, ffi: ffi}) ] - } - ; - -module.exports = config; -``` - -See the [example](https://github.com/ethul/purs-loader/tree/master/example) directory for a complete example. +Refer to the [purescript-webpack-example](https://github.com/ethul/purescript-webpack-example) for an example. 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 @@ -```bash -bower install -npm install -npm run-script build -npm run-script run -``` 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 @@ -{ - "name": "example", - "private": true, - "devDependencies": { - "purescript-prelude": "~0.1.0" - } -} 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 @@ -{ - "name": "example", - "version": "0.0.0", - "private": true, - "scripts": { - "build": "webpack --progress --colors --bail", - "build:watch": "webpack --progress --colors --watch", - "run": "node bundle.js", - "clean": "rm -rf bower_components && rm -rf bundle.js && rm -rf node_modules && rm -rf output" - }, - "license": "MIT", - "devDependencies": { - "node-libs-browser": "^0.5.2", - "purescript-webpack-plugin": "^0.1.1", - "purs-loader": "file:../", - "webpack": "^1.12.9" - } -} 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 @@ -module Bar where - -test = "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 @@ -module Foo where - -import Prelude - -import qualified Foo.Bar as B - -foo = "A" - -bar = "B" - -jaz = "D" ++ B.jar ++ B.jee - -foreign import foot :: String - -foreign 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 @@ -module Foo.Bar (bar, jar, jee) where - -import Foo.Boz - -bar = "u" - -bar' = "d" - -jam = "c" - -jar = "xyzw" - -jee = "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 @@ -module Foo.Baz (baz) where - -baz = "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 @@ -module Foo.Boz where - -a = "a" - -b = "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 @@ -// module Foo - -exports.foot = "a"; - -exports.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 @@ -module Test (testing) where - -bar = "c" - -goo = "a" - -foreign 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 @@ -'use strict'; - -// module Test - -var testing = 'abcde'; - -exports.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 @@ -var Prelude = require('purescript-prelude/src/Prelude'); - -var test = require('./Test'); - -var foo = require('./Foo.purs'); - -var baz = require('./Foo/Baz'); - -var jam = require('./jam'); - -console.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 @@ -var x = 'a'; - -var abcde = require('./Bar'); - -module.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 @@ -'use strict'; - -var PurescriptWebpackPlugin = require('purescript-webpack-plugin'); - -var src = ['bower_components/purescript-*/src/**/*.purs', 'src/**/*.purs']; - -var ffi = ['bower_components/purescript-*/src/**/*.js', 'src/**/*FFI.js']; - -var modulesDirectories = [ - 'node_modules', - 'bower_components' -]; - -var config - = { entry: './src/entry' - , output: { path: __dirname - , pathinfo: true - , filename: 'bundle.js' - } - , module: { loaders: [ { test: /\.purs$/ - , loader: 'purs-loader' - } ] } - , resolve: { modulesDirectories: modulesDirectories, extensions: [ '', '.js', '.purs'] } - , plugins: [ new PurescriptWebpackPlugin({src: src, ffi: ffi}) ] - } - ; - -module.exports = config; -- cgit v1.2.3