@angular-devkit/build-angular 12.0.3 → 12.0.4
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 +6 -6
- package/src/browser/index.js +1 -3
- package/src/dev-server/index.js +1 -1
- package/src/extract-i18n/index.js +4 -3
- package/src/karma/index.js +1 -0
- package/src/karma/tests/setup.d.ts +18 -0
- package/src/karma/tests/setup.js +29 -0
- package/src/sass/sass-service.d.ts +0 -3
- package/src/sass/sass-service.js +4 -5
- package/src/utils/spinner.d.ts +2 -0
- package/src/utils/spinner.js +14 -0
- package/src/webpack/configs/common.js +11 -14
- package/src/webpack/configs/stats.d.ts +2 -0
- package/src/webpack/configs/stats.js +1 -0
- package/src/webpack/configs/styles.js +7 -0
- package/src/webpack/plugins/karma/karma-context.html +1 -1
- package/src/webpack/plugins/karma/karma-debug.html +1 -1
- package/src/webpack/plugins/karma/karma.js +1 -1
- package/src/webpack/utils/async-chunks.js +9 -5
- package/src/webpack/utils/stats.d.ts +2 -2
- package/src/webpack/utils/stats.js +15 -3
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.4",
|
|
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
|
-
"@angular-devkit/architect": "0.1200.
|
|
10
|
-
"@angular-devkit/build-optimizer": "0.1200.
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1200.
|
|
12
|
-
"@angular-devkit/core": "12.0.
|
|
9
|
+
"@angular-devkit/architect": "0.1200.4",
|
|
10
|
+
"@angular-devkit/build-optimizer": "0.1200.4",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1200.4",
|
|
12
|
+
"@angular-devkit/core": "12.0.4",
|
|
13
13
|
"@babel/core": "7.14.3",
|
|
14
14
|
"@babel/generator": "7.14.3",
|
|
15
15
|
"@babel/plugin-transform-async-to-generator": "7.13.0",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@babel/template": "7.12.13",
|
|
20
20
|
"@discoveryjs/json-ext": "0.5.2",
|
|
21
21
|
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
|
|
22
|
-
"@ngtools/webpack": "12.0.
|
|
22
|
+
"@ngtools/webpack": "12.0.4",
|
|
23
23
|
"ansi-colors": "4.1.1",
|
|
24
24
|
"babel-loader": "8.2.2",
|
|
25
25
|
"browserslist": "^4.9.1",
|
package/src/browser/index.js
CHANGED
|
@@ -69,7 +69,7 @@ async function initialize(options, context, differentialLoadingNeeded, webpackCo
|
|
|
69
69
|
const originalOutputPath = options.outputPath;
|
|
70
70
|
// Assets are processed directly by the builder except when watching
|
|
71
71
|
const adjustedOptions = options.watch ? options : { ...options, assets: [] };
|
|
72
|
-
const { config, projectRoot, projectSourceRoot, i18n
|
|
72
|
+
const { config, projectRoot, projectSourceRoot, i18n } = await webpack_browser_config_1.generateI18nBrowserWebpackConfigFromContext(adjustedOptions, context, (wco) => [
|
|
73
73
|
configs_1.getCommonConfig(wco),
|
|
74
74
|
configs_1.getBrowserConfig(wco),
|
|
75
75
|
configs_1.getStylesConfig(wco),
|
|
@@ -544,12 +544,10 @@ function assertNever(input) {
|
|
|
544
544
|
throw new Error(`Unexpected call to assertNever() with input: ${JSON.stringify(input, null /* replacer */, 4 /* tabSize */)}`);
|
|
545
545
|
}
|
|
546
546
|
function generateBundleInfoStats(bundle, chunk, chunkType) {
|
|
547
|
-
var _a;
|
|
548
547
|
return stats_1.generateBundleStats({
|
|
549
548
|
size: bundle.size,
|
|
550
549
|
files: bundle.map ? [bundle.filename, bundle.map.filename] : [bundle.filename],
|
|
551
550
|
names: chunk === null || chunk === void 0 ? void 0 : chunk.names,
|
|
552
|
-
entry: !!((_a = chunk === null || chunk === void 0 ? void 0 : chunk.names) === null || _a === void 0 ? void 0 : _a.includes('runtime')),
|
|
553
551
|
initial: !!(chunk === null || chunk === void 0 ? void 0 : chunk.initial),
|
|
554
552
|
rendered: true,
|
|
555
553
|
chunkType,
|
package/src/dev-server/index.js
CHANGED
|
@@ -224,7 +224,7 @@ function serveWebpackBrowser(options, context, transforms = {}) {
|
|
|
224
224
|
}));
|
|
225
225
|
}
|
|
226
226
|
return build_webpack_1.runWebpackDevServer(webpackConfig, context, {
|
|
227
|
-
logging: transforms.logging || stats_1.createWebpackLoggingCallback(
|
|
227
|
+
logging: transforms.logging || stats_1.createWebpackLoggingCallback(browserOptions, logger),
|
|
228
228
|
webpackFactory: require('webpack'),
|
|
229
229
|
webpackDevServerFactory: require('webpack-dev-server'),
|
|
230
230
|
}).pipe(operators_1.concatMap(async (buildEvent, index) => {
|
|
@@ -118,7 +118,7 @@ async function execute(options, context, transforms) {
|
|
|
118
118
|
const i18n = i18n_options_1.createI18nOptions(metadata);
|
|
119
119
|
let useLegacyIds = true;
|
|
120
120
|
const ivyMessages = [];
|
|
121
|
-
const
|
|
121
|
+
const builderOptions = {
|
|
122
122
|
...browserOptions,
|
|
123
123
|
optimization: false,
|
|
124
124
|
sourceMap: {
|
|
@@ -138,7 +138,8 @@ async function execute(options, context, transforms) {
|
|
|
138
138
|
subresourceIntegrity: false,
|
|
139
139
|
outputHashing: schema_1.OutputHashing.None,
|
|
140
140
|
namedChunks: true,
|
|
141
|
-
}
|
|
141
|
+
};
|
|
142
|
+
const { config, projectRoot } = await webpack_browser_config_1.generateBrowserWebpackConfigFromContext(builderOptions, context, (wco) => {
|
|
142
143
|
var _a;
|
|
143
144
|
if (wco.tsConfig.options.enableIvy === false) {
|
|
144
145
|
context.logger.warn('Ivy extraction enabled but application is not Ivy enabled. Extraction may fail.');
|
|
@@ -187,7 +188,7 @@ async function execute(options, context, transforms) {
|
|
|
187
188
|
};
|
|
188
189
|
}
|
|
189
190
|
const webpackResult = await build_webpack_1.runWebpack((await ((_a = transforms === null || transforms === void 0 ? void 0 : transforms.webpackConfiguration) === null || _a === void 0 ? void 0 : _a.call(transforms, config))) || config, context, {
|
|
190
|
-
logging: stats_1.createWebpackLoggingCallback(
|
|
191
|
+
logging: stats_1.createWebpackLoggingCallback(builderOptions, context.logger),
|
|
191
192
|
webpackFactory: webpack,
|
|
192
193
|
}).toPromise();
|
|
193
194
|
// Set the outputPath to the extraction output location for downstream consumers
|
package/src/karma/index.js
CHANGED
|
@@ -40,6 +40,7 @@ async function initialize(options, context, webpackConfigurationTransformer) {
|
|
|
40
40
|
// https://github.com/webpack/webpack-dev-middleware/blob/698c9ae5e9bb9a013985add6189ff21c1a1ec185/src/index.js#L65
|
|
41
41
|
// https://github.com/webpack/webpack/blob/cde1b73e12eb8a77eb9ba42e7920c9ec5d29c2c9/lib/Compiler.js#L379-L388
|
|
42
42
|
watch: true,
|
|
43
|
+
extractCss: true,
|
|
43
44
|
}, context, (wco) => [
|
|
44
45
|
configs_1.getCommonConfig(wco),
|
|
45
46
|
configs_1.getStylesConfig(wco),
|
|
@@ -0,0 +1,18 @@
|
|
|
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 { Schema } from '../schema';
|
|
9
|
+
export { describeBuilder } from '../../testing';
|
|
10
|
+
export declare const KARMA_BUILDER_INFO: Readonly<{
|
|
11
|
+
name: string;
|
|
12
|
+
schemaPath: string;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Contains all required karma builder fields.
|
|
16
|
+
* Also disables progress reporting to minimize logging output.
|
|
17
|
+
*/
|
|
18
|
+
export declare const BASE_OPTIONS: Readonly<Schema>;
|
|
@@ -0,0 +1,29 @@
|
|
|
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.BASE_OPTIONS = exports.KARMA_BUILDER_INFO = exports.describeBuilder = void 0;
|
|
11
|
+
var testing_1 = require("../../testing");
|
|
12
|
+
Object.defineProperty(exports, "describeBuilder", { enumerable: true, get: function () { return testing_1.describeBuilder; } });
|
|
13
|
+
exports.KARMA_BUILDER_INFO = Object.freeze({
|
|
14
|
+
name: '@angular-devkit/build-angular:karma',
|
|
15
|
+
schemaPath: __dirname + '/../schema.json',
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* Contains all required karma builder fields.
|
|
19
|
+
* Also disables progress reporting to minimize logging output.
|
|
20
|
+
*/
|
|
21
|
+
exports.BASE_OPTIONS = Object.freeze({
|
|
22
|
+
main: 'src/test.ts',
|
|
23
|
+
polyfills: 'src/polyfills.ts',
|
|
24
|
+
tsConfig: 'src/tsconfig.spec.json',
|
|
25
|
+
karmaConfig: 'karma.conf.js',
|
|
26
|
+
browsers: 'ChromeHeadlessCI',
|
|
27
|
+
progress: false,
|
|
28
|
+
watch: false,
|
|
29
|
+
});
|
|
@@ -41,9 +41,6 @@ export declare class SassWorkerImplementation {
|
|
|
41
41
|
/**
|
|
42
42
|
* Shutdown the Sass render worker.
|
|
43
43
|
* Executing this method will stop any pending render requests.
|
|
44
|
-
*
|
|
45
|
-
* The worker is unreferenced upon creation and will not block application exit. This method
|
|
46
|
-
* is only needed if early cleanup is needed.
|
|
47
44
|
*/
|
|
48
45
|
close(): void;
|
|
49
46
|
private createWorker;
|
package/src/sass/sass-service.js
CHANGED
|
@@ -87,13 +87,13 @@ class SassWorkerImplementation {
|
|
|
87
87
|
/**
|
|
88
88
|
* Shutdown the Sass render worker.
|
|
89
89
|
* Executing this method will stop any pending render requests.
|
|
90
|
-
*
|
|
91
|
-
* The worker is unreferenced upon creation and will not block application exit. This method
|
|
92
|
-
* is only needed if early cleanup is needed.
|
|
93
90
|
*/
|
|
94
91
|
close() {
|
|
95
92
|
for (const worker of this.workers) {
|
|
96
|
-
|
|
93
|
+
try {
|
|
94
|
+
void worker.terminate();
|
|
95
|
+
}
|
|
96
|
+
catch { }
|
|
97
97
|
}
|
|
98
98
|
this.requests.clear();
|
|
99
99
|
}
|
|
@@ -154,7 +154,6 @@ class SassWorkerImplementation {
|
|
|
154
154
|
Atomics.notify(importerSignal, 0);
|
|
155
155
|
});
|
|
156
156
|
});
|
|
157
|
-
worker.unref();
|
|
158
157
|
mainImporterPort.unref();
|
|
159
158
|
return worker;
|
|
160
159
|
}
|
package/src/utils/spinner.d.ts
CHANGED
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
export declare class Spinner {
|
|
9
|
+
#private;
|
|
9
10
|
private readonly spinner;
|
|
10
11
|
/** When false, only fail messages will be displayed. */
|
|
11
12
|
enabled: boolean;
|
|
12
13
|
constructor(text?: string);
|
|
13
14
|
set text(text: string);
|
|
15
|
+
get isSpinning(): boolean;
|
|
14
16
|
succeed(text?: string): void;
|
|
15
17
|
fail(text?: string): void;
|
|
16
18
|
stop(): void;
|
package/src/utils/spinner.js
CHANGED
|
@@ -6,25 +6,38 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
|
|
10
|
+
if (!privateMap.has(receiver)) {
|
|
11
|
+
throw new TypeError("attempted to get private field on non-instance");
|
|
12
|
+
}
|
|
13
|
+
return privateMap.get(receiver);
|
|
14
|
+
};
|
|
15
|
+
var _isTTY;
|
|
9
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
17
|
exports.Spinner = void 0;
|
|
11
18
|
const ora = require("ora");
|
|
12
19
|
const color_1 = require("./color");
|
|
20
|
+
const tty_1 = require("./tty");
|
|
13
21
|
class Spinner {
|
|
14
22
|
constructor(text) {
|
|
15
23
|
/** When false, only fail messages will be displayed. */
|
|
16
24
|
this.enabled = true;
|
|
25
|
+
_isTTY.set(this, tty_1.isTTY());
|
|
17
26
|
this.spinner = ora({
|
|
18
27
|
text,
|
|
19
28
|
// The below 2 options are needed because otherwise CTRL+C will be delayed
|
|
20
29
|
// when the underlying process is sync.
|
|
21
30
|
hideCursor: false,
|
|
22
31
|
discardStdin: false,
|
|
32
|
+
isEnabled: __classPrivateFieldGet(this, _isTTY),
|
|
23
33
|
});
|
|
24
34
|
}
|
|
25
35
|
set text(text) {
|
|
26
36
|
this.spinner.text = text;
|
|
27
37
|
}
|
|
38
|
+
get isSpinning() {
|
|
39
|
+
return this.spinner.isSpinning || !__classPrivateFieldGet(this, _isTTY);
|
|
40
|
+
}
|
|
28
41
|
succeed(text) {
|
|
29
42
|
if (this.enabled) {
|
|
30
43
|
this.spinner.succeed(text);
|
|
@@ -43,3 +56,4 @@ class Spinner {
|
|
|
43
56
|
}
|
|
44
57
|
}
|
|
45
58
|
exports.Spinner = Spinner;
|
|
59
|
+
_isTTY = new WeakMap();
|
|
@@ -25,7 +25,7 @@ const helpers_1 = require("../utils/helpers");
|
|
|
25
25
|
const stats_1 = require("../utils/stats");
|
|
26
26
|
// eslint-disable-next-line max-lines-per-function
|
|
27
27
|
function getCommonConfig(wco) {
|
|
28
|
-
var _a;
|
|
28
|
+
var _a, _b;
|
|
29
29
|
const { root, projectRoot, buildOptions, tsConfig } = wco;
|
|
30
30
|
const { platform = 'browser', sourceMap: { styles: stylesSourceMap, scripts: scriptsSourceMap, vendor: vendorSourceMap }, optimization: { styles: stylesOptimization, scripts: scriptsOptimization }, } = buildOptions;
|
|
31
31
|
const extraPlugins = [];
|
|
@@ -38,25 +38,22 @@ function getCommonConfig(wco) {
|
|
|
38
38
|
if (buildOptions.progress) {
|
|
39
39
|
const spinner = new spinner_1.Spinner();
|
|
40
40
|
spinner.start(`Generating ${platform} application bundles (phase: setup)...`);
|
|
41
|
-
let previousPercentage;
|
|
42
41
|
extraPlugins.push(new webpack_1.ProgressPlugin({
|
|
43
42
|
handler: (percentage, message) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// Ex: 0.99 -> 1 -> 0.99 -> 1
|
|
47
|
-
// This causes the "complete" message to be displayed multiple times.
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
43
|
+
const phase = message ? ` (phase: ${message})` : '';
|
|
44
|
+
spinner.text = `Generating ${platform} application bundles${phase}...`;
|
|
50
45
|
switch (percentage) {
|
|
51
46
|
case 1:
|
|
52
|
-
|
|
47
|
+
if (spinner.isSpinning) {
|
|
48
|
+
spinner.succeed(`${platform.replace(/^\w/, (s) => s.toUpperCase())} application bundle generation complete.`);
|
|
49
|
+
}
|
|
53
50
|
break;
|
|
54
51
|
case 0:
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
if (!spinner.isSpinning) {
|
|
53
|
+
spinner.start();
|
|
54
|
+
}
|
|
57
55
|
break;
|
|
58
56
|
}
|
|
59
|
-
previousPercentage = percentage;
|
|
60
57
|
},
|
|
61
58
|
}));
|
|
62
59
|
}
|
|
@@ -325,9 +322,9 @@ function getCommonConfig(wco) {
|
|
|
325
322
|
context: root,
|
|
326
323
|
entry: entryPoints,
|
|
327
324
|
output: {
|
|
328
|
-
clean: buildOptions.deleteOutputPath,
|
|
325
|
+
clean: (_a = buildOptions.deleteOutputPath) !== null && _a !== void 0 ? _a : true,
|
|
329
326
|
path: path.resolve(root, buildOptions.outputPath),
|
|
330
|
-
publicPath: (
|
|
327
|
+
publicPath: (_b = buildOptions.deployUrl) !== null && _b !== void 0 ? _b : '',
|
|
331
328
|
filename: ({ chunk }) => {
|
|
332
329
|
if ((chunk === null || chunk === void 0 ? void 0 : chunk.name) === 'polyfills-es5') {
|
|
333
330
|
return `polyfills-es5${hashFormat.chunk}.js`;
|
|
@@ -16,6 +16,7 @@ export declare function getWebpackStatsConfig(verbose?: boolean): {
|
|
|
16
16
|
warnings: boolean;
|
|
17
17
|
errors: boolean;
|
|
18
18
|
assets: boolean;
|
|
19
|
+
cachedAssets: boolean;
|
|
19
20
|
ids: boolean;
|
|
20
21
|
entrypoints: boolean;
|
|
21
22
|
};
|
|
@@ -30,6 +31,7 @@ export declare function getStatsConfig(wco: WebpackConfigOptions): {
|
|
|
30
31
|
warnings: boolean;
|
|
31
32
|
errors: boolean;
|
|
32
33
|
assets: boolean;
|
|
34
|
+
cachedAssets: boolean;
|
|
33
35
|
ids: boolean;
|
|
34
36
|
entrypoints: boolean;
|
|
35
37
|
};
|
|
@@ -81,6 +81,13 @@ function getStylesConfig(wco) {
|
|
|
81
81
|
}
|
|
82
82
|
catch {
|
|
83
83
|
sassImplementation = new sass_service_1.SassWorkerImplementation();
|
|
84
|
+
extraPlugins.push({
|
|
85
|
+
apply(compiler) {
|
|
86
|
+
compiler.hooks.shutdown.tap('sass-worker', () => {
|
|
87
|
+
sassImplementation === null || sassImplementation === void 0 ? void 0 : sassImplementation.close();
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
});
|
|
84
91
|
}
|
|
85
92
|
const assetNameTemplate = helpers_1.assetNameTemplateFactory(hashFormat);
|
|
86
93
|
const extraPostcssPlugins = [];
|
|
@@ -9,6 +9,7 @@ Reloaded before every execution run.
|
|
|
9
9
|
<title></title>
|
|
10
10
|
<base href="/" />
|
|
11
11
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
12
|
+
<link rel="stylesheet" href="_karma_webpack_/styles.css" crossorigin="anonymous" />
|
|
12
13
|
<meta
|
|
13
14
|
name="viewport"
|
|
14
15
|
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
|
|
@@ -34,7 +35,6 @@ Reloaded before every execution run.
|
|
|
34
35
|
<script src="_karma_webpack_/polyfills.js" crossorigin="anonymous"></script>
|
|
35
36
|
<!-- Dynamically replaced with <script> tags -->
|
|
36
37
|
%SCRIPTS%
|
|
37
|
-
<script src="_karma_webpack_/styles.js" crossorigin="anonymous"></script>
|
|
38
38
|
<script src="_karma_webpack_/scripts.js" crossorigin="anonymous"></script>
|
|
39
39
|
<script src="_karma_webpack_/vendor.js" crossorigin="anonymous"></script>
|
|
40
40
|
<script src="_karma_webpack_/main.js" crossorigin="anonymous"></script>
|
|
@@ -10,6 +10,7 @@ just for immediate execution, without reporting to Karma server.
|
|
|
10
10
|
<title>Karma DEBUG RUNNER</title>
|
|
11
11
|
<base href="/" />
|
|
12
12
|
<link href="favicon.ico" rel="icon" type="image/x-icon" />
|
|
13
|
+
<link rel="stylesheet" href="_karma_webpack_/styles.css" crossorigin="anonymous" />
|
|
13
14
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
14
15
|
<meta
|
|
15
16
|
name="viewport"
|
|
@@ -36,7 +37,6 @@ just for immediate execution, without reporting to Karma server.
|
|
|
36
37
|
<script src="_karma_webpack_/polyfills.js" crossorigin="anonymous"></script>
|
|
37
38
|
<!-- Dynamically replaced with <script> tags -->
|
|
38
39
|
%SCRIPTS%
|
|
39
|
-
<script src="_karma_webpack_/styles.js" crossorigin="anonymous"></script>
|
|
40
40
|
<script src="_karma_webpack_/scripts.js" crossorigin="anonymous"></script>
|
|
41
41
|
<script src="_karma_webpack_/vendor.js" crossorigin="anonymous"></script>
|
|
42
42
|
<script src="_karma_webpack_/main.js" crossorigin="anonymous"></script>
|
|
@@ -248,7 +248,7 @@ function fallbackMiddleware() {
|
|
|
248
248
|
`/${KARMA_APPLICATION_PATH}/polyfills.js`,
|
|
249
249
|
`/${KARMA_APPLICATION_PATH}/polyfills-es5.js`,
|
|
250
250
|
`/${KARMA_APPLICATION_PATH}/scripts.js`,
|
|
251
|
-
`/${KARMA_APPLICATION_PATH}/styles.
|
|
251
|
+
`/${KARMA_APPLICATION_PATH}/styles.css`,
|
|
252
252
|
`/${KARMA_APPLICATION_PATH}/vendor.js`,
|
|
253
253
|
];
|
|
254
254
|
if (request.url && alwaysServe.includes(request.url)) {
|
|
@@ -22,7 +22,7 @@ function markAsyncChunksNonInitial(webpackStats, extraEntryPoints) {
|
|
|
22
22
|
// **cannot** be loaded in main bundle.
|
|
23
23
|
const asyncChunkIds = extraEntryPoints
|
|
24
24
|
.filter((entryPoint) => !entryPoint.inject)
|
|
25
|
-
.flatMap((entryPoint) => entryPoints[entryPoint.bundleName].chunks);
|
|
25
|
+
.flatMap((entryPoint) => { var _a; return (_a = entryPoints[entryPoint.bundleName].chunks) === null || _a === void 0 ? void 0 : _a.filter((n) => n !== 'runtime'); });
|
|
26
26
|
// Find chunks for each ID.
|
|
27
27
|
const asyncChunks = asyncChunkIds.map((chunkId) => {
|
|
28
28
|
const chunk = chunks.find((chunk) => chunk.id === chunkId);
|
|
@@ -33,9 +33,13 @@ function markAsyncChunksNonInitial(webpackStats, extraEntryPoints) {
|
|
|
33
33
|
});
|
|
34
34
|
// A chunk is considered `initial` only if Webpack already belives it to be initial
|
|
35
35
|
// and the application developer did not mark it async via an extra entry point.
|
|
36
|
-
return chunks.map((chunk) =>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
return chunks.map((chunk) => {
|
|
37
|
+
return asyncChunks.find((asyncChunk) => asyncChunk === chunk)
|
|
38
|
+
? {
|
|
39
|
+
...chunk,
|
|
40
|
+
initial: false,
|
|
41
|
+
}
|
|
42
|
+
: chunk;
|
|
43
|
+
});
|
|
40
44
|
}
|
|
41
45
|
exports.markAsyncChunksNonInitial = markAsyncChunksNonInitial;
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { WebpackLoggingCallback } from '@angular-devkit/build-webpack';
|
|
9
9
|
import { logging } from '@angular-devkit/core';
|
|
10
10
|
import { Configuration, StatsCompilation } from 'webpack';
|
|
11
|
+
import { Schema as BrowserBuilderOptions } from '../../browser/schema';
|
|
11
12
|
export declare function formatSize(size: number): string;
|
|
12
13
|
export declare type BundleStatsData = [files: string, names: string, size: number | string];
|
|
13
14
|
export declare type ChunkType = 'modern' | 'legacy' | 'unknown';
|
|
@@ -20,7 +21,6 @@ export declare function generateBundleStats(info: {
|
|
|
20
21
|
size?: number;
|
|
21
22
|
files?: string[];
|
|
22
23
|
names?: string[];
|
|
23
|
-
entry?: boolean;
|
|
24
24
|
initial?: boolean;
|
|
25
25
|
rendered?: boolean;
|
|
26
26
|
chunkType?: ChunkType;
|
|
@@ -30,5 +30,5 @@ export declare function statsWarningsToString(json: StatsCompilation, statsConfi
|
|
|
30
30
|
export declare function statsErrorsToString(json: StatsCompilation, statsConfig: any): string;
|
|
31
31
|
export declare function statsHasErrors(json: StatsCompilation): boolean;
|
|
32
32
|
export declare function statsHasWarnings(json: StatsCompilation): boolean;
|
|
33
|
-
export declare function createWebpackLoggingCallback(
|
|
33
|
+
export declare function createWebpackLoggingCallback(options: BrowserBuilderOptions, logger: logging.LoggerApi): WebpackLoggingCallback;
|
|
34
34
|
export declare function webpackStatsLogger(logger: logging.LoggerApi, json: StatsCompilation, config: Configuration, bundleStats?: BundleStats[]): void;
|
|
@@ -13,6 +13,8 @@ const path = require("path");
|
|
|
13
13
|
const textTable = require("text-table");
|
|
14
14
|
const color_1 = require("../../utils/color");
|
|
15
15
|
const stats_1 = require("../configs/stats");
|
|
16
|
+
const async_chunks_1 = require("./async-chunks");
|
|
17
|
+
const helpers_1 = require("./helpers");
|
|
16
18
|
function formatSize(size) {
|
|
17
19
|
if (size <= 0) {
|
|
18
20
|
return '0 bytes';
|
|
@@ -30,7 +32,7 @@ function generateBundleStats(info) {
|
|
|
30
32
|
const size = typeof info.size === 'number' ? info.size : '-';
|
|
31
33
|
const files = (_b = (_a = info.files) === null || _a === void 0 ? void 0 : _a.filter((f) => !f.endsWith('.map')).map((f) => path.basename(f)).join(', ')) !== null && _b !== void 0 ? _b : '';
|
|
32
34
|
const names = ((_c = info.names) === null || _c === void 0 ? void 0 : _c.length) ? info.names.join(', ') : '-';
|
|
33
|
-
const initial = !!
|
|
35
|
+
const initial = !!info.initial;
|
|
34
36
|
const chunkType = info.chunkType || 'unknown';
|
|
35
37
|
return {
|
|
36
38
|
chunkType,
|
|
@@ -255,12 +257,22 @@ function statsHasWarnings(json) {
|
|
|
255
257
|
return !!(((_a = json.warnings) === null || _a === void 0 ? void 0 : _a.length) || ((_b = json.children) === null || _b === void 0 ? void 0 : _b.some((c) => { var _a; return (_a = c.warnings) === null || _a === void 0 ? void 0 : _a.length; })));
|
|
256
258
|
}
|
|
257
259
|
exports.statsHasWarnings = statsHasWarnings;
|
|
258
|
-
function createWebpackLoggingCallback(
|
|
260
|
+
function createWebpackLoggingCallback(options, logger) {
|
|
261
|
+
const { verbose = false, scripts = [], styles = [] } = options;
|
|
262
|
+
const extraEntryPoints = [
|
|
263
|
+
...helpers_1.normalizeExtraEntryPoints(styles, 'styles'),
|
|
264
|
+
...helpers_1.normalizeExtraEntryPoints(scripts, 'scripts'),
|
|
265
|
+
];
|
|
259
266
|
return (stats, config) => {
|
|
260
267
|
if (verbose) {
|
|
261
268
|
logger.info(stats.toString(config.stats));
|
|
262
269
|
}
|
|
263
|
-
|
|
270
|
+
const rawStats = stats.toJson(stats_1.getWebpackStatsConfig(false));
|
|
271
|
+
const webpackStats = {
|
|
272
|
+
...rawStats,
|
|
273
|
+
chunks: async_chunks_1.markAsyncChunksNonInitial(rawStats, extraEntryPoints),
|
|
274
|
+
};
|
|
275
|
+
webpackStatsLogger(logger, webpackStats, config);
|
|
264
276
|
};
|
|
265
277
|
}
|
|
266
278
|
exports.createWebpackLoggingCallback = createWebpackLoggingCallback;
|