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