diff --git a/README.md b/README.md index e308016..c8af814 100644 --- a/README.md +++ b/README.md @@ -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, diff --git a/src/compile.js b/src/compile.js index e37b3e4..4928be3 100644 --- a/src/compile.js +++ b/src/compile.js @@ -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()); }); diff --git a/src/index.js b/src/index.js index ff13302..8f8733f 100644 --- a/src/index.js +++ b/src/index.js @@ -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 @@ -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); @@ -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, @@ -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,