]> git.immae.eu Git - github/fretlink/purs-loader.git/blame - README.md
Merge pull request #27 from ethul/topic/issue-26
[github/fretlink/purs-loader.git] / README.md
CommitLineData
a42f24b8 1# purs-loader
2
08b34471 3> [PureScript](http://www.purescript.org) loader for [webpack](http://webpack.github.io)
a42f24b8 4
5## Install
6
7Install with [npm](https://npmjs.org/package/purs-loader)
8
9```
10npm install purs-loader --save-dev
11```
12
13## Options
14
a72c8af1 15###### `noPrelude` (Boolean)
16
17Toggles `--no-prelude` that omits the Prelude.
18
19###### `noTco` (Boolean)
20
21Toggles `--no-tco` that disables tail-call optimizations.
22
23###### `noMagicDo` (Boolean)
24
25Toggles `--no-magic-do` that disables optimizations overloading the do keyword generating efficient code for the `Eff` monad.
26
27###### `noOpts` (Boolean)
28
29Toggles `--no-opts` that skips the optimization phase.
30
31###### `verboseErrors` (Boolean)
32
33Toggles `--verbose-errors` that displays verbose error messages.
34
35###### `comments` (Boolean)
36
37Toggles `--comments` that includes comments in generated code.
38
39###### `output` (String)
40
41Sets `--output=<string>` the specifies the output directory, `output` by default.
42
43###### `noPrefix` (Boolean)
44
45Toggles `--no-prefix` that does not include the comment header.
46
1983893b 47###### `requirePath` (String)
48
49Sets `--require-path=<string>` that specifies the path prefix to use for `require()` calls in the generated JavaScript.
50
51###### `ffi` (String Array)
52
53Specifies the PureScript FFI files setting `--ffi=<string>`. Glob syntax is supported. This option is specified as `ffi[]=path`.
54
a72c8af1 55###### `src` (String Array)
56
1983893b 57Specifies the PureScript source files. Glob syntax is supported. This option is specified as `src[]=path`.
a42f24b8 58
59## Example
60
1983893b 61```js
62// webpack.config.js
63
64var path = require('path');
65
66var srcs = ['src[]=bower_components/purescript-*/src/**/*.purs', 'src[]=src/**/*.purs'];
67
68var ffis = ['ffi[]=bower_components/purescript-*/src/**/*.js'];
69
70var output = 'output';
71
72var modulesDirectories = [
73 'node_modules',
74 // The bower component for purescript-prelude is specified here to
75 // allow JavaScript files to require the 'Prelude' module globally.
76 'bower_components/purescript-prelude/src',
77 // The output directory is specified here to allow PureScript files in
78 // your source to import other PureScript modules in your source.
79 output
80];
81
82var config
83 = { entry: './src/entry'
84 , output: { path: __dirname
85 , pathinfo: true
86 , filename: 'bundle.js'
87 }
88 , module: { loaders: [ { test: /\.purs$/
89 , loader: 'purs-loader?output=' + output + '&' + srcs.concat(ffis).join('&')
90 } ] }
91 , resolve: { modulesDirectories: modulesDirectories
92 , extensions: ['', '.js', '.purs']
93 }
94 , resolveLoader: { root: path.join(__dirname, 'node_modules') }
95 }
96 ;
97
98module.exports = config;
99```
100
464355c7 101See the [example](https://github.com/ethul/purs-loader/tree/master/example) directory for a complete example.
0e1221d7 102
103## Notes
104
105A `.psci` file is generated during each run of the loader.