Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const loaderConfig = {
pscIdeColors: false, // defaults to true if psc === 'psa'
pscPackage: false, // include dependencies from psc-package
spago: false, // include dependencies from spago
spagoDhall: null, // if set, uses the specified spago config (i.e., spago -x spagoDhall ...)
bundleOutput: 'output/bundle.js',
bundleNamespace: 'PS',
bundle: false,
Expand Down
10 changes: 10 additions & 0 deletions src/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ module.exports = function compile(psModule) {
});

compilation.stdout.on('data', data => {
// NB: it seems like the actual error details are printed to stdout
// (at least on 0.15). So without this, you'll just get an error line
// saying what file has the error, but not what the error is...
//
// Combined with the `stderr` of each file being combined above,
// this has the unfortunate side effect of printing every file
// compiled as a warning (assuming compilation succeeds).
//
// purs has --json-errors, and we should really be taking advantage of it here...
stderr.push(data.toString());
debugVerbose(data.toString());
});

Expand Down
10 changes: 6 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ var CACHE_VAR = {

// include src files provided by psc-package or Spago
function requestDependencySources(packagerCommand, srcPath, loaderOptions) {
const packagerArgs = ['sources'];
const spagoDhall = loaderOptions.spago ? loaderOptions.spagoDhall : null;
const packagerArgs = spagoDhall ? ['-x', spagoDhall, 'sources'] : ['sources'];

const loaderSrc = loaderOptions.src || [
srcPath
Expand Down Expand Up @@ -75,13 +76,13 @@ function requestDependencySources(packagerCommand, srcPath, loaderOptions) {
}

// 'spago output path' will return the output folder in a monorepo
function getSpagoSources() {
function getSpagoSources(spagoDhall) {
const cachedVal = CACHE_VAR.spagoOutputPath;
if (cachedVal) {
return cachedVal
}
const command = "spago"
const args = ["path", "output"]
const args = spagoDhall ? ["-x", spagoDhall, "path", "output"] : ["path", "output"];

const cmd = spawn(command, args);

Expand Down Expand Up @@ -139,7 +140,7 @@ module.exports = function purescriptLoader(source, map) {
}
})(loaderOptions.pscPackage, loaderOptions.spago);

const outputPath = loaderOptions.spago ? getSpagoSources() : 'output'
const outputPath = loaderOptions.spago ? getSpagoSources(loaderOptions.spagoDhall) : 'output'

const options = Object.assign({
context: webpackContext,
Expand All @@ -156,6 +157,7 @@ module.exports = function purescriptLoader(source, map) {
pscIdeColors: loaderOptions.psc === 'psa',
pscPackage: false,
spago: false,
spagoDhall: null,
bundleOutput: 'output/bundle.js',
bundleNamespace: 'PS',
bundle: false,
Expand Down