@@ -12,7 +12,6 @@ import {
12
12
NamedBundle ,
13
13
} from './public/Bundle' ;
14
14
import WorkerFarm , { bus } from '@parcel/workers' ;
15
- import ParcelConfig from './ParcelConfig' ;
16
15
import logger , {
17
16
patchConsole ,
18
17
unpatchConsole ,
@@ -24,23 +23,24 @@ import BundleGraph from './BundleGraph';
24
23
import { tracer , PluginTracer } from '@parcel/profiler' ;
25
24
26
25
type Opts = { |
27
- config : ParcelConfig ,
28
26
options : ParcelOptions ,
27
+ reporters : Array < LoadedPlugin < Reporter >> ,
29
28
workerFarm : WorkerFarm ,
30
29
| } ;
31
30
32
31
const instances : Set < ReporterRunner > = new Set();
33
32
34
33
export default class ReporterRunner {
35
34
workerFarm : WorkerFarm ;
36
- config: ParcelConfig ;
35
+ errors: Error [ ] ;
37
36
options: ParcelOptions ;
38
37
pluginOptions: PluginOptions ;
39
38
reporters: Array < LoadedPlugin < Reporter >> ;
40
39
41
40
constructor ( opts : Opts ) {
42
- this . config = opts . config ;
41
+ this . errors = [ ] ;
43
42
this . options = opts . options ;
43
+ this . reporters = opts . reporters ;
44
44
this . workerFarm = opts . workerFarm ;
45
45
this . pluginOptions = new PluginOptions ( this . options ) ;
46
46
@@ -86,39 +86,33 @@ export default class ReporterRunner {
86
86
} ;
87
87
88
88
async report ( event : ReporterEvent ) {
89
- // We should catch all errors originating from reporter plugins to prevent infinite loops
90
- try {
91
- let reporters = this . reporters ;
92
- if ( ! reporters ) {
93
- this . reporters = await this . config . getReporters ( ) ;
94
- reporters = this . reporters ;
95
- }
96
-
97
- for ( let reporter of this . reporters ) {
98
- let measurement ;
99
- try {
100
- // To avoid an infinite loop we don't measure trace events, as they'll
101
- // result in another trace!
102
- if ( event . type !== 'trace' ) {
103
- measurement = tracer . createMeasurement ( reporter . name , 'reporter' ) ;
104
- }
105
- await reporter . plugin . report ( {
106
- event,
107
- options : this . pluginOptions ,
108
- logger : new PluginLogger ( { origin : reporter . name } ) ,
109
- tracer : new PluginTracer ( {
110
- origin : reporter . name ,
111
- category : 'reporter' ,
112
- } ) ,
113
- } ) ;
114
- } catch ( reportError ) {
89
+ for ( let reporter of this . reporters ) {
90
+ let measurement ;
91
+ try {
92
+ // To avoid an infinite loop we don't measure trace events, as they'll
93
+ // result in another trace!
94
+ if ( event . type !== 'trace' ) {
95
+ measurement = tracer . createMeasurement ( reporter . name , 'reporter' ) ;
96
+ }
97
+ await reporter . plugin . report ( {
98
+ event,
99
+ options : this . pluginOptions ,
100
+ logger : new PluginLogger ( { origin : reporter . name } ) ,
101
+ tracer : new PluginTracer ( {
102
+ origin : reporter . name ,
103
+ category : 'reporter' ,
104
+ } ) ,
105
+ } ) ;
106
+ } catch ( reportError ) {
107
+ if ( event . type !== 'buildSuccess' ) {
108
+ // This will be captured by consumers
115
109
INTERNAL_ORIGINAL_CONSOLE . error ( reportError ) ;
116
- } finally {
117
- measurement && measurement . end ( ) ;
118
110
}
111
+
112
+ this . errors . push ( reportError ) ;
113
+ } finally {
114
+ measurement && measurement . end ( ) ;
119
115
}
120
- } catch ( err ) {
121
- INTERNAL_ORIGINAL_CONSOLE . error ( err ) ;
122
116
}
123
117
}
124
118
0 commit comments