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");
2222
2323const RequestShortener = require ( "./RequestShortener" ) ;
2424const makePathsRelative = require ( "./util/identifier" ) . makePathsRelative ;
25+ const ConcurrentCompilationError = require ( "./ConcurrentCompilationError" ) ;
2526
2627class Compiler extends Tapable {
2728 constructor ( context ) {
@@ -134,12 +135,7 @@ class Compiler extends Tapable {
134135 }
135136
136137 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 ( ) ) ;
143139
144140 this . running = true ;
145141 this . fileTimestamps = new Map ( ) ;
@@ -148,12 +144,7 @@ class Compiler extends Tapable {
148144 }
149145
150146 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 ( ) ) ;
157148
158149 const finalCallback = ( err , stats ) => {
159150 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;
1010const asyncLib = require ( "neo-async" ) ;
1111const MultiWatching = require ( "./MultiWatching" ) ;
1212const MultiStats = require ( "./MultiStats" ) ;
13+ const ConcurrentCompilationError = require ( "./ConcurrentCompilationError" ) ;
1314
1415module . exports = class MultiCompiler extends Tapable {
1516 constructor ( compilers ) {
@@ -186,12 +187,7 @@ module.exports = class MultiCompiler extends Tapable {
186187 }
187188
188189 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 ( ) ) ;
195191
196192 const finalHandler = ( err , stats ) => {
197193 this . running = false ;
@@ -245,12 +241,7 @@ module.exports = class MultiCompiler extends Tapable {
245241 }
246242
247243 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 ( ) ) ;
254245
255246 const finalCallback = ( err , stats ) => {
256247 this . running = false ;
You can’t perform that action at this time.
0 commit comments