debug('finished compiling PureScript.')
cache.compilationFinished = true
if (code !== 0) {
- cache.errors = stderr.join('')
+ const errorMessage = stderr.join('');
+ if (errorMessage.length) {
+ psModule.emitError(errorMessage);
+ }
reject(new Error('compilation failed'))
} else {
- cache.warnings = stderr.join('')
+ const warningMessage = stderr.join('');
+ if (options.warnings && warningMessage.length) {
+ psModule.emitWarning(warningMessage);
+ }
resolve(psModule)
}
})
compilation.on('close', code => {
debug('finished bundling PureScript.')
if (code !== 0) {
- cache.errors = (cache.errors || '') + stderr.join('')
+ const errorMessage = stderr.join('');
+ if (errorMessage.length) {
+ psModule.emitError(errorMessage);
+ }
return reject(new Error('bundling failed'))
}
cache.bundle = stderr
.then(resolve)
.catch(() => resolve(psModule))
}
- cache.errors = compileMessages.join('\n')
+ const errorMessage = compileMessages.join('\n');
+ if (errorMessage.length) {
+ psModule.emitError(errorMessage);
+ }
resolve(psModule);
} else {
- cache.warnings = compileMessages.join('\n')
- resolve(psModule)
+ const warningMessage = compileMessages.join('\n');
+ if (options.warnings && warningMessage.length) {
+ psModule.emitWarning(warningMessage);
+ }
+ resolve(psModule);
}
})
})
psModuleMap: cache.psModuleMap
}
})
-
- // add psc warnings to webpack compilation warnings
- this._compiler.plugin('after-compile', (compilation, callback) => {
- if (options.warnings && cache.warnings) {
- compilation.warnings.unshift(`PureScript compilation:\n${cache.warnings}`)
- cache.warnings = null;
- }
-
- if (cache.errors) {
- compilation.errors.unshift(`PureScript compilation:\n${cache.errors}`)
- cache.errors = null;
- }
-
- 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)
}
debug('loader called', psModule.name)