@angular-devkit/build-angular 15.0.0-next.3 → 15.0.0-next.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 +19 -18
- package/src/builders/app-shell/index.js +39 -40
- package/src/builders/app-shell/render-worker.d.ts +36 -0
- package/src/builders/app-shell/render-worker.js +82 -0
- package/src/builders/browser/index.d.ts +2 -0
- package/src/builders/browser/index.js +38 -19
- package/src/builders/browser/schema.json +2 -2
- package/src/builders/browser-esbuild/compiler-plugin.d.ts +10 -2
- package/src/builders/browser-esbuild/compiler-plugin.js +211 -115
- package/src/builders/browser-esbuild/esbuild.d.ts +4 -3
- package/src/builders/browser-esbuild/esbuild.js +12 -6
- package/src/builders/browser-esbuild/experimental-warnings.js +0 -3
- package/src/builders/browser-esbuild/index.d.ts +3 -3
- package/src/builders/browser-esbuild/index.js +145 -87
- package/src/builders/browser-esbuild/options.d.ts +26 -4
- package/src/builders/browser-esbuild/options.js +56 -5
- package/src/builders/browser-esbuild/profiling.d.ts +11 -0
- package/src/builders/browser-esbuild/profiling.js +64 -0
- package/src/builders/browser-esbuild/sass-plugin.js +11 -5
- package/src/builders/browser-esbuild/schema.json +2 -2
- package/src/builders/browser-esbuild/watcher.d.ts +23 -0
- package/src/builders/browser-esbuild/watcher.js +93 -0
- package/src/builders/dev-server/index.d.ts +2 -0
- package/src/builders/dev-server/index.js +10 -7
- package/src/builders/karma/find-tests-plugin.js +1 -0
- package/src/builders/karma/index.d.ts +1 -1
- package/src/builders/karma/index.js +50 -9
- package/src/builders/karma/schema.d.ts +1 -1
- package/src/builders/karma/schema.json +1 -1
- package/src/builders/server/schema.json +1 -1
- package/src/utils/environment-options.d.ts +1 -0
- package/src/utils/environment-options.js +3 -1
- package/src/utils/process-bundle.js +1 -1
- package/src/utils/service-worker.d.ts +3 -0
- package/src/utils/service-worker.js +29 -2
- package/src/webpack/configs/common.js +31 -7
- package/src/webpack/configs/index.d.ts +0 -1
- package/src/webpack/configs/index.js +0 -1
- package/src/webpack/configs/styles.d.ts +1 -7
- package/src/webpack/configs/styles.js +70 -60
- package/src/webpack/plugins/occurrences-plugin.d.ts +18 -0
- package/src/webpack/plugins/occurrences-plugin.js +79 -0
- package/src/webpack/plugins/scripts-webpack-plugin.js +24 -5
- package/src/webpack/plugins/styles-webpack-plugin.d.ts +19 -0
- package/src/webpack/plugins/styles-webpack-plugin.js +71 -0
- package/src/webpack/utils/helpers.d.ts +5 -1
- package/src/webpack/utils/helpers.js +24 -14
- package/src/webpack/utils/stats.d.ts +13 -8
- package/src/webpack/utils/stats.js +57 -6
- package/src/webpack/configs/analytics.d.ts +0 -11
- package/src/webpack/configs/analytics.js +0 -27
- package/src/webpack/plugins/analytics.d.ts +0 -66
- package/src/webpack/plugins/analytics.js +0 -236
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { BuilderContext } from '@angular-devkit/architect';
|
|
9
|
-
import { Configuration } from 'webpack';
|
|
10
|
-
import { WebpackConfigOptions } from '../../utils/build-options';
|
|
11
|
-
export declare function getAnalyticsConfig(wco: WebpackConfigOptions, context: BuilderContext): Configuration;
|
|
@@ -1,27 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.getAnalyticsConfig = void 0;
|
|
11
|
-
const analytics_1 = require("../plugins/analytics");
|
|
12
|
-
function getAnalyticsConfig(wco, context) {
|
|
13
|
-
if (!context.analytics) {
|
|
14
|
-
return {};
|
|
15
|
-
}
|
|
16
|
-
// If there's analytics, add our plugin. Otherwise no need to slow down the build.
|
|
17
|
-
let category = 'build';
|
|
18
|
-
if (context.builder) {
|
|
19
|
-
// We already vetted that this is a "safe" package, otherwise the analytics would be noop.
|
|
20
|
-
category = context.builder.builderName.split(':')[1] || context.builder.builderName || 'build';
|
|
21
|
-
}
|
|
22
|
-
// The category is the builder name if it's an angular builder.
|
|
23
|
-
return {
|
|
24
|
-
plugins: [new analytics_1.NgBuildAnalyticsPlugin(wco.projectRoot, context.analytics, category)],
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
exports.getAnalyticsConfig = getAnalyticsConfig;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { analytics } from '@angular-devkit/core';
|
|
9
|
-
import { Compilation, Compiler, Module, NormalModule, Stats } from 'webpack';
|
|
10
|
-
/**
|
|
11
|
-
* Faster than using a RegExp, so we use this to count occurences in source code.
|
|
12
|
-
* @param source The source to look into.
|
|
13
|
-
* @param match The match string to look for.
|
|
14
|
-
* @param wordBreak Whether to check for word break before and after a match was found.
|
|
15
|
-
* @return The number of matches found.
|
|
16
|
-
* @private
|
|
17
|
-
*/
|
|
18
|
-
export declare function countOccurrences(source: string, match: string, wordBreak?: boolean): number;
|
|
19
|
-
/**
|
|
20
|
-
* Holder of statistics related to the build.
|
|
21
|
-
*/
|
|
22
|
-
declare class AnalyticsBuildStats {
|
|
23
|
-
errors: string[];
|
|
24
|
-
numberOfNgOnInit: number;
|
|
25
|
-
numberOfComponents: number;
|
|
26
|
-
initialChunkSize: number;
|
|
27
|
-
totalChunkCount: number;
|
|
28
|
-
totalChunkSize: number;
|
|
29
|
-
lazyChunkCount: number;
|
|
30
|
-
lazyChunkSize: number;
|
|
31
|
-
assetCount: number;
|
|
32
|
-
assetSize: number;
|
|
33
|
-
polyfillSize: number;
|
|
34
|
-
cssSize: number;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Analytics plugin that reports the analytics we want from the CLI.
|
|
38
|
-
*/
|
|
39
|
-
export declare class NgBuildAnalyticsPlugin {
|
|
40
|
-
protected _projectRoot: string;
|
|
41
|
-
protected _analytics: analytics.Analytics;
|
|
42
|
-
protected _category: string;
|
|
43
|
-
protected _built: boolean;
|
|
44
|
-
protected _stats: AnalyticsBuildStats;
|
|
45
|
-
constructor(_projectRoot: string, _analytics: analytics.Analytics, _category: string);
|
|
46
|
-
protected _reset(): void;
|
|
47
|
-
protected _getMetrics(stats: Stats): (string | number)[];
|
|
48
|
-
protected _getDimensions(): (string | number | boolean)[];
|
|
49
|
-
protected _reportBuildMetrics(stats: Stats): void;
|
|
50
|
-
protected _reportRebuildMetrics(stats: Stats): void;
|
|
51
|
-
protected _checkTsNormalModule(module: NormalModule): void;
|
|
52
|
-
protected _collectErrors(stats: Stats): void;
|
|
53
|
-
protected _collectBundleStats(compilation: Compilation): void;
|
|
54
|
-
/** **********************************************************************************************
|
|
55
|
-
* The next section is all the different Webpack hooks for this plugin.
|
|
56
|
-
*/
|
|
57
|
-
/**
|
|
58
|
-
* Reports a succeed module.
|
|
59
|
-
* @private
|
|
60
|
-
*/
|
|
61
|
-
protected _succeedModule(module: Module): void;
|
|
62
|
-
protected _compilation(compiler: Compiler, compilation: Compilation): void;
|
|
63
|
-
protected _done(stats: Stats): void;
|
|
64
|
-
apply(compiler: Compiler): void;
|
|
65
|
-
}
|
|
66
|
-
export {};
|
|
@@ -1,236 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.NgBuildAnalyticsPlugin = exports.countOccurrences = void 0;
|
|
11
|
-
const core_1 = require("@angular-devkit/core");
|
|
12
|
-
const webpack_1 = require("webpack");
|
|
13
|
-
const webpackAllErrorMessageRe = /^([^(]+)\(\d+,\d\): (.*)$/gm;
|
|
14
|
-
const webpackTsErrorMessageRe = /^[^(]+\(\d+,\d\): error (TS\d+):/;
|
|
15
|
-
/**
|
|
16
|
-
* Faster than using a RegExp, so we use this to count occurences in source code.
|
|
17
|
-
* @param source The source to look into.
|
|
18
|
-
* @param match The match string to look for.
|
|
19
|
-
* @param wordBreak Whether to check for word break before and after a match was found.
|
|
20
|
-
* @return The number of matches found.
|
|
21
|
-
* @private
|
|
22
|
-
*/
|
|
23
|
-
function countOccurrences(source, match, wordBreak = false) {
|
|
24
|
-
if (match.length == 0) {
|
|
25
|
-
return source.length + 1;
|
|
26
|
-
}
|
|
27
|
-
let count = 0;
|
|
28
|
-
// We condition here so branch prediction happens out of the loop, not in it.
|
|
29
|
-
if (wordBreak) {
|
|
30
|
-
const re = /\w/;
|
|
31
|
-
for (let pos = source.lastIndexOf(match); pos >= 0; pos = source.lastIndexOf(match, pos)) {
|
|
32
|
-
if (!(re.test(source[pos - 1] || '') || re.test(source[pos + match.length] || ''))) {
|
|
33
|
-
count++; // 1 match, AH! AH! AH! 2 matches, AH! AH! AH!
|
|
34
|
-
}
|
|
35
|
-
pos -= match.length;
|
|
36
|
-
if (pos < 0) {
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
for (let pos = source.lastIndexOf(match); pos >= 0; pos = source.lastIndexOf(match, pos)) {
|
|
43
|
-
count++; // 1 match, AH! AH! AH! 2 matches, AH! AH! AH!
|
|
44
|
-
pos -= match.length;
|
|
45
|
-
if (pos < 0) {
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return count;
|
|
51
|
-
}
|
|
52
|
-
exports.countOccurrences = countOccurrences;
|
|
53
|
-
/**
|
|
54
|
-
* Holder of statistics related to the build.
|
|
55
|
-
*/
|
|
56
|
-
class AnalyticsBuildStats {
|
|
57
|
-
constructor() {
|
|
58
|
-
this.errors = [];
|
|
59
|
-
this.numberOfNgOnInit = 0;
|
|
60
|
-
this.numberOfComponents = 0;
|
|
61
|
-
this.initialChunkSize = 0;
|
|
62
|
-
this.totalChunkCount = 0;
|
|
63
|
-
this.totalChunkSize = 0;
|
|
64
|
-
this.lazyChunkCount = 0;
|
|
65
|
-
this.lazyChunkSize = 0;
|
|
66
|
-
this.assetCount = 0;
|
|
67
|
-
this.assetSize = 0;
|
|
68
|
-
this.polyfillSize = 0;
|
|
69
|
-
this.cssSize = 0;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Analytics plugin that reports the analytics we want from the CLI.
|
|
74
|
-
*/
|
|
75
|
-
class NgBuildAnalyticsPlugin {
|
|
76
|
-
constructor(_projectRoot, _analytics, _category) {
|
|
77
|
-
this._projectRoot = _projectRoot;
|
|
78
|
-
this._analytics = _analytics;
|
|
79
|
-
this._category = _category;
|
|
80
|
-
this._built = false;
|
|
81
|
-
this._stats = new AnalyticsBuildStats();
|
|
82
|
-
}
|
|
83
|
-
_reset() {
|
|
84
|
-
this._stats = new AnalyticsBuildStats();
|
|
85
|
-
}
|
|
86
|
-
_getMetrics(stats) {
|
|
87
|
-
const startTime = +(stats.startTime || 0);
|
|
88
|
-
const endTime = +(stats.endTime || 0);
|
|
89
|
-
const metrics = [];
|
|
90
|
-
metrics[core_1.analytics.NgCliAnalyticsMetrics.BuildTime] = endTime - startTime;
|
|
91
|
-
metrics[core_1.analytics.NgCliAnalyticsMetrics.NgOnInitCount] = this._stats.numberOfNgOnInit;
|
|
92
|
-
metrics[core_1.analytics.NgCliAnalyticsMetrics.NgComponentCount] = this._stats.numberOfComponents;
|
|
93
|
-
metrics[core_1.analytics.NgCliAnalyticsMetrics.InitialChunkSize] = this._stats.initialChunkSize;
|
|
94
|
-
metrics[core_1.analytics.NgCliAnalyticsMetrics.TotalChunkCount] = this._stats.totalChunkCount;
|
|
95
|
-
metrics[core_1.analytics.NgCliAnalyticsMetrics.TotalChunkSize] = this._stats.totalChunkSize;
|
|
96
|
-
metrics[core_1.analytics.NgCliAnalyticsMetrics.LazyChunkCount] = this._stats.lazyChunkCount;
|
|
97
|
-
metrics[core_1.analytics.NgCliAnalyticsMetrics.LazyChunkSize] = this._stats.lazyChunkSize;
|
|
98
|
-
metrics[core_1.analytics.NgCliAnalyticsMetrics.AssetCount] = this._stats.assetCount;
|
|
99
|
-
metrics[core_1.analytics.NgCliAnalyticsMetrics.AssetSize] = this._stats.assetSize;
|
|
100
|
-
metrics[core_1.analytics.NgCliAnalyticsMetrics.PolyfillSize] = this._stats.polyfillSize;
|
|
101
|
-
metrics[core_1.analytics.NgCliAnalyticsMetrics.CssSize] = this._stats.cssSize;
|
|
102
|
-
return metrics;
|
|
103
|
-
}
|
|
104
|
-
_getDimensions() {
|
|
105
|
-
const dimensions = [];
|
|
106
|
-
if (this._stats.errors.length) {
|
|
107
|
-
// Adding commas before and after so the regex are easier to define filters.
|
|
108
|
-
dimensions[core_1.analytics.NgCliAnalyticsDimensions.BuildErrors] = `,${this._stats.errors.join()},`;
|
|
109
|
-
}
|
|
110
|
-
return dimensions;
|
|
111
|
-
}
|
|
112
|
-
_reportBuildMetrics(stats) {
|
|
113
|
-
const dimensions = this._getDimensions();
|
|
114
|
-
const metrics = this._getMetrics(stats);
|
|
115
|
-
this._analytics.event(this._category, 'build', { dimensions, metrics });
|
|
116
|
-
}
|
|
117
|
-
_reportRebuildMetrics(stats) {
|
|
118
|
-
const dimensions = this._getDimensions();
|
|
119
|
-
const metrics = this._getMetrics(stats);
|
|
120
|
-
this._analytics.event(this._category, 'rebuild', { dimensions, metrics });
|
|
121
|
-
}
|
|
122
|
-
_checkTsNormalModule(module) {
|
|
123
|
-
const originalSource = module.originalSource();
|
|
124
|
-
if (!originalSource) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const originalContent = originalSource.source().toString();
|
|
128
|
-
// PLEASE REMEMBER:
|
|
129
|
-
// We're dealing with ES5 _or_ ES2015 JavaScript at this point (we don't know for sure).
|
|
130
|
-
// Just count the ngOnInit occurences. Comments/Strings/calls occurences should be sparse
|
|
131
|
-
// so we just consider them within the margin of error. We do break on word break though.
|
|
132
|
-
this._stats.numberOfNgOnInit += countOccurrences(originalContent, 'ngOnInit', true);
|
|
133
|
-
// Count the number of `Component({` strings (case sensitive), which happens in __decorate().
|
|
134
|
-
this._stats.numberOfComponents += countOccurrences(originalContent, 'Component({');
|
|
135
|
-
// For Ivy we just count ɵcmp.
|
|
136
|
-
this._stats.numberOfComponents += countOccurrences(originalContent, '.ɵcmp', true);
|
|
137
|
-
// for ascii_only true
|
|
138
|
-
this._stats.numberOfComponents += countOccurrences(originalContent, '.\u0275cmp', true);
|
|
139
|
-
}
|
|
140
|
-
_collectErrors(stats) {
|
|
141
|
-
if (stats.hasErrors()) {
|
|
142
|
-
for (const errObject of stats.compilation.errors) {
|
|
143
|
-
if (errObject instanceof Error) {
|
|
144
|
-
const allErrors = errObject.message.match(webpackAllErrorMessageRe);
|
|
145
|
-
for (const err of [...(allErrors || [])].slice(1)) {
|
|
146
|
-
const message = (err.match(webpackTsErrorMessageRe) || [])[1];
|
|
147
|
-
if (message) {
|
|
148
|
-
// At this point this should be a TS1234.
|
|
149
|
-
this._stats.errors.push(message);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
_collectBundleStats(compilation) {
|
|
157
|
-
var _a, _b;
|
|
158
|
-
const chunkAssets = new Set();
|
|
159
|
-
for (const chunk of compilation.chunks) {
|
|
160
|
-
if (!chunk.rendered || chunk.files.size === 0) {
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
const firstFile = Array.from(chunk.files)[0];
|
|
164
|
-
const size = (_b = (_a = compilation.getAsset(firstFile)) === null || _a === void 0 ? void 0 : _a.source.size()) !== null && _b !== void 0 ? _b : 0;
|
|
165
|
-
chunkAssets.add(firstFile);
|
|
166
|
-
if (chunk.canBeInitial()) {
|
|
167
|
-
this._stats.initialChunkSize += size;
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
this._stats.lazyChunkCount++;
|
|
171
|
-
this._stats.lazyChunkSize += size;
|
|
172
|
-
}
|
|
173
|
-
this._stats.totalChunkCount++;
|
|
174
|
-
this._stats.totalChunkSize += size;
|
|
175
|
-
if (firstFile.endsWith('.css')) {
|
|
176
|
-
this._stats.cssSize += size;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
for (const asset of compilation.getAssets()) {
|
|
180
|
-
// Only count non-JavaScript related files
|
|
181
|
-
if (chunkAssets.has(asset.name)) {
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
this._stats.assetSize += asset.source.size();
|
|
185
|
-
this._stats.assetCount++;
|
|
186
|
-
if (asset.name == 'polyfill') {
|
|
187
|
-
this._stats.polyfillSize += asset.source.size();
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
/** **********************************************************************************************
|
|
192
|
-
* The next section is all the different Webpack hooks for this plugin.
|
|
193
|
-
*/
|
|
194
|
-
/**
|
|
195
|
-
* Reports a succeed module.
|
|
196
|
-
* @private
|
|
197
|
-
*/
|
|
198
|
-
_succeedModule(module) {
|
|
199
|
-
// Only report NormalModule instances.
|
|
200
|
-
if (!(module instanceof webpack_1.NormalModule)) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
// Only reports modules that are part of the user's project. We also don't do node_modules.
|
|
204
|
-
// There is a chance that someone name a file path `hello_node_modules` or something and we
|
|
205
|
-
// will ignore that file for the purpose of gathering, but we're willing to take the risk.
|
|
206
|
-
if (!module.resource ||
|
|
207
|
-
!module.resource.startsWith(this._projectRoot) ||
|
|
208
|
-
module.resource.indexOf('node_modules') >= 0) {
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
// Check that it's a source file from the project.
|
|
212
|
-
if (module.resource.endsWith('.ts')) {
|
|
213
|
-
this._checkTsNormalModule(module);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
_compilation(compiler, compilation) {
|
|
217
|
-
this._reset();
|
|
218
|
-
compilation.hooks.succeedModule.tap('NgBuildAnalyticsPlugin', this._succeedModule.bind(this));
|
|
219
|
-
}
|
|
220
|
-
_done(stats) {
|
|
221
|
-
this._collectErrors(stats);
|
|
222
|
-
this._collectBundleStats(stats.compilation);
|
|
223
|
-
if (this._built) {
|
|
224
|
-
this._reportRebuildMetrics(stats);
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
this._reportBuildMetrics(stats);
|
|
228
|
-
this._built = true;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
apply(compiler) {
|
|
232
|
-
compiler.hooks.compilation.tap('NgBuildAnalyticsPlugin', this._compilation.bind(this, compiler));
|
|
233
|
-
compiler.hooks.done.tap('NgBuildAnalyticsPlugin', this._done.bind(this));
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
exports.NgBuildAnalyticsPlugin = NgBuildAnalyticsPlugin;
|