aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authoreric thul <thul.eric@gmail.com>2016-11-19 12:26:58 -0500
committereric thul <thul.eric@gmail.com>2016-11-19 12:45:11 -0500
commitdf05d7e1e854b318fc74f33ca701ed521fd3a5ce (patch)
treef2e021214de4cd17270a07e60bd2af0592af9882
parent2d52ea7e4b77a3ea5a8574ca245f51738d22d4a0 (diff)
downloadpurs-loader-df05d7e1e854b318fc74f33ca701ed521fd3a5ce.tar.gz
purs-loader-df05d7e1e854b318fc74f33ca701ed521fd3a5ce.tar.zst
purs-loader-df05d7e1e854b318fc74f33ca701ed521fd3a5ce.zip
Always resolve on psc-ide rebuild failure
The objective of enabling psc-ide is to obtain feedback immediately from the PureScript compiler. When the loader triggers an error to webpack, the bundle is invalidated and dependencies of the PureScript file that caused the error will be passed through the loader on the next successful rebuild. However, this behaviour adds time to the feedback loop. In order to reduce the time of the PureScript compiler feedback loop when in development, this commit always resolves the rebuild process with a success. Errors and warnings are still emitted, but the webpack bundle is not invalidated. This means that the loader will only be run for the current file being editted and the developer gets immediate feedback on success or failure when psc-ide is enabled. Resolves #76
-rw-r--r--src/PscIde.js13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/PscIde.js b/src/PscIde.js
index c9d0cfa..b0b56a8 100644
--- a/src/PscIde.js
+++ b/src/PscIde.js
@@ -77,10 +77,7 @@ function connect(psModule) {
77 if (!cache.ideServer && number === 9) { 77 if (!cache.ideServer && number === 9) {
78 debug(error) 78 debug(error)
79 79
80 console.log( 80 console.warn('Failed to connect to or start psc-ide-server. A full compilation will occur on rebuild');
81 'failed to connect to or start psc-ide-server, ' +
82 'full compilation will occur on rebuild'
83 )
84 81
85 return Promise.resolve(psModule) 82 return Promise.resolve(psModule)
86 } 83 }
@@ -133,9 +130,7 @@ function rebuild(psModule) {
133 } 130 }
134 131
135 if (res && !Array.isArray(res.result)) { 132 if (res && !Array.isArray(res.result)) {
136 return res.resultType === 'success' 133 return resolve(psModule);
137 ? resolve(psModule)
138 : reject(new Error('psc-ide rebuild failed'))
139 } 134 }
140 135
141 Promise.map(res.result, (item, i) => { 136 Promise.map(res.result, (item, i) => {
@@ -153,10 +148,10 @@ function rebuild(psModule) {
153 })) 148 }))
154 .then(() => request({ command: 'load' })) 149 .then(() => request({ command: 'load' }))
155 .then(resolve) 150 .then(resolve)
156 .catch(() => reject(new Error('psc-ide rebuild failed'))) 151 .catch(() => resolve(psModule))
157 } 152 }
158 cache.errors = compileMessages.join('\n') 153 cache.errors = compileMessages.join('\n')
159 reject(new Error('psc-ide rebuild failed')) 154 resolve(psModule);
160 } else { 155 } else {
161 cache.warnings = compileMessages.join('\n') 156 cache.warnings = compileMessages.join('\n')
162 resolve(psModule) 157 resolve(psModule)