Default options:
```javascript
-{
+const loaderConfig = {
psc: 'psc',
pscArgs: {},
pscBundle: 'psc-bundle',
pscIdeArgs: {}, // for example, to use different psc-ide-server port: {port: 4088}
pscIdeServerArgs: {}, // for example, to change the port { port: 4088 }
pscIdeColors: false, // defaults to true if psc === 'psa'
+ pscPackage: false,
bundleOutput: 'output/bundle.js',
bundleNamespace: 'PS',
bundle: false,
output: 'output',
src: [
path.join('src', '**', '*.purs'),
+ // if pscPackage = false
path.join('bower_components', 'purescript-*', 'src', '**', '*.purs')
+ /*
+ * OR source paths reported by `psc-package sources`, if pscPackage = true
+ */
]
}
```
affected). To override the default behaviour, add:
`pscIdeServerArgs: { "_": ['your/*globs/here'] }` to the loader config
+### `psc-package` support (experimental)
-
-
+Set `pscPackage` query parameter to `true` to enable `psc-package` support. The `psc-package`-supplied source paths
+will be appended to `src` parameter.
const Psc = require('./Psc');
const PscIde = require('./PscIde');
const dargs = require('./dargs');
+const spawn = require('cross-spawn').sync
+const eol = require('os').EOL
const requireRegex = /require\(['"]\.\.\/([\w\.]+)['"]\)/g
const query = loaderUtils.parseQuery(this.query)
const webpackOptions = this.options.purescriptLoader || {}
- const options = Object.assign({
+ const depsPaths = (pscPackage => {
+ if (pscPackage) {
+ debug('calling psc-package...')
+
+ return spawn('psc-package', ['sources']).stdout.toString().split(eol).filter(v => v != '')
+ }
+ else {
+ return [ path.join('bower_components', 'purescript-*', 'src', '**', '*.purs') ]
+ }
+ })
+
+ let options = Object.assign(webpackOptions, query)
+
+ const defaultDeps = depsPaths(options.pscPackage)
+ const defaultOptions = {
context: config.context,
psc: 'psc',
pscArgs: {},
pscBundle: 'psc-bundle',
pscBundleArgs: {},
pscIde: false,
- pscIdeColors: webpackOptions.psc === 'psa' || query.psc === 'psa',
+ pscIdeColors: options.psc === 'psa',
pscIdeArgs: {},
+ pscPackage: false,
bundleOutput: 'output/bundle.js',
bundleNamespace: 'PS',
bundle: false,
output: 'output',
src: [
path.join('src', '**', '*.purs'),
- path.join('bower_components', 'purescript-*', 'src', '**', '*.purs')
+ ...defaultDeps
]
- }, webpackOptions, query)
+ }
this.cacheable && this.cacheable()
errors: []
}
+ if (options.pscPackage && options.src) {
+ options.src = options.src.concat(defaultDeps) // append psc-package-provided source paths with users'
+ }
+
+ options = Object.assign(defaultOptions, options)
+
if (!config.purescriptLoaderInstalled) {
config.purescriptLoaderInstalled = true