Move concurrent compilation error to separate class
This commit is contained in:
parent
9f60f50644
commit
ea6e173551
|
@ -22,6 +22,7 @@ const ResolverFactory = require("./ResolverFactory");
|
|||
|
||||
const RequestShortener = require("./RequestShortener");
|
||||
const makePathsRelative = require("./util/identifier").makePathsRelative;
|
||||
const ConcurrentCompilationError = require("./ConcurrentCompilationError");
|
||||
|
||||
class Compiler extends Tapable {
|
||||
constructor(context) {
|
||||
|
@ -134,12 +135,7 @@ class Compiler extends Tapable {
|
|||
}
|
||||
|
||||
watch(watchOptions, handler) {
|
||||
if (this.running)
|
||||
return handler(
|
||||
new Error(
|
||||
"You ran Webpack twice. Each instance only supports a single concurrent compilation at a time."
|
||||
)
|
||||
);
|
||||
if (this.running) return handler(new ConcurrentCompilationError());
|
||||
|
||||
this.running = true;
|
||||
this.fileTimestamps = new Map();
|
||||
|
@ -148,12 +144,7 @@ class Compiler extends Tapable {
|
|||
}
|
||||
|
||||
run(callback) {
|
||||
if (this.running)
|
||||
return callback(
|
||||
new Error(
|
||||
"You ran Webpack twice. Each instance only supports a single concurrent compilation at a time."
|
||||
)
|
||||
);
|
||||
if (this.running) return callback(new ConcurrentCompilationError());
|
||||
|
||||
const finalCallback = (err, stats) => {
|
||||
this.running = false;
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Maksim Nazarjev @acupofspirt
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const WebpackError = require("./WebpackError");
|
||||
|
||||
module.exports = class ConcurrentCompilationError extends WebpackError {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "ConcurrentCompilationError";
|
||||
this.message =
|
||||
"You ran Webpack twice. Each instance only supports a single concurrent compilation at a time.";
|
||||
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
};
|
|
@ -10,6 +10,7 @@ const MultiHook = require("tapable").MultiHook;
|
|||
const asyncLib = require("neo-async");
|
||||
const MultiWatching = require("./MultiWatching");
|
||||
const MultiStats = require("./MultiStats");
|
||||
const ConcurrentCompilationError = require("./ConcurrentCompilationError");
|
||||
|
||||
module.exports = class MultiCompiler extends Tapable {
|
||||
constructor(compilers) {
|
||||
|
@ -186,12 +187,7 @@ module.exports = class MultiCompiler extends Tapable {
|
|||
}
|
||||
|
||||
watch(watchOptions, handler) {
|
||||
if (this.running)
|
||||
return handler(
|
||||
new Error(
|
||||
"You ran Webpack twice. Each instance only supports a single concurrent compilation at a time."
|
||||
)
|
||||
);
|
||||
if (this.running) return handler(new ConcurrentCompilationError());
|
||||
|
||||
const finalHandler = (err, stats) => {
|
||||
this.running = false;
|
||||
|
@ -245,12 +241,7 @@ module.exports = class MultiCompiler extends Tapable {
|
|||
}
|
||||
|
||||
run(callback) {
|
||||
if (this.running)
|
||||
return callback(
|
||||
new Error(
|
||||
"You ran Webpack twice. Each instance only supports a single concurrent compilation at a time."
|
||||
)
|
||||
);
|
||||
if (this.running) return callback(new ConcurrentCompilationError());
|
||||
|
||||
const finalCallback = (err, stats) => {
|
||||
this.running = false;
|
||||
|
|
Loading…
Reference in New Issue