compilationStarted: false,
compilationFinished: false,
installed: false,
- srcOption: []
+ srcOption: [],
+ spagoOutputPath: null
};
// include src files provided by psc-package or Spago
}
}
+// 'spago output path' will return the output folder in a monorepo
+function getSpagoSources() {
+ const cachedVal = CACHE_VAR.spagoOutputPath;
+ if (cachedVal) {
+ return cachedVal
+ }
+ const command = "spago"
+ const args = ["path", "output"]
+
+ const cmd = spawn(command, args);
+
+ if (cmd.error) {
+ throw new Error(cmd.error);
+ }
+ else if (cmd.status !== 0) {
+ const error = cmd.stdout.toString();
+
+ throw new Error(error);
+ }
+ else {
+ const result = cmd.stdout.toString().split(eol)[0]
+
+ debug('"spago path output" result: %o', result);
+
+ CACHE_VAR.spagoOutputPath = result;
+
+ return result;
+ }
+}
+
module.exports = function purescriptLoader(source, map) {
this.cacheable && this.cacheable();
return result;
}
})(loaderOptions.pscPackage, loaderOptions.spago);
+
+ const outputPath = loaderOptions.spago ? getSpagoSources() : 'output'
const options = Object.assign({
context: webpackContext,
bundle: false,
warnings: true,
watch: false,
- output: 'output',
+ output: outputPath,
src: []
}, loaderOptions, {
src: srcOption