@angular-devkit/build-angular 12.1.0-next.4 → 12.1.1
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 +35 -33
- package/src/app-shell/index.js +28 -8
- package/src/babel/plugins/adjust-static-class-members.d.ts +25 -0
- package/src/babel/plugins/adjust-static-class-members.js +251 -0
- package/src/babel/plugins/adjust-typescript-enums.d.ts +21 -0
- package/src/babel/plugins/adjust-typescript-enums.js +123 -0
- package/src/babel/plugins/elide-angular-metadata.d.ts +21 -0
- package/src/babel/plugins/elide-angular-metadata.js +68 -0
- package/src/babel/plugins/pure-toplevel-functions.d.ts +14 -0
- package/src/babel/plugins/pure-toplevel-functions.js +86 -0
- package/src/babel/presets/application.d.ts +1 -0
- package/src/babel/presets/application.js +24 -4
- package/src/babel/webpack-loader.js +39 -1
- package/src/browser/index.d.ts +1 -4
- package/src/browser/index.js +26 -36
- package/src/dev-server/index.d.ts +1 -1
- package/src/dev-server/index.js +31 -10
- package/src/dev-server/tests/execute-fetch.js +4 -1
- package/src/extract-i18n/index.d.ts +1 -1
- package/src/extract-i18n/index.js +37 -14
- package/src/extract-i18n/ivy-extract-loader.js +20 -1
- package/src/karma/find-tests.js +20 -1
- package/src/karma/index.js +21 -1
- package/src/karma/tests/setup.d.ts +18 -0
- package/src/karma/tests/setup.js +29 -0
- package/src/ng-packagr/index.js +21 -2
- package/src/protractor/index.js +21 -2
- package/src/sass/sass-service.d.ts +0 -3
- package/src/sass/sass-service.js +4 -5
- package/src/server/index.d.ts +1 -1
- package/src/server/index.js +20 -1
- package/src/tslint/index.js +22 -3
- package/src/typings.d.ts +6 -0
- package/src/utils/action-cache.js +21 -2
- package/src/utils/action-executor.js +21 -2
- package/src/utils/build-browser-features.js +25 -3
- package/src/utils/cache-path.js +5 -2
- package/src/utils/check-port.js +20 -1
- package/src/utils/color.js +20 -1
- package/src/utils/copy-assets.js +26 -4
- package/src/utils/copy-file.js +20 -1
- package/src/utils/delete-output-dir.js +28 -2
- package/src/utils/environment-options.d.ts +1 -0
- package/src/utils/environment-options.js +26 -2
- package/src/utils/find-up.js +20 -1
- package/src/utils/i18n-inlining.js +21 -2
- package/src/utils/i18n-options.js +23 -5
- package/src/utils/index-file/html-rewriting-stream.js +20 -1
- package/src/utils/index-file/index-html-generator.js +20 -1
- package/src/utils/index-file/inline-critical-css.js +20 -1
- package/src/utils/index-file/inline-fonts.js +27 -5
- package/src/utils/is-directory.js +20 -1
- package/src/utils/load-translations.js +26 -7
- package/src/utils/process-bundle.js +34 -12
- package/src/utils/read-tsconfig.js +20 -1
- package/src/utils/service-worker.js +21 -2
- package/src/utils/spinner.d.ts +2 -0
- package/src/utils/spinner.js +18 -2
- package/src/utils/webpack-browser-config.js +21 -2
- package/src/webpack/configs/analytics.d.ts +11 -0
- package/src/webpack/configs/analytics.js +29 -0
- package/src/webpack/configs/browser.js +0 -4
- package/src/webpack/configs/common.js +90 -31
- package/src/webpack/configs/dev-server.js +20 -1
- package/src/webpack/configs/index.d.ts +1 -0
- package/src/webpack/configs/index.js +1 -0
- package/src/webpack/configs/server.js +0 -1
- package/src/webpack/configs/stats.d.ts +2 -0
- package/src/webpack/configs/stats.js +1 -0
- package/src/webpack/configs/styles.js +28 -2
- package/src/webpack/configs/test.js +32 -3
- package/src/webpack/configs/typescript.d.ts +2 -9
- package/src/webpack/configs/typescript.js +16 -14
- package/src/webpack/plugins/any-component-style-budget-checker.js +20 -1
- package/src/webpack/plugins/builder-watch-plugin.d.ts +0 -2
- package/src/webpack/plugins/builder-watch-plugin.js +2 -7
- package/src/webpack/plugins/index.js +4 -1
- 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 +27 -5
- package/src/webpack/plugins/postcss-cli-resources.js +21 -2
- package/src/webpack/plugins/scripts-webpack-plugin.js +20 -1
- package/src/webpack/utils/async-chunks.js +9 -5
- package/src/webpack/utils/helpers.js +20 -1
- package/src/webpack/utils/stats.d.ts +2 -3
- package/src/webpack/utils/stats.js +50 -15
|
@@ -6,17 +6,39 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
+
};
|
|
9
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
32
|
exports.inlineLocales = exports.createI18nPlugins = exports.process = exports.setup = void 0;
|
|
11
33
|
const core_1 = require("@babel/core");
|
|
12
|
-
const template_1 = require("@babel/template");
|
|
13
|
-
const cacache = require("cacache");
|
|
34
|
+
const template_1 = __importDefault(require("@babel/template"));
|
|
35
|
+
const cacache = __importStar(require("cacache"));
|
|
14
36
|
const crypto_1 = require("crypto");
|
|
15
|
-
const fs = require("fs");
|
|
16
|
-
const path = require("path");
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
17
39
|
const source_map_1 = require("source-map");
|
|
18
40
|
const terser_1 = require("terser");
|
|
19
|
-
const v8 = require("v8");
|
|
41
|
+
const v8 = __importStar(require("v8"));
|
|
20
42
|
const webpack_1 = require("webpack");
|
|
21
43
|
const environment_options_1 = require("./environment-options");
|
|
22
44
|
const { ConcatSource, OriginalSource, ReplaceSource, SourceMapSource } = webpack_1.sources;
|
|
@@ -359,23 +381,23 @@ function createIifeWrapperPlugin() {
|
|
|
359
381
|
const USE_LOCALIZE_PLUGINS = false;
|
|
360
382
|
async function createI18nPlugins(locale, translation, missingTranslation, shouldInline, localeDataContent) {
|
|
361
383
|
const plugins = [];
|
|
362
|
-
const localizeDiag = await Promise.resolve().then(() => require('@angular/localize/src/tools/src/diagnostics'));
|
|
384
|
+
const localizeDiag = await Promise.resolve().then(() => __importStar(require('@angular/localize/src/tools/src/diagnostics')));
|
|
363
385
|
const diagnostics = new localizeDiag.Diagnostics();
|
|
364
386
|
if (shouldInline) {
|
|
365
|
-
const es2015 = await Promise.resolve().then(() => require('@angular/localize/src/tools/src/translate/source_files/es2015_translate_plugin'));
|
|
387
|
+
const es2015 = await Promise.resolve().then(() => __importStar(require('@angular/localize/src/tools/src/translate/source_files/es2015_translate_plugin')));
|
|
366
388
|
plugins.push(
|
|
367
389
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
368
390
|
es2015.makeEs2015TranslatePlugin(diagnostics, (translation || {}), {
|
|
369
391
|
missingTranslation: translation === undefined ? 'ignore' : missingTranslation,
|
|
370
392
|
}));
|
|
371
|
-
const es5 = await Promise.resolve().then(() => require('@angular/localize/src/tools/src/translate/source_files/es5_translate_plugin'));
|
|
393
|
+
const es5 = await Promise.resolve().then(() => __importStar(require('@angular/localize/src/tools/src/translate/source_files/es5_translate_plugin')));
|
|
372
394
|
plugins.push(
|
|
373
395
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
374
396
|
es5.makeEs5TranslatePlugin(diagnostics, (translation || {}), {
|
|
375
397
|
missingTranslation: translation === undefined ? 'ignore' : missingTranslation,
|
|
376
398
|
}));
|
|
377
399
|
}
|
|
378
|
-
const inlineLocale = await Promise.resolve().then(() => require('@angular/localize/src/tools/src/translate/source_files/locale_plugin'));
|
|
400
|
+
const inlineLocale = await Promise.resolve().then(() => __importStar(require('@angular/localize/src/tools/src/translate/source_files/locale_plugin')));
|
|
379
401
|
plugins.push(inlineLocale.makeLocalePlugin(locale));
|
|
380
402
|
if (localeDataContent) {
|
|
381
403
|
plugins.push({
|
|
@@ -472,9 +494,9 @@ async function inlineLocalesDirect(ast, options) {
|
|
|
472
494
|
if (!i18n || i18n.inlineLocales.size === 0) {
|
|
473
495
|
return { file: options.filename, diagnostics: [], count: 0 };
|
|
474
496
|
}
|
|
475
|
-
const { default: generate } = await Promise.resolve().then(() => require('@babel/generator'));
|
|
476
|
-
const utils = await Promise.resolve().then(() => require('@angular/localize/src/tools/src/source_file_utils'));
|
|
477
|
-
const localizeDiag = await Promise.resolve().then(() => require('@angular/localize/src/tools/src/diagnostics'));
|
|
497
|
+
const { default: generate } = await Promise.resolve().then(() => __importStar(require('@babel/generator')));
|
|
498
|
+
const utils = await Promise.resolve().then(() => __importStar(require('@angular/localize/src/tools/src/source_file_utils')));
|
|
499
|
+
const localizeDiag = await Promise.resolve().then(() => __importStar(require('@angular/localize/src/tools/src/diagnostics')));
|
|
478
500
|
const diagnostics = new localizeDiag.Diagnostics();
|
|
479
501
|
const positions = findLocalizePositions(ast, options, utils);
|
|
480
502
|
if (positions.length === 0 && !options.setLocale) {
|
|
@@ -6,9 +6,28 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
9
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
29
|
exports.readTsconfig = void 0;
|
|
11
|
-
const path = require("path");
|
|
30
|
+
const path = __importStar(require("path"));
|
|
12
31
|
/**
|
|
13
32
|
* Reads and parses a given TsConfig file.
|
|
14
33
|
*
|
|
@@ -6,12 +6,31 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
9
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
29
|
exports.augmentAppWithServiceWorker = void 0;
|
|
11
30
|
const core_1 = require("@angular-devkit/core");
|
|
12
|
-
const crypto = require("crypto");
|
|
31
|
+
const crypto = __importStar(require("crypto"));
|
|
13
32
|
const fs_1 = require("fs");
|
|
14
|
-
const path = require("path");
|
|
33
|
+
const path = __importStar(require("path"));
|
|
15
34
|
const stream_1 = require("stream");
|
|
16
35
|
class CliFilesystem {
|
|
17
36
|
constructor(base) {
|
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,40 @@
|
|
|
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, state, kind, f) {
|
|
10
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
11
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
12
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
13
|
+
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
var _Spinner_isTTY;
|
|
9
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
19
|
exports.Spinner = void 0;
|
|
11
|
-
const
|
|
20
|
+
const ora_1 = __importDefault(require("ora"));
|
|
12
21
|
const color_1 = require("./color");
|
|
22
|
+
const tty_1 = require("./tty");
|
|
13
23
|
class Spinner {
|
|
14
24
|
constructor(text) {
|
|
15
25
|
/** When false, only fail messages will be displayed. */
|
|
16
26
|
this.enabled = true;
|
|
17
|
-
this.
|
|
27
|
+
_Spinner_isTTY.set(this, tty_1.isTTY());
|
|
28
|
+
this.spinner = ora_1.default({
|
|
18
29
|
text,
|
|
19
30
|
// The below 2 options are needed because otherwise CTRL+C will be delayed
|
|
20
31
|
// when the underlying process is sync.
|
|
21
32
|
hideCursor: false,
|
|
22
33
|
discardStdin: false,
|
|
34
|
+
isEnabled: __classPrivateFieldGet(this, _Spinner_isTTY, "f"),
|
|
23
35
|
});
|
|
24
36
|
}
|
|
25
37
|
set text(text) {
|
|
26
38
|
this.spinner.text = text;
|
|
27
39
|
}
|
|
40
|
+
get isSpinning() {
|
|
41
|
+
return this.spinner.isSpinning || !__classPrivateFieldGet(this, _Spinner_isTTY, "f");
|
|
42
|
+
}
|
|
28
43
|
succeed(text) {
|
|
29
44
|
if (this.enabled) {
|
|
30
45
|
this.spinner.succeed(text);
|
|
@@ -43,3 +58,4 @@ class Spinner {
|
|
|
43
58
|
}
|
|
44
59
|
}
|
|
45
60
|
exports.Spinner = Spinner;
|
|
61
|
+
_Spinner_isTTY = new WeakMap();
|
|
@@ -6,10 +6,29 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
9
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
29
|
exports.getIndexInputFile = exports.getIndexOutputFile = exports.generateBrowserWebpackConfigFromContext = exports.generateI18nBrowserWebpackConfigFromContext = exports.generateWebpackConfig = void 0;
|
|
11
30
|
const core_1 = require("@angular-devkit/core");
|
|
12
|
-
const path = require("path");
|
|
31
|
+
const path = __importStar(require("path"));
|
|
13
32
|
const webpack_1 = require("webpack");
|
|
14
33
|
const webpack_merge_1 = require("webpack-merge");
|
|
15
34
|
const utils_1 = require("../utils");
|
|
@@ -23,7 +42,7 @@ async function generateWebpackConfig(workspaceRoot, projectRoot, sourceRoot, opt
|
|
|
23
42
|
}
|
|
24
43
|
const tsConfigPath = path.resolve(workspaceRoot, options.tsConfig);
|
|
25
44
|
const tsConfig = read_tsconfig_1.readTsconfig(tsConfigPath);
|
|
26
|
-
const ts = await Promise.resolve().then(() => require('typescript'));
|
|
45
|
+
const ts = await Promise.resolve().then(() => __importStar(require('typescript')));
|
|
27
46
|
const scriptTarget = tsConfig.options.target || ts.ScriptTarget.ES5;
|
|
28
47
|
const buildOptions = { ...options, ...extraBuildOptions };
|
|
29
48
|
const wco = {
|
|
@@ -0,0 +1,11 @@
|
|
|
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;
|
|
@@ -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.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: [
|
|
25
|
+
new analytics_1.NgBuildAnalyticsPlugin(wco.projectRoot, context.analytics, category, !!wco.tsConfig.options.enableIvy),
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
exports.getAnalyticsConfig = getAnalyticsConfig;
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.getBrowserConfig = void 0;
|
|
11
|
-
const typescript_1 = require("typescript");
|
|
12
11
|
const utils_1 = require("../../utils");
|
|
13
12
|
const plugins_1 = require("../plugins");
|
|
14
13
|
const helpers_1 = require("../utils/helpers");
|
|
@@ -51,9 +50,6 @@ function getBrowserConfig(wco) {
|
|
|
51
50
|
resolve: {
|
|
52
51
|
mainFields: ['es2015', 'browser', 'module', 'main'],
|
|
53
52
|
},
|
|
54
|
-
target: wco.tsConfig.options.target === typescript_1.ScriptTarget.ES5 || buildBrowserFeatures.isEs5SupportNeeded()
|
|
55
|
-
? ['web', 'es5']
|
|
56
|
-
: 'web',
|
|
57
53
|
output: {
|
|
58
54
|
crossOriginLoading,
|
|
59
55
|
trustedTypes: 'angular#bundler',
|
|
@@ -6,12 +6,36 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
+
};
|
|
9
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
32
|
exports.getCommonConfig = void 0;
|
|
11
33
|
const build_optimizer_1 = require("@angular-devkit/build-optimizer");
|
|
12
|
-
const
|
|
34
|
+
const compiler_cli_1 = require("@angular/compiler-cli");
|
|
35
|
+
const copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
|
|
36
|
+
const crypto_1 = require("crypto");
|
|
13
37
|
const fs_1 = require("fs");
|
|
14
|
-
const path = require("path");
|
|
38
|
+
const path = __importStar(require("path"));
|
|
15
39
|
const typescript_1 = require("typescript");
|
|
16
40
|
const webpack_1 = require("webpack");
|
|
17
41
|
const utils_1 = require("../../utils");
|
|
@@ -22,10 +46,9 @@ const spinner_1 = require("../../utils/spinner");
|
|
|
22
46
|
const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
|
|
23
47
|
const plugins_1 = require("../plugins");
|
|
24
48
|
const helpers_1 = require("../utils/helpers");
|
|
25
|
-
const stats_1 = require("../utils/stats");
|
|
26
49
|
// eslint-disable-next-line max-lines-per-function
|
|
27
50
|
function getCommonConfig(wco) {
|
|
28
|
-
var _a;
|
|
51
|
+
var _a, _b;
|
|
29
52
|
const { root, projectRoot, buildOptions, tsConfig } = wco;
|
|
30
53
|
const { platform = 'browser', sourceMap: { styles: stylesSourceMap, scripts: scriptsSourceMap, vendor: vendorSourceMap }, optimization: { styles: stylesOptimization, scripts: scriptsOptimization }, } = buildOptions;
|
|
31
54
|
const extraPlugins = [];
|
|
@@ -38,25 +61,22 @@ function getCommonConfig(wco) {
|
|
|
38
61
|
if (buildOptions.progress) {
|
|
39
62
|
const spinner = new spinner_1.Spinner();
|
|
40
63
|
spinner.start(`Generating ${platform} application bundles (phase: setup)...`);
|
|
41
|
-
let previousPercentage;
|
|
42
64
|
extraPlugins.push(new webpack_1.ProgressPlugin({
|
|
43
65
|
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
|
-
}
|
|
66
|
+
const phase = message ? ` (phase: ${message})` : '';
|
|
67
|
+
spinner.text = `Generating ${platform} application bundles${phase}...`;
|
|
50
68
|
switch (percentage) {
|
|
51
69
|
case 1:
|
|
52
|
-
|
|
70
|
+
if (spinner.isSpinning) {
|
|
71
|
+
spinner.succeed(`${platform.replace(/^\w/, (s) => s.toUpperCase())} application bundle generation complete.`);
|
|
72
|
+
}
|
|
53
73
|
break;
|
|
54
74
|
case 0:
|
|
55
|
-
|
|
56
|
-
|
|
75
|
+
if (!spinner.isSpinning) {
|
|
76
|
+
spinner.start();
|
|
77
|
+
}
|
|
57
78
|
break;
|
|
58
79
|
}
|
|
59
|
-
previousPercentage = percentage;
|
|
60
80
|
},
|
|
61
81
|
}));
|
|
62
82
|
}
|
|
@@ -182,7 +202,7 @@ function getCommonConfig(wco) {
|
|
|
182
202
|
},
|
|
183
203
|
};
|
|
184
204
|
});
|
|
185
|
-
extraPlugins.push(new
|
|
205
|
+
extraPlugins.push(new copy_webpack_plugin_1.default({
|
|
186
206
|
patterns: copyWebpackPluginPatterns,
|
|
187
207
|
}));
|
|
188
208
|
}
|
|
@@ -196,7 +216,7 @@ function getCommonConfig(wco) {
|
|
|
196
216
|
extraPlugins.push(new (class {
|
|
197
217
|
apply(compiler) {
|
|
198
218
|
compiler.hooks.done.tapPromise('angular-cli-stats', async (stats) => {
|
|
199
|
-
const { stringifyStream } = await Promise.resolve().then(() => require('@discoveryjs/json-ext'));
|
|
219
|
+
const { stringifyStream } = await Promise.resolve().then(() => __importStar(require('@discoveryjs/json-ext')));
|
|
200
220
|
const data = stats.toJson('verbose');
|
|
201
221
|
const statsOutputPath = path.resolve(root, buildOptions.outputPath, 'stats.json');
|
|
202
222
|
try {
|
|
@@ -222,7 +242,7 @@ function getCommonConfig(wco) {
|
|
|
222
242
|
});
|
|
223
243
|
}
|
|
224
244
|
let buildOptimizerUseRule = [];
|
|
225
|
-
if (buildOptions.buildOptimizer) {
|
|
245
|
+
if (buildOptions.buildOptimizer && wco.scriptTarget < typescript_1.ScriptTarget.ES2015) {
|
|
226
246
|
extraPlugins.push(new build_optimizer_1.BuildOptimizerWebpackPlugin());
|
|
227
247
|
buildOptimizerUseRule = [
|
|
228
248
|
{
|
|
@@ -234,10 +254,9 @@ function getCommonConfig(wco) {
|
|
|
234
254
|
const extraMinimizers = [];
|
|
235
255
|
if (scriptsOptimization) {
|
|
236
256
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
237
|
-
const { GLOBAL_DEFS_FOR_TERSER, GLOBAL_DEFS_FOR_TERSER_WITH_AOT, } = require('@angular/compiler-cli');
|
|
238
257
|
const angularGlobalDefinitions = buildOptions.aot
|
|
239
|
-
? GLOBAL_DEFS_FOR_TERSER_WITH_AOT
|
|
240
|
-
: GLOBAL_DEFS_FOR_TERSER;
|
|
258
|
+
? compiler_cli_1.GLOBAL_DEFS_FOR_TERSER_WITH_AOT
|
|
259
|
+
: compiler_cli_1.GLOBAL_DEFS_FOR_TERSER;
|
|
241
260
|
// TODO: Investigate why this fails for some packages: wco.supportES2015 ? 6 : 5;
|
|
242
261
|
const terserEcma = 5;
|
|
243
262
|
const terserOptions = {
|
|
@@ -305,12 +324,19 @@ function getCommonConfig(wco) {
|
|
|
305
324
|
return {
|
|
306
325
|
mode: scriptsOptimization || stylesOptimization.minify ? 'production' : 'development',
|
|
307
326
|
devtool: false,
|
|
327
|
+
target: [
|
|
328
|
+
platform === 'server' ? 'node' : 'web',
|
|
329
|
+
tsConfig.options.target === typescript_1.ScriptTarget.ES5 ||
|
|
330
|
+
(platform !== 'server' && buildBrowserFeatures.isEs5SupportNeeded())
|
|
331
|
+
? 'es5'
|
|
332
|
+
: 'es2015',
|
|
333
|
+
],
|
|
308
334
|
profile: buildOptions.statsJson,
|
|
309
335
|
resolve: {
|
|
310
336
|
roots: [projectRoot],
|
|
311
337
|
extensions: ['.ts', '.tsx', '.mjs', '.js'],
|
|
312
338
|
symlinks: !buildOptions.preserveSymlinks,
|
|
313
|
-
modules: [
|
|
339
|
+
modules: [tsConfig.options.baseUrl || projectRoot, 'node_modules'],
|
|
314
340
|
},
|
|
315
341
|
resolveLoader: {
|
|
316
342
|
symlinks: !buildOptions.preserveSymlinks,
|
|
@@ -325,9 +351,9 @@ function getCommonConfig(wco) {
|
|
|
325
351
|
context: root,
|
|
326
352
|
entry: entryPoints,
|
|
327
353
|
output: {
|
|
328
|
-
clean: buildOptions.deleteOutputPath,
|
|
354
|
+
clean: (_a = buildOptions.deleteOutputPath) !== null && _a !== void 0 ? _a : true,
|
|
329
355
|
path: path.resolve(root, buildOptions.outputPath),
|
|
330
|
-
publicPath: (
|
|
356
|
+
publicPath: (_b = buildOptions.deployUrl) !== null && _b !== void 0 ? _b : '',
|
|
331
357
|
filename: ({ chunk }) => {
|
|
332
358
|
if ((chunk === null || chunk === void 0 ? void 0 : chunk.name) === 'polyfills-es5') {
|
|
333
359
|
return `polyfills-es5${hashFormat.chunk}.js`;
|
|
@@ -336,14 +362,22 @@ function getCommonConfig(wco) {
|
|
|
336
362
|
return `[name]${targetInFileName}${hashFormat.chunk}.js`;
|
|
337
363
|
}
|
|
338
364
|
},
|
|
339
|
-
chunkFilename: `[
|
|
365
|
+
chunkFilename: `[name]${targetInFileName}${hashFormat.chunk}.js`,
|
|
340
366
|
},
|
|
341
367
|
watch: buildOptions.watch,
|
|
342
368
|
watchOptions: helpers_1.getWatchOptions(buildOptions.poll),
|
|
343
369
|
performance: {
|
|
344
370
|
hints: false,
|
|
345
371
|
},
|
|
346
|
-
ignoreWarnings:
|
|
372
|
+
ignoreWarnings: [
|
|
373
|
+
// Webpack 5+ has no facility to disable this warning.
|
|
374
|
+
// System.import is used in @angular/core for deprecated string-form lazy routes
|
|
375
|
+
/System.import\(\) is deprecated and will be removed soon/i,
|
|
376
|
+
// https://github.com/webpack-contrib/source-map-loader/blob/b2de4249c7431dd8432da607e08f0f65e9d64219/src/index.js#L83
|
|
377
|
+
/Failed to parse source map from/,
|
|
378
|
+
// https://github.com/webpack-contrib/postcss-loader/blob/bd261875fdf9c596af4ffb3a1a73fe3c549befda/src/index.js#L153-L158
|
|
379
|
+
/Add postcss as project dependency/,
|
|
380
|
+
],
|
|
347
381
|
module: {
|
|
348
382
|
// Show an error for missing exports instead of a warning.
|
|
349
383
|
strictExportPresence: true,
|
|
@@ -373,6 +407,7 @@ function getCommonConfig(wco) {
|
|
|
373
407
|
cacheDirectory: cache_path_1.findCachePath('babel-webpack'),
|
|
374
408
|
scriptTarget: wco.scriptTarget,
|
|
375
409
|
aot: buildOptions.aot,
|
|
410
|
+
optimize: buildOptions.buildOptimizer && wco.scriptTarget >= typescript_1.ScriptTarget.ES2015,
|
|
376
411
|
},
|
|
377
412
|
},
|
|
378
413
|
...buildOptimizerUseRule,
|
|
@@ -385,11 +420,7 @@ function getCommonConfig(wco) {
|
|
|
385
420
|
syncWebAssembly: true,
|
|
386
421
|
asyncWebAssembly: true,
|
|
387
422
|
},
|
|
388
|
-
cache:
|
|
389
|
-
!environment_options_1.cachingDisabled && {
|
|
390
|
-
type: 'memory',
|
|
391
|
-
maxGenerations: 1,
|
|
392
|
-
},
|
|
423
|
+
cache: getCacheSettings(wco, buildBrowserFeatures.supportedBrowsers),
|
|
393
424
|
optimization: {
|
|
394
425
|
minimizer: extraMinimizers,
|
|
395
426
|
moduleIds: 'deterministic',
|
|
@@ -406,3 +437,31 @@ function getCommonConfig(wco) {
|
|
|
406
437
|
};
|
|
407
438
|
}
|
|
408
439
|
exports.getCommonConfig = getCommonConfig;
|
|
440
|
+
function getCacheSettings(wco, supportedBrowsers) {
|
|
441
|
+
if (environment_options_1.persistentBuildCacheEnabled) {
|
|
442
|
+
const packageVersion = require('../../../package.json').version;
|
|
443
|
+
return {
|
|
444
|
+
type: 'filesystem',
|
|
445
|
+
cacheDirectory: cache_path_1.findCachePath('angular-webpack'),
|
|
446
|
+
maxMemoryGenerations: 1,
|
|
447
|
+
// We use the versions and build options as the cache name. The Webpack configurations are too
|
|
448
|
+
// dynamic and shared among different build types: test, build and serve.
|
|
449
|
+
// None of which are "named".
|
|
450
|
+
name: crypto_1.createHash('sha1')
|
|
451
|
+
.update(compiler_cli_1.VERSION.full)
|
|
452
|
+
.update(packageVersion)
|
|
453
|
+
.update(wco.projectRoot)
|
|
454
|
+
.update(JSON.stringify(wco.tsConfig))
|
|
455
|
+
.update(JSON.stringify(wco.buildOptions))
|
|
456
|
+
.update(supportedBrowsers.join(''))
|
|
457
|
+
.digest('base64'),
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
if (wco.buildOptions.watch && !environment_options_1.cachingDisabled) {
|
|
461
|
+
return {
|
|
462
|
+
type: 'memory',
|
|
463
|
+
maxGenerations: 1,
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
@@ -6,12 +6,31 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
9
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
29
|
exports.buildServePath = exports.getDevServerConfig = void 0;
|
|
11
30
|
const core_1 = require("@angular-devkit/core");
|
|
12
31
|
const fs_1 = require("fs");
|
|
13
32
|
const path_1 = require("path");
|
|
14
|
-
const url = require("url");
|
|
33
|
+
const url = __importStar(require("url"));
|
|
15
34
|
const utils_1 = require("../../utils");
|
|
16
35
|
const webpack_browser_config_1 = require("../../utils/webpack-browser-config");
|
|
17
36
|
const hmr_loader_1 = require("../plugins/hmr/hmr-loader");
|
|
@@ -17,6 +17,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
17
17
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
__exportStar(require("./analytics"), exports);
|
|
20
21
|
__exportStar(require("./browser"), exports);
|
|
21
22
|
__exportStar(require("./common"), exports);
|
|
22
23
|
__exportStar(require("./dev-server"), exports);
|
|
@@ -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
|
};
|