Skip to content

Commit d4ec59a

Browse files
committed
Remove maxInstances and cache options.
1 parent e3a1598 commit d4ec59a

File tree

2 files changed

+21
-78
lines changed

2 files changed

+21
-78
lines changed

README.md

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -59,46 +59,6 @@ will cause the compiler to look for **all** elm source files in the specified di
5959
approach is recommended as it allows the compile to watch elm.json as well as every file
6060
in the source directories.
6161

62-
#### maxInstances (default 1)
63-
64-
You can add `maxInstances=8` to the loader:
65-
66-
```js
67-
...
68-
use: {
69-
loader: 'elm-webpack-loader',
70-
options: {
71-
maxInstances: 8
72-
}
73-
}
74-
...
75-
```
76-
77-
Set a limit to the number of maxInstances of elm that can spawned. This should be set to a number
78-
less than the number of cores your machine has. The ideal number is 1, as it will prevent Elm
79-
instances causing deadlocks.
80-
81-
#### Cache (default false)
82-
83-
You can add `cache=true` to the loader:
84-
85-
```js
86-
...
87-
use: {
88-
loader: 'elm-webpack-loader',
89-
options: {
90-
cache: true
91-
}
92-
}
93-
...
94-
```
95-
96-
If you add this, when using watch mode, the loader will only load the dependencies at startup.
97-
This could be performance improvement, but know that new files won't be picked up and so won't be
98-
watched until you restart webpack.
99-
100-
This flag doesn't matter if you don't use watch mode.
101-
10262
#### ForceWatch (default false)
10363

10464
This loader will infer if you are running webpack in watch mode by checking the webpack arguments.

index.js

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ var loaderUtils = require('loader-utils');
77
var elmCompiler = require('node-elm-compiler');
88
var yargs = require('yargs');
99

10-
var runningInstances = 0;
1110
var alreadyCompiledFiles = [];
1211

1312
var 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

Comments
 (0)