const compilation = spawn(options.psc, args)
- compilation.stdout.on('data', data => stderr.push(data.toString()))
- compilation.stderr.on('data', data => stderr.push(data.toString()))
+ compilation.stderr.on('data', data => {
+ stderr.push(data.toString());
+ });
compilation.on('close', code => {
debug('finished compiling PureScript.')
let cache = config.purescriptLoaderCache = config.purescriptLoaderCache || {
rebuild: false,
deferred: [],
- bundleModules: []
+ bundleModules: [],
+ warnings: [],
+ errors: []
}
if (!config.purescriptLoaderInstalled) {
deferred: [],
bundleModules: [],
ideServer: cache.ideServer,
- psModuleMap: cache.psModuleMap
+ psModuleMap: cache.psModuleMap,
+ warnings: [],
+ errors: []
}
- })
+ });
+
+ // add psc warnings to webpack compilation warnings
+ this._compiler.plugin('after-compile', (compilation, callback) => {
+ cache.warnings.forEach(warning => {
+ compilation.warnings.push(warning);
+ });
+
+ cache.errors.forEach(error => {
+ compilation.errors.push(error);
+ });
+
+ callback()
+ });
}
const psModuleName = PsModuleMap.match(source)
jsPath: path.resolve(path.join(options.output, psModuleName, 'index.js')),
options: options,
cache: cache,
- emitWarning: warning => this.emitWarning(warning),
- emitError: error => this.emitError(error)
+ emitWarning: warning => {
+ if (options.warnings && warning.length) {
+ cache.warnings.push(warning);
+ }
+ },
+ emitError: error => {
+ if (error.length) {
+ cache.errors.push(error);
+ }
+ }
}
debug('loader called', psModule.name)