const serverArgs = dargs(Object.assign({
outputDirectory: options.output,
- "_": options.src
+ '_': options.src
}, options.pscIdeServerArgs))
debug('attempting to start psc-ide-server', serverArgs)
const ideServer = cache.ideServer = spawn('psc-ide-server', serverArgs)
+
+ ideServer.stdout.on('data', data => {
+ debug('psc-ide-server stdout: %s', data.toString());
+ });
+
ideServer.stderr.on('data', data => {
- debug(data.toString())
- })
+ debug('psc-ide-server stderr: %s', data.toString());
+ });
+
+ ideServer.on('error', error => {
+ debug('psc-ide-server error: %o', error);
+ });
+
+ ideServer.on('close', (code, signal) => {
+ debug('psc-ide-server close: %s %s', code, signal);
+ });
return retryPromise((retry, number) => {
return connect_().catch(error => {
debug('unknown module, attempting full recompile')
return Psc.compile(psModule)
.then(() => PsModuleMap.makeMap(options.src).then(map => {
- debug('rebuilt module map');
+ debug('rebuilt module map after unknown module forced a recompile');
cache.psModuleMap = map;
}))
.then(() => request({ command: 'load' }))
})
})
+ debug('psc-ide-client stdin: %o', body);
+
ideClient.stdin.write(JSON.stringify(body))
ideClient.stdin.write('\n')
})
if (!cache.compilationStarted) {
return Psc.compile(psModule)
.then(() => PsModuleMap.makeMap(options.src).then(map => {
- debug('rebuilt module map');
+ debug('rebuilt module map after compile');
cache.psModuleMap = map;
}))
.then(() => Promise.map(cache.deferred, psModule => {
const result = js
.replace(requireRE, (m, p1) => {
- const escapedPath = jsStringEscape(psModuleMap[p1].src);
+ const moduleValue = psModuleMap[p1];
- replacedImports.push(p1);
+ if (!moduleValue) {
+ debug('module %s was not found in the map, replacing require with null', p1);
- return `require("${escapedPath}")`;
+ return 'null';
+ }
+ else {
+ const escapedPath = jsStringEscape(moduleValue.src);
+
+ replacedImports.push(p1);
+
+ return `require("${escapedPath}")`;
+ }
})
.replace(foreignRE, () => {
const escapedPath = jsStringEscape(psModuleMap[name].ffi);
})
;
- debug('imports %o', imports);
-
- debug('replaced imports %o', replacedImports);
-
const additionalImports = difference(imports, replacedImports);
- debug('additional imports for %s: %o', name, additionalImports);
+ if (additionalImports.length) {
+ debug('additional imports for %s: %o', name, additionalImports);
+ }
const additionalImportsResult = additionalImports.map(import_ => {
const escapedPath = jsStringEscape(psModuleMap[import_].src);