File tree Expand file tree Collapse file tree 3 files changed +25
-24
lines changed Expand file tree Collapse file tree 3 files changed +25
-24
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ const ResolverFactory = require("./ResolverFactory");
22
22
23
23
const RequestShortener = require ( "./RequestShortener" ) ;
24
24
const makePathsRelative = require ( "./util/identifier" ) . makePathsRelative ;
25
+ const ConcurrentCompilationError = require ( "./ConcurrentCompilationError" ) ;
25
26
26
27
class Compiler extends Tapable {
27
28
constructor ( context ) {
@@ -134,12 +135,7 @@ class Compiler extends Tapable {
134
135
}
135
136
136
137
watch ( watchOptions , handler ) {
137
- if ( this . running )
138
- return handler (
139
- new Error (
140
- "You ran Webpack twice. Each instance only supports a single concurrent compilation at a time."
141
- )
142
- ) ;
138
+ if ( this . running ) return handler ( new ConcurrentCompilationError ( ) ) ;
143
139
144
140
this . running = true ;
145
141
this . fileTimestamps = new Map ( ) ;
@@ -148,12 +144,7 @@ class Compiler extends Tapable {
148
144
}
149
145
150
146
run ( callback ) {
151
- if ( this . running )
152
- return callback (
153
- new Error (
154
- "You ran Webpack twice. Each instance only supports a single concurrent compilation at a time."
155
- )
156
- ) ;
147
+ if ( this . running ) return callback ( new ConcurrentCompilationError ( ) ) ;
157
148
158
149
const finalCallback = ( err , stats ) => {
159
150
this . running = false ;
Original file line number Diff line number Diff line change
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Maksim Nazarjev @acupofspirt
4
+ */
5
+ "use strict" ;
6
+
7
+ const WebpackError = require ( "./WebpackError" ) ;
8
+
9
+ module . exports = class ConcurrentCompilationError extends WebpackError {
10
+ constructor ( ) {
11
+ super ( ) ;
12
+
13
+ this . name = "ConcurrentCompilationError" ;
14
+ this . message =
15
+ "You ran Webpack twice. Each instance only supports a single concurrent compilation at a time." ;
16
+
17
+ Error . captureStackTrace ( this , this . constructor ) ;
18
+ }
19
+ } ;
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ const MultiHook = require("tapable").MultiHook;
10
10
const asyncLib = require ( "neo-async" ) ;
11
11
const MultiWatching = require ( "./MultiWatching" ) ;
12
12
const MultiStats = require ( "./MultiStats" ) ;
13
+ const ConcurrentCompilationError = require ( "./ConcurrentCompilationError" ) ;
13
14
14
15
module . exports = class MultiCompiler extends Tapable {
15
16
constructor ( compilers ) {
@@ -186,12 +187,7 @@ module.exports = class MultiCompiler extends Tapable {
186
187
}
187
188
188
189
watch ( watchOptions , handler ) {
189
- if ( this . running )
190
- return handler (
191
- new Error (
192
- "You ran Webpack twice. Each instance only supports a single concurrent compilation at a time."
193
- )
194
- ) ;
190
+ if ( this . running ) return handler ( new ConcurrentCompilationError ( ) ) ;
195
191
196
192
const finalHandler = ( err , stats ) => {
197
193
this . running = false ;
@@ -245,12 +241,7 @@ module.exports = class MultiCompiler extends Tapable {
245
241
}
246
242
247
243
run ( callback ) {
248
- if ( this . running )
249
- return callback (
250
- new Error (
251
- "You ran Webpack twice. Each instance only supports a single concurrent compilation at a time."
252
- )
253
- ) ;
244
+ if ( this . running ) return callback ( new ConcurrentCompilationError ( ) ) ;
254
245
255
246
const finalCallback = ( err , stats ) => {
256
247
this . running = false ;
You can’t perform that action at this time.
0 commit comments