gulp-purescript
Runs the PureScript compiler to produce JavaScript files
Install with npm
npm install gulp-purescript --save-dev
This plugin requires that the PureScript binaries first be installed. The binaries may be installed using the purescript NPM package or as described on the PureScript installation section of the GitHub wiki.
var gulp = require('gulp');
var purescript = require('gulp-purescript');
gulp.task('psc', function(){
return purescript.psc({
src: 'src/*.purs'
});
});
There is also a more complete example that makes use of all the provided tasks in a common setup.
Refer to the PureScript compiler usage section of the Github wiki for additional details on the behaviour of each option below.
Options can be passed to the Haskell runtime system for psc
by passing a --psc-rts-opts
argument to gulp
. Any values that follow this flag will be passed through to the runtime. There is no need to include +RTS
/-RTS
options as these are inserted automatically. See the GHC documentation for information on the available RTS options.
Invokes the psc
command. The following options are supported.
Files to compile. Glob syntax is supported.
Toggles --no-tco
that disables tail-call optimizations.
Toggles --no-magic-do
that disables optimizations overloading the do keyword generating efficient code for the Eff
monad.
Toggles --no-opts
that skips the optimization phase.
Toggles --verbose-errors
that displays verbose error messages.
Toggles --comments
that includes comments in generated code.
Sets --output=<string>
the specifies the output directory, output
by default.
Toggles --no-prefix
that does not include the comment header.
Toggles --source-maps
that generates source maps.
Toggles --json-errors
that prints errors to stderr as JSON.
Invokes the psc-bundle
command. The following options are supported.
The psc
-produced JavaScript source files to bundle. Glob syntax is supported.
Sets --output=<string>
that specifies the output filename for the bundle.
The name of the module or modules to use as entry points for dead code elimination.
Toggles --main
or sets --main=<string>
that generates code to run the main
function in the specified module or the Main
module by default.
Sets --namespace=<string>
that specifies the namespace that PureScript modules will be exported to when running in the browser.
Invokes the psc-docs
command. The following options are supported.
Files to be used for generating the documentation. Glob syntax is supported.
Sets --output=<markdown|etags|ctags>
that specifies the output format.
Sets --docgen=...
that can be used to filter the modules documentation is generated for.
- If a string value is provided, the documentation for that single module will be generated.
- If a list of strings is provided, the documentation for all listed modules will be generated.
- If an object with module name/filename pairs (for example,
{ Module: 'docs/Module.md' }
) is provided, files will be written for each of the modules. In this mode, the task requires nodest
as no value is returned.
Generates a .psci
file.
Files added to the .psci
file with the :m
command. Glob syntax is supported.
This example will make and bundle the code, run tests, and produce a .psci
file and documentation for a project using the common bower_components
/src
file layout.
var gulp = require("gulp");
var purescript = require("gulp-purescript");
var run = require("gulp-run");
var sources = [
"src/**/*.purs",
"bower_components/purescript-*/src/**/*.purs",
];
gulp.task("make", function () {
return purescript.psc({ src: sources });
});
gulp.task("bundle", ["make"], function () {
return purescript.pscBundle({ src: "output/**/*.js", output: "dist/bundle.js" });
});
gulp.task("docs", function () {
return purescript.pscDocs({
src: sources,
docgen: {
"Name.Of.Module1": "docs/Name/Of/Module1.md",
"Name.Of.Module2": "docs/Name/Of/Module2.md"
}
});
});
gulp.task("dotpsci", function () {
return purescript.psci({ src: sources })
.pipe(gulp.dest("."));
});
gulp.task("test", ["make"], function() {
return purescript.pscBundle({ src: "output/**/*.js", main: "Test.Main" })
.pipe(run("node"));
});
gulp.task("default", ["bundle", "docs", "dotpsci", "test"]);