@angular-devkit/build-angular 15.0.4 → 15.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/webpack/plugins/javascript-optimizer-plugin.js +7 -1
- package/src/webpack/plugins/javascript-optimizer-worker.d.ts +6 -0
- package/src/webpack/plugins/javascript-optimizer-worker.js +40 -17
- package/src/builders/browser-esbuild/worker-angular-compilation.d.ts +0 -0
- package/src/builders/browser-esbuild/worker-angular-compilation.js +0 -59
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "15.0.
|
|
3
|
+
"version": "15.0.5",
|
|
4
4
|
"description": "Angular Webpack Build Facade",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"typings": "src/index.d.ts",
|
|
7
7
|
"builders": "builders.json",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@ampproject/remapping": "2.2.0",
|
|
10
|
-
"@angular-devkit/architect": "0.1500.
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1500.
|
|
12
|
-
"@angular-devkit/core": "15.0.
|
|
10
|
+
"@angular-devkit/architect": "0.1500.5",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1500.5",
|
|
12
|
+
"@angular-devkit/core": "15.0.5",
|
|
13
13
|
"@babel/core": "7.20.2",
|
|
14
14
|
"@babel/generator": "7.20.4",
|
|
15
15
|
"@babel/helper-annotate-as-pure": "7.18.6",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@babel/runtime": "7.20.1",
|
|
21
21
|
"@babel/template": "7.18.10",
|
|
22
22
|
"@discoveryjs/json-ext": "0.5.7",
|
|
23
|
-
"@ngtools/webpack": "15.0.
|
|
23
|
+
"@ngtools/webpack": "15.0.5",
|
|
24
24
|
"ansi-colors": "4.1.3",
|
|
25
25
|
"autoprefixer": "10.4.13",
|
|
26
26
|
"babel-loader": "9.1.0",
|
|
@@ -130,7 +130,13 @@ class JavaScriptOptimizerPlugin {
|
|
|
130
130
|
},
|
|
131
131
|
options: optimizeOptions,
|
|
132
132
|
})
|
|
133
|
-
.then(({ code, name, map }) => {
|
|
133
|
+
.then(async ({ code, name, map, errors }) => {
|
|
134
|
+
if (errors === null || errors === void 0 ? void 0 : errors.length) {
|
|
135
|
+
for (const error of errors) {
|
|
136
|
+
(0, webpack_diagnostics_1.addError)(compilation, `Optimization error [${name}]: ${error}`);
|
|
137
|
+
}
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
134
140
|
const optimizedAsset = map
|
|
135
141
|
? new SourceMapSource(code, name, map)
|
|
136
142
|
: new OriginalSource(code, name);
|
|
@@ -81,8 +81,14 @@ interface OptimizeRequest {
|
|
|
81
81
|
* Handles optimization requests sent from the main thread via the `JavaScriptOptimizerPlugin`.
|
|
82
82
|
*/
|
|
83
83
|
export default function ({ asset, options }: OptimizeRequest): Promise<{
|
|
84
|
+
name: string;
|
|
85
|
+
errors: string[];
|
|
86
|
+
code?: undefined;
|
|
87
|
+
map?: undefined;
|
|
88
|
+
} | {
|
|
84
89
|
name: string;
|
|
85
90
|
code: string;
|
|
86
91
|
map: import("@ampproject/remapping/dist/types/source-map").default | undefined;
|
|
92
|
+
errors?: undefined;
|
|
87
93
|
}>;
|
|
88
94
|
export {};
|
|
@@ -25,6 +25,13 @@ let esbuild;
|
|
|
25
25
|
async function default_1({ asset, options }) {
|
|
26
26
|
// esbuild is used as a first pass
|
|
27
27
|
const esbuildResult = await optimizeWithEsbuild(asset.code, asset.name, options);
|
|
28
|
+
if (isEsBuildFailure(esbuildResult)) {
|
|
29
|
+
return {
|
|
30
|
+
name: asset.name,
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
32
|
+
errors: await esbuild.formatMessages(esbuildResult.errors, { kind: 'error' }),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
28
35
|
// terser is used as a second pass
|
|
29
36
|
const terserResult = await optimizeWithTerser(asset.name, esbuildResult.code, options.sourcemap, options.advanced);
|
|
30
37
|
// Merge intermediate sourcemaps with input sourcemap if enabled
|
|
@@ -57,23 +64,31 @@ async function optimizeWithEsbuild(content, name, options) {
|
|
|
57
64
|
if (!esbuild) {
|
|
58
65
|
esbuild = new esbuild_executor_1.EsbuildExecutor(options.alwaysUseWasm);
|
|
59
66
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
try {
|
|
68
|
+
return await esbuild.transform(content, {
|
|
69
|
+
minifyIdentifiers: !options.keepIdentifierNames,
|
|
70
|
+
minifySyntax: true,
|
|
71
|
+
// NOTE: Disabling whitespace ensures unused pure annotations are kept
|
|
72
|
+
minifyWhitespace: false,
|
|
73
|
+
pure: ['forwardRef'],
|
|
74
|
+
legalComments: options.removeLicenses ? 'none' : 'inline',
|
|
75
|
+
sourcefile: name,
|
|
76
|
+
sourcemap: options.sourcemap && 'external',
|
|
77
|
+
define: options.define,
|
|
78
|
+
// This option should always be disabled for browser builds as we don't rely on `.name`
|
|
79
|
+
// and causes deadcode to be retained which makes `NG_BUILD_MANGLE` unusable to investigate tree-shaking issues.
|
|
80
|
+
// We enable `keepNames` only for server builds as Domino relies on `.name`.
|
|
81
|
+
// Once we no longer rely on Domino for SSR we should be able to remove this.
|
|
82
|
+
keepNames: options.keepNames,
|
|
83
|
+
target: options.target,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
if (isEsBuildFailure(error)) {
|
|
88
|
+
return error;
|
|
89
|
+
}
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
77
92
|
}
|
|
78
93
|
/**
|
|
79
94
|
* Optimizes a JavaScript asset using terser.
|
|
@@ -114,3 +129,11 @@ async function optimizeWithTerser(name, code, sourcemaps, advanced) {
|
|
|
114
129
|
}
|
|
115
130
|
return { code: result.code, map: result.map };
|
|
116
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Determines if an unknown value is an esbuild BuildFailure error object thrown by esbuild.
|
|
134
|
+
* @param value A potential esbuild BuildFailure error object.
|
|
135
|
+
* @returns `true` if the object is determined to be a BuildFailure object; otherwise, `false`.
|
|
136
|
+
*/
|
|
137
|
+
function isEsBuildFailure(value) {
|
|
138
|
+
return !!value && typeof value === 'object' && 'errors' in value && 'warnings' in value;
|
|
139
|
+
}
|
|
File without changes
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// /**
|
|
3
|
-
// * @license
|
|
4
|
-
// * Copyright Google LLC All Rights Reserved.
|
|
5
|
-
// *
|
|
6
|
-
// * Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
// * found in the LICENSE file at https://angular.io/license
|
|
8
|
-
// */
|
|
9
|
-
// import type ng from '@angular/compiler-cli';
|
|
10
|
-
// import { Worker } from 'node:worker_threads';
|
|
11
|
-
// import { AngularHostOptions } from './angular-host';
|
|
12
|
-
// interface Message {
|
|
13
|
-
// id: number;
|
|
14
|
-
// }
|
|
15
|
-
// interface InitializeRequest extends Message {
|
|
16
|
-
// tsconfig: string;
|
|
17
|
-
// tsCallbackId: number;
|
|
18
|
-
// tcoCallbackId?: number;
|
|
19
|
-
// }
|
|
20
|
-
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
-
// type ResponseCallback = (...args: any[]) => void;
|
|
22
|
-
// let callbackIds = 0;
|
|
23
|
-
// export class WorkerAngularCompilation {
|
|
24
|
-
// #worker: Worker;
|
|
25
|
-
// #callbacks = new Map<number, ResponseCallback>();
|
|
26
|
-
// constructor() {
|
|
27
|
-
// this.#worker = new Worker(require.resolve('./compilation-worker'));
|
|
28
|
-
// }
|
|
29
|
-
// async initialize(
|
|
30
|
-
// tsconfig: string,
|
|
31
|
-
// hostOptions: AngularHostOptions,
|
|
32
|
-
// transformCompilerOptions?: (compilerOptions: ng.CompilerOptions) => ng.CompilerOptions,
|
|
33
|
-
// ): Promise<{ compilerOptions: ng.CompilerOptions }> {
|
|
34
|
-
// const request: InitializeRequest = {
|
|
35
|
-
// id: ++callbackIds,
|
|
36
|
-
// tsconfig,
|
|
37
|
-
// tsCallbackId: ++callbackIds,
|
|
38
|
-
// };
|
|
39
|
-
// this.#callbacks.set(request.tsCallbackId, () => {
|
|
40
|
-
// hostOptions.transformStylesheet();
|
|
41
|
-
// });
|
|
42
|
-
// if (transformCompilerOptions) {
|
|
43
|
-
// request.tcoCallbackId = ++callbackIds;
|
|
44
|
-
// this.#callbacks.set(request.tcoCallbackId, (id: number, compilerOptions) => {
|
|
45
|
-
// try {
|
|
46
|
-
// transformCompilerOptions(compilerOptions);
|
|
47
|
-
// } catch (e) {
|
|
48
|
-
// }
|
|
49
|
-
// });
|
|
50
|
-
// }
|
|
51
|
-
// const result = new Promise<{ compilerOptions: ng.CompilerOptions }>((resolve, reject) => {
|
|
52
|
-
// this.#callbacks.set(request.id, () => {
|
|
53
|
-
// resolve({});
|
|
54
|
-
// });
|
|
55
|
-
// });
|
|
56
|
-
// this.#worker.postMessage(request);
|
|
57
|
-
// return result;
|
|
58
|
-
// }
|
|
59
|
-
// }
|