File tree 6 files changed +20
-19
lines changed
angular_devkit/build_angular/src
6 files changed +20
-19
lines changed Original file line number Diff line number Diff line change 6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import { Compilation , WebpackError } from 'webpack' ;
9
+ import type { Compilation } from 'webpack' ;
10
10
11
11
export function addWarning ( compilation : Compilation , message : string ) : void {
12
- compilation . warnings . push ( new WebpackError ( message ) ) ;
12
+ compilation . warnings . push ( new compilation . compiler . webpack . WebpackError ( message ) ) ;
13
13
}
14
14
15
15
export function addError ( compilation : Compilation , message : string ) : void {
16
- compilation . errors . push ( new WebpackError ( message ) ) ;
16
+ compilation . errors . push ( new compilation . compiler . webpack . WebpackError ( message ) ) ;
17
17
}
Original file line number Diff line number Diff line change 9
9
import * as fs from 'fs' ;
10
10
import MiniCssExtractPlugin from 'mini-css-extract-plugin' ;
11
11
import * as path from 'path' ;
12
- import { Configuration , RuleSetUseItem , WebpackError } from 'webpack' ;
12
+ import type { Configuration , RuleSetUseItem } from 'webpack' ;
13
13
import { StyleElement } from '../../builders/browser/schema' ;
14
14
import { SassWorkerImplementation } from '../../sass/sass-service' ;
15
15
import { WebpackConfigOptions } from '../../utils/build-options' ;
16
+ import { addWarning } from '../../utils/webpack-diagnostics' ;
16
17
import {
17
18
AnyComponentStyleBudgetChecker ,
18
19
PostcssCliResources ,
@@ -112,7 +113,7 @@ export function getStylesConfig(wco: WebpackConfigOptions): Configuration {
112
113
113
114
compiler . hooks . afterCompile . tap ( 'sass-worker' , ( compilation ) => {
114
115
for ( const message of sassTildeUsageMessage ) {
115
- compilation . warnings . push ( new WebpackError ( message ) ) ;
116
+ addWarning ( compilation , message ) ;
116
117
}
117
118
118
119
sassTildeUsageMessage . clear ( ) ;
Original file line number Diff line number Diff line change 7
7
*/
8
8
9
9
import Piscina from 'piscina' ;
10
- import { ScriptTarget } from 'typescript' ;
11
10
import type { Compiler , sources } from 'webpack' ;
12
11
import { maxWorkers } from '../../utils/environment-options' ;
13
12
import { transformSupportedBrowsersToTargets } from '../../utils/esbuild-targets' ;
13
+ import { addError } from '../../utils/webpack-diagnostics' ;
14
14
import { EsbuildExecutor } from './esbuild-executor' ;
15
15
import type { OptimizeRequestOptions } from './javascript-optimizer-worker' ;
16
16
@@ -220,10 +220,10 @@ export class JavaScriptOptimizerPlugin {
220
220
} ) ;
221
221
} ,
222
222
( error ) => {
223
- const optimizationError = new compiler . webpack . WebpackError (
223
+ addError (
224
+ compilation ,
224
225
`Optimization error [${ name } ]: ${ error . stack || error . message } ` ,
225
226
) ;
226
- compilation . errors . push ( optimizationError ) ;
227
227
} ,
228
228
) ,
229
229
) ;
Original file line number Diff line number Diff line change 9
9
import { promisify } from 'util' ;
10
10
import { Compiler } from 'webpack' ;
11
11
import { brotliCompress } from 'zlib' ;
12
+ import { addWarning } from '../../utils/webpack-diagnostics' ;
12
13
13
14
const brotliCompressAsync = promisify ( brotliCompress ) ;
14
15
@@ -49,10 +50,9 @@ export class TransferSizePlugin {
49
50
) ;
50
51
} )
51
52
. catch ( ( error ) => {
52
- compilation . warnings . push (
53
- new compilation . compiler . webpack . WebpackError (
54
- `Unable to calculate estimated transfer size for '${ assetName } '. Reason: ${ error . message } ` ,
55
- ) ,
53
+ addWarning (
54
+ compilation ,
55
+ `Unable to calculate estimated transfer size for '${ assetName } '. Reason: ${ error . message } ` ,
56
56
) ;
57
57
} ) ,
58
58
) ;
Original file line number Diff line number Diff line change @@ -189,12 +189,11 @@ export class AngularWebpackPlugin {
189
189
try {
190
190
this . setupCompilation ( compilation , compilationState ) ;
191
191
} catch ( error ) {
192
- compilation . errors . push (
193
- new WebpackError (
194
- `Failed to initialize Angular compilation - ${
195
- error instanceof Error ? error . message : error
196
- } `,
197
- ) ,
192
+ addError (
193
+ compilation ,
194
+ `Failed to initialize Angular compilation - ${
195
+ error instanceof Error ? error . message : error
196
+ } `,
198
197
) ;
199
198
}
200
199
} ) ;
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import assert from 'assert';
10
10
import * as path from 'path' ;
11
11
import * as vm from 'vm' ;
12
12
import type { Asset , Compilation } from 'webpack' ;
13
+ import { addError } from './ivy/diagnostics' ;
13
14
import { normalizePath } from './ivy/paths' ;
14
15
import {
15
16
CompilationWithInlineAngularResource ,
@@ -212,7 +213,7 @@ export class WebpackResourceLoader {
212
213
} catch ( error ) {
213
214
assert ( error instanceof Error , 'catch clause variable is not an Error instance' ) ;
214
215
// Use compilation errors, as otherwise webpack will choke
215
- compilation . errors . push ( new WebpackError ( error . message ) ) ;
216
+ addError ( compilation , error . message ) ;
216
217
}
217
218
} ) ;
218
219
} ,
You can’t perform that action at this time.
0 commit comments