```
+#### `booleanLoaderOption`
+
+``` purescript
+instance booleanLoaderOption :: LoaderOption Boolean
+```
+
+
+#### `stringLoaderOption`
+
+``` purescript
+instance stringLoaderOption :: LoaderOption String
+```
+
+
#### `pscMakeOutputOption`
``` purescript
```
+#### `loaderSrcOption`
+
+``` purescript
+loaderSrcOption :: Foreign -> Maybe [String]
+```
+
+
## Module PursLoader.Path
## Options
- - **no-prelude**: Boolean value that toggles `--no-prelude`
- - Do not include the Prelude in the generated Javascript.
- - **no-opts**: Boolean value that toggles `--no-opts`
- - Disable all optimizations.
- - **no-magic-do**: Boolean value that toggles `--no-magic-do`
- - Turn off optimizations which inline calls to >>= for the Eff monad.
- - **no-tco**: Boolean value that toggles `--no-tco`
- - Turn off tail-call elimination.
- - **verbose-errors**: Boolean value that toggles `--verbose-errors`
- - Generate verbose error messages.
- - **output**: String value that sets `--output=<string>`
- - Write the generated Javascript to the specified file.
+###### `noPrelude` (Boolean)
+
+Toggles `--no-prelude` that omits the Prelude.
+
+###### `noTco` (Boolean)
+
+Toggles `--no-tco` that disables tail-call optimizations.
+
+###### `noMagicDo` (Boolean)
+
+Toggles `--no-magic-do` that disables optimizations overloading the do keyword generating efficient code for the `Eff` monad.
+
+###### `noOpts` (Boolean)
+
+Toggles `--no-opts` that skips the optimization phase.
+
+###### `verboseErrors` (Boolean)
+
+Toggles `--verbose-errors` that displays verbose error messages.
+
+###### `comments` (Boolean)
+
+Toggles `--comments` that includes comments in generated code.
+
+###### `output` (String)
+
+Sets `--output=<string>` the specifies the output directory, `output` by default.
+
+###### `noPrefix` (Boolean)
+
+Toggles `--no-prefix` that does not include the comment header.
+
+###### `src` (String Array)
+
+Specifies PureScript source paths to be globbed for `.purs` files. By default, `bower_components` is search. Additional paths may be specified using this option. This option is specified as `src[]=path`.
## Example
, output: { path: __dirname
, filename: 'bundle.js'
}
- , module: { loaders: [ { test: /\.purs$/, loader: 'purs-loader' } ] }
+ , module: { loaders: [ { test: /\.purs$/, loader: 'purs-loader?src[]=src' } ] }
, resolve: { modulesDirectories: [ 'node_modules',
'output'
]
import PursLoader.LoaderRef (LoaderRef(), Loader(), async, cacheable, clearDependencies, addDependency, query, resourcePath)
import PursLoader.LoaderUtil (getRemainingRequest, parseQuery)
import PursLoader.OS (eol)
-import PursLoader.Options (pscMakeOptions, pscMakeDefaultOutput, pscMakeOutputOption)
+import PursLoader.Options (loaderSrcOption, pscMakeOptions, pscMakeDefaultOutput, pscMakeOutputOption)
import PursLoader.Path (dirname, join, relative, resolve)
foreign import cwd "var cwd = process.cwd();" :: String
(!!!) = flip (!!)
-pursPattern :: String -> String
-pursPattern root = join [ "{" ++ joinWith "," [ bowerPattern, root ] ++ "}"
+pursPattern :: [String] -> String
+pursPattern srcs = join [ "{" ++ joinWith "," ([ bowerPattern ] <> srcs) ++ "}"
, "**"
, "*.purs"
]
liftEff $ cacheable ref
let request = getRemainingRequest ref
- root = dirname $ relative cwd request
parsed = parseQuery $ query ref
+ srcs = loaderSrcOption parsed
opts = pscMakeOptions parsed
- pattern = pursPattern root
+ pattern = pursPattern $ fromMaybe [] srcs
key = match moduleRegex source >>= (!!!) 1
files <- glob pattern
( pscMakeOptions
, pscMakeDefaultOutput
, pscMakeOutputOption
+ , loaderSrcOption
) where
import Data.Either (either)
outputOpt = "output"
+commentsOpt = "comments"
+
+noPrefixOpt = "no-prefix"
+
+srcOpt = "src"
+
pscMakeDefaultOutput = "output"
newtype Options
, noMagicDo :: NullOrUndefined Boolean
, noTco :: NullOrUndefined Boolean
, verboseErrors :: NullOrUndefined Boolean
+ , comments :: NullOrUndefined Boolean
, output :: NullOrUndefined String
+ , noPrefix :: NullOrUndefined Boolean
+ , src :: NullOrUndefined [String]
}
instance isForeignOptions :: IsForeign Options where
- read obj = (\a b c d e f ->
- Options { noPrelude: a
- , noOpts: b
- , noMagicDo: c
- , noTco: d
- , verboseErrors: e
- , output: f
- }) <$> readProp noPreludeOpt obj
- <*> readProp noOptsOpt obj
- <*> readProp noMagicDoOpt obj
- <*> readProp noTcoOpt obj
- <*> readProp verboseErrorsOpt obj
- <*> readProp outputOpt obj
-
-booleanOpt :: String -> NullOrUndefined Boolean -> [String]
-booleanOpt key opt = maybe [] (\a -> if a then ["--" ++ key] else []) (runNullOrUndefined opt)
-
-stringOpt :: String -> NullOrUndefined String -> [String]
-stringOpt key opt = maybe [] (\a -> ["--" ++ key ++ "=" ++ a]) (runNullOrUndefined opt)
+ read obj = Options <$> ({ noPrelude: _
+ , noOpts: _
+ , noMagicDo: _
+ , noTco: _
+ , verboseErrors: _
+ , comments: _
+ , output: _
+ , noPrefix: _
+ , src: _
+ } <$> readProp noPreludeOpt obj
+ <*> readProp noOptsOpt obj
+ <*> readProp noMagicDoOpt obj
+ <*> readProp noTcoOpt obj
+ <*> readProp verboseErrorsOpt obj
+ <*> readProp commentsOpt obj
+ <*> readProp outputOpt obj
+ <*> readProp noPrefixOpt obj
+ <*> readProp srcOpt obj)
+
+class LoaderOption a where
+ opt :: String -> NullOrUndefined a -> [String]
+
+instance booleanLoaderOption :: LoaderOption Boolean where
+ opt key opt = maybe [] (\a -> if a then ["--" ++ key] else [])
+ (runNullOrUndefined opt)
+
+instance stringLoaderOption :: LoaderOption String where
+ opt key opt = maybe [] (\a -> ["--" ++ key ++ "=" ++ a])
+ (runNullOrUndefined opt)
pscMakeOutputOption :: Foreign -> Maybe String
pscMakeOutputOption query = either (const Nothing)
pscMakeOptions :: Foreign -> [String]
pscMakeOptions query = either (const []) fold parsed
where parsed = read query :: F Options
- fold (Options a) = booleanOpt noPreludeOpt a.noPrelude <>
- booleanOpt noOptsOpt a.noOpts <>
- booleanOpt noMagicDoOpt a.noMagicDo <>
- booleanOpt noTcoOpt a.noTco <>
- booleanOpt verboseErrorsOpt a.verboseErrors <>
- stringOpt outputOpt a.output
+ fold (Options a) = opt noPreludeOpt a.noPrelude <>
+ opt noOptsOpt a.noOpts <>
+ opt noMagicDoOpt a.noMagicDo <>
+ opt noTcoOpt a.noTco <>
+ opt verboseErrorsOpt a.verboseErrors <>
+ opt commentsOpt a.comments <>
+ opt outputOpt a.output <>
+ opt noPrefixOpt a.noPrefix
+
+loaderSrcOption :: Foreign -> Maybe [String]
+loaderSrcOption query = either (const Nothing)
+ (\(Options a) -> runNullOrUndefined a.src)
+ (read query)