@@ -7,11 +7,9 @@ var loaderUtils = require('loader-utils');
77var elmCompiler = require ( 'node-elm-compiler' ) ;
88var yargs = require ( 'yargs' ) ;
99
10- var runningInstances = 0 ;
1110var alreadyCompiledFiles = [ ] ;
1211
1312var defaultOptions = {
14- cache : false ,
1513 forceWatch : false ,
1614 optimize : false
1715} ;
@@ -154,53 +152,38 @@ module.exports = function() {
154152
155153 delete options . forceWatch
156154
157- var maxInstances = options . maxInstances ;
158-
159- if ( typeof maxInstances === "undefined" ) {
160- maxInstances = 1 ;
161- } else {
162- delete options . maxInstances ;
155+ // If we are running in watch mode, and we have previously compiled
156+ // the current file, then let the user know that `elm make` is running
157+ // and can be slow
158+ if ( alreadyCompiledFiles . indexOf ( resourcePath ) > - 1 ) {
159+ console . log ( 'Started compiling Elm...' ) ;
163160 }
164161
165- var intervalId = setInterval ( function ( ) {
166- if ( runningInstances >= maxInstances ) return ;
167- runningInstances += 1 ;
168- clearInterval ( intervalId ) ;
169-
170- // If we are running in watch mode, and we have previously compiled
171- // the current file, then let the user know that `elm make` is running
172- // and can be slow
173- if ( alreadyCompiledFiles . indexOf ( resourcePath ) > - 1 ) {
174- console . log ( 'Started compiling Elm..' ) ;
175- }
176-
177- var compilation = compile ( files , options )
178- . then ( function ( v ) { runningInstances -= 1 ; return { kind : 'success' , result : v } ; } )
179- . catch ( function ( v ) { runningInstances -= 1 ; return { kind : 'error' , error : v } ; } ) ;
162+ var compilation = compile ( files , options )
163+ . then ( function ( v ) { return { kind : 'success' , result : v } ; } )
164+ . catch ( function ( v ) { return { kind : 'error' , error : v } ; } ) ;
180165
181- promises . push ( compilation ) ;
166+ promises . push ( compilation ) ;
182167
183- Promise . all ( promises )
184- . then ( function ( results ) {
168+ Promise . all ( promises )
169+ . then ( function ( results ) {
185170 var output = results [ results . length - 1 ] ; // compilation output is always last
186171
187172 if ( output . kind === 'success' ) {
188- alreadyCompiledFiles . push ( resourcePath ) ;
189- callback ( null , output . result ) ;
173+ alreadyCompiledFiles . push ( resourcePath ) ;
174+ callback ( null , output . result ) ;
190175 } else {
191- if ( typeof output . error === 'string' ) {
192- output . error = new Error ( output . error ) ;
193- }
176+ if ( typeof output . error === 'string' ) {
177+ output . error = new Error ( output . error ) ;
178+ }
194179
195- output . error . message = 'Compiler process exited with error ' + output . error . message ;
196- output . error . stack = null ;
197- callback ( output . error ) ;
180+ output . error . message = 'Compiler process exited with error ' + output . error . message ;
181+ output . error . stack = null ;
182+ callback ( output . error ) ;
198183 }
199- } ) . catch ( function ( err ) {
184+ } ) . catch ( function ( err ) {
200185 callback ( err ) ;
201- } ) ;
202-
203- } , 200 ) ;
186+ } ) ;
204187}
205188
206189
0 commit comments