@angular-devkit/build-angular 13.1.0-next.0 → 13.1.0-rc.0
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 -35
- package/src/babel/presets/application.d.ts +5 -2
- package/src/babel/presets/application.js +7 -14
- package/src/babel/webpack-loader.js +23 -14
- package/src/builders/browser/index.js +7 -5
- package/src/builders/dev-server/index.js +31 -2
- package/src/builders/extract-i18n/ivy-extract-loader.js +4 -1
- package/src/utils/build-options.d.ts +1 -0
- package/src/utils/bundle-calculator.d.ts +6 -7
- package/src/utils/bundle-calculator.js +3 -1
- package/src/utils/environment-options.d.ts +0 -1
- package/src/utils/environment-options.js +1 -4
- package/src/utils/i18n-options.d.ts +16 -10
- package/src/utils/i18n-options.js +46 -37
- package/src/utils/index-file/augment-index-html.d.ts +5 -1
- package/src/utils/index-file/augment-index-html.js +38 -5
- package/src/utils/index.d.ts +0 -1
- package/src/utils/index.js +0 -1
- package/src/utils/normalize-builder-schema.js +2 -0
- package/src/utils/read-tsconfig.js +1 -4
- package/src/utils/supported-browsers.d.ts +8 -0
- package/src/utils/supported-browsers.js +26 -0
- package/src/webpack/configs/common.js +27 -23
- package/src/webpack/configs/dev-server.js +78 -25
- package/src/webpack/configs/styles.js +23 -14
- package/src/webpack/plugins/hmr/hmr-accept.js +4 -1
- package/src/webpack/plugins/named-chunks-plugin.d.ts +17 -0
- package/src/webpack/plugins/named-chunks-plugin.js +49 -0
- package/src/webpack/plugins/transfer-size-plugin.d.ts +12 -0
- package/src/webpack/plugins/transfer-size-plugin.js +47 -0
- package/src/webpack/utils/helpers.d.ts +3 -1
- package/src/webpack/utils/helpers.js +18 -3
- package/src/webpack/utils/stats.d.ts +10 -3
- package/src/webpack/utils/stats.js +111 -33
- package/src/utils/build-browser-features.d.ts +0 -16
- package/src/utils/build-browser-features.js +0 -54
package/package.json
CHANGED
|
@@ -1,88 +1,88 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "13.1.0-
|
|
3
|
+
"version": "13.1.0-rc.0",
|
|
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
|
-
"@ampproject/remapping": "1.0.
|
|
10
|
-
"@angular-devkit/architect": "0.1301.0-
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1301.0-
|
|
12
|
-
"@angular-devkit/core": "13.1.0-
|
|
9
|
+
"@ampproject/remapping": "1.0.2",
|
|
10
|
+
"@angular-devkit/architect": "0.1301.0-rc.0",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1301.0-rc.0",
|
|
12
|
+
"@angular-devkit/core": "13.1.0-rc.0",
|
|
13
13
|
"@babel/core": "7.16.0",
|
|
14
14
|
"@babel/generator": "7.16.0",
|
|
15
15
|
"@babel/helper-annotate-as-pure": "7.16.0",
|
|
16
|
-
"@babel/plugin-proposal-async-generator-functions": "7.16.
|
|
16
|
+
"@babel/plugin-proposal-async-generator-functions": "7.16.4",
|
|
17
17
|
"@babel/plugin-transform-async-to-generator": "7.16.0",
|
|
18
|
-
"@babel/plugin-transform-runtime": "7.16.
|
|
19
|
-
"@babel/preset-env": "7.16.
|
|
20
|
-
"@babel/runtime": "7.16.
|
|
18
|
+
"@babel/plugin-transform-runtime": "7.16.4",
|
|
19
|
+
"@babel/preset-env": "7.16.4",
|
|
20
|
+
"@babel/runtime": "7.16.3",
|
|
21
21
|
"@babel/template": "7.16.0",
|
|
22
|
-
"@discoveryjs/json-ext": "0.5.
|
|
23
|
-
"@ngtools/webpack": "13.1.0-
|
|
22
|
+
"@discoveryjs/json-ext": "0.5.6",
|
|
23
|
+
"@ngtools/webpack": "13.1.0-rc.0",
|
|
24
24
|
"ansi-colors": "4.1.1",
|
|
25
25
|
"babel-loader": "8.2.3",
|
|
26
26
|
"babel-plugin-istanbul": "6.1.1",
|
|
27
27
|
"browserslist": "^4.9.1",
|
|
28
28
|
"cacache": "15.3.0",
|
|
29
|
-
"caniuse-lite": "^1.0.30001032",
|
|
30
29
|
"circular-dependency-plugin": "5.2.2",
|
|
31
|
-
"copy-webpack-plugin": "
|
|
32
|
-
"core-js": "3.19.
|
|
33
|
-
"critters": "0.0.
|
|
34
|
-
"css-loader": "6.5.
|
|
35
|
-
"esbuild-wasm": "0.
|
|
30
|
+
"copy-webpack-plugin": "10.0.0",
|
|
31
|
+
"core-js": "3.19.3",
|
|
32
|
+
"critters": "0.0.15",
|
|
33
|
+
"css-loader": "6.5.1",
|
|
34
|
+
"esbuild-wasm": "0.14.2",
|
|
36
35
|
"glob": "7.2.0",
|
|
37
36
|
"https-proxy-agent": "5.0.0",
|
|
38
37
|
"inquirer": "8.2.0",
|
|
38
|
+
"jsonc-parser": "3.0.0",
|
|
39
39
|
"karma-source-map-support": "1.4.0",
|
|
40
40
|
"less": "4.1.2",
|
|
41
41
|
"less-loader": "10.2.0",
|
|
42
|
-
"license-webpack-plugin": "
|
|
43
|
-
"loader-utils": "3.
|
|
44
|
-
"mini-css-extract-plugin": "2.4.
|
|
42
|
+
"license-webpack-plugin": "4.0.0",
|
|
43
|
+
"loader-utils": "3.2.0",
|
|
44
|
+
"mini-css-extract-plugin": "2.4.5",
|
|
45
45
|
"minimatch": "3.0.4",
|
|
46
46
|
"open": "8.4.0",
|
|
47
47
|
"ora": "5.4.1",
|
|
48
48
|
"parse5-html-rewriting-stream": "6.0.1",
|
|
49
49
|
"piscina": "3.1.0",
|
|
50
|
-
"postcss": "8.
|
|
50
|
+
"postcss": "8.4.4",
|
|
51
51
|
"postcss-import": "14.0.2",
|
|
52
|
-
"postcss-loader": "6.2.
|
|
52
|
+
"postcss-loader": "6.2.1",
|
|
53
53
|
"postcss-preset-env": "6.7.0",
|
|
54
54
|
"regenerator-runtime": "0.13.9",
|
|
55
55
|
"resolve-url-loader": "4.0.0",
|
|
56
56
|
"rxjs": "6.6.7",
|
|
57
|
-
"sass": "1.
|
|
58
|
-
"sass-loader": "12.
|
|
57
|
+
"sass": "1.44.0",
|
|
58
|
+
"sass-loader": "12.4.0",
|
|
59
59
|
"semver": "7.3.5",
|
|
60
60
|
"source-map-loader": "3.0.0",
|
|
61
|
-
"source-map-support": "0.5.
|
|
61
|
+
"source-map-support": "0.5.21",
|
|
62
62
|
"stylus": "0.55.0",
|
|
63
63
|
"stylus-loader": "6.2.0",
|
|
64
|
-
"terser": "5.
|
|
64
|
+
"terser": "5.10.0",
|
|
65
65
|
"text-table": "0.2.0",
|
|
66
66
|
"tree-kill": "1.2.2",
|
|
67
67
|
"tslib": "2.3.1",
|
|
68
|
-
"webpack": "5.
|
|
69
|
-
"webpack-dev-middleware": "5.2.
|
|
70
|
-
"webpack-dev-server": "4.
|
|
68
|
+
"webpack": "5.65.0",
|
|
69
|
+
"webpack-dev-middleware": "5.2.2",
|
|
70
|
+
"webpack-dev-server": "4.6.0",
|
|
71
71
|
"webpack-merge": "5.8.0",
|
|
72
72
|
"webpack-subresource-integrity": "5.0.0"
|
|
73
73
|
},
|
|
74
74
|
"optionalDependencies": {
|
|
75
|
-
"esbuild": "0.
|
|
75
|
+
"esbuild": "0.14.2"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"@angular/compiler-cli": "^13.0.0 || ^13.
|
|
79
|
-
"@angular/localize": "^13.0.0 || ^13.
|
|
80
|
-
"@angular/service-worker": "^13.0.0 || ^13.
|
|
78
|
+
"@angular/compiler-cli": "^13.0.0 || ^13.1.0-next",
|
|
79
|
+
"@angular/localize": "^13.0.0 || ^13.1.0-next",
|
|
80
|
+
"@angular/service-worker": "^13.0.0 || ^13.1.0-next",
|
|
81
81
|
"karma": "^6.3.0",
|
|
82
|
-
"ng-packagr": "^13.0.0 || ^13.
|
|
82
|
+
"ng-packagr": "^13.0.0 || ^13.1.0-next",
|
|
83
83
|
"protractor": "^7.0.0",
|
|
84
84
|
"tailwindcss": "^2.0.0",
|
|
85
|
-
"typescript": "
|
|
85
|
+
"typescript": ">=4.4.3 <4.6"
|
|
86
86
|
},
|
|
87
87
|
"peerDependenciesMeta": {
|
|
88
88
|
"@angular/localize": {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
+
import type { ɵParsedTranslation } from '@angular/localize/private';
|
|
8
9
|
import type { makeEs2015TranslatePlugin, makeEs5TranslatePlugin, makeLocalePlugin } from '@angular/localize/tools';
|
|
9
10
|
export declare type DiagnosticReporter = (type: 'error' | 'warning' | 'info', message: string) => void;
|
|
10
11
|
/**
|
|
@@ -22,8 +23,9 @@ export interface ApplicationPresetOptions {
|
|
|
22
23
|
i18n?: {
|
|
23
24
|
locale: string;
|
|
24
25
|
missingTranslationBehavior?: 'error' | 'warning' | 'ignore';
|
|
25
|
-
translation?:
|
|
26
|
-
|
|
26
|
+
translation?: Record<string, ɵParsedTranslation>;
|
|
27
|
+
translationFiles?: string[];
|
|
28
|
+
pluginCreators: I18nPluginCreators;
|
|
27
29
|
};
|
|
28
30
|
angularLinker?: {
|
|
29
31
|
shouldLink: boolean;
|
|
@@ -34,6 +36,7 @@ export interface ApplicationPresetOptions {
|
|
|
34
36
|
forceAsyncTransformation?: boolean;
|
|
35
37
|
instrumentCode?: {
|
|
36
38
|
includedBasePath: string;
|
|
39
|
+
inputSourceMap: unknown;
|
|
37
40
|
};
|
|
38
41
|
optimize?: {
|
|
39
42
|
looseEnums: boolean;
|
|
@@ -60,28 +60,18 @@ function createI18nDiagnostics(reporter) {
|
|
|
60
60
|
})();
|
|
61
61
|
return diagnostics;
|
|
62
62
|
}
|
|
63
|
-
function createI18nPlugins(locale, translation, missingTranslationBehavior, diagnosticReporter,
|
|
64
|
-
// TODO_ESM: Make `pluginCreators` required once `@angular/localize` is published with the `tools` entry point
|
|
65
|
-
pluginCreators) {
|
|
63
|
+
function createI18nPlugins(locale, translation, missingTranslationBehavior, diagnosticReporter, pluginCreators) {
|
|
66
64
|
const diagnostics = createI18nDiagnostics(diagnosticReporter);
|
|
67
65
|
const plugins = [];
|
|
66
|
+
const { makeEs5TranslatePlugin, makeEs2015TranslatePlugin, makeLocalePlugin } = pluginCreators;
|
|
68
67
|
if (translation) {
|
|
69
|
-
const { makeEs2015TranslatePlugin,
|
|
70
|
-
// TODO_ESM: Remove all deep imports once `@angular/localize` is published with the `tools` entry point
|
|
71
|
-
} = pluginCreators !== null && pluginCreators !== void 0 ? pluginCreators : require('@angular/localize/src/tools/src/translate/source_files/es2015_translate_plugin');
|
|
72
68
|
plugins.push(makeEs2015TranslatePlugin(diagnostics, translation, {
|
|
73
69
|
missingTranslation: missingTranslationBehavior,
|
|
74
70
|
}));
|
|
75
|
-
const { makeEs5TranslatePlugin,
|
|
76
|
-
// TODO_ESM: Remove all deep imports once `@angular/localize` is published with the `tools` entry point
|
|
77
|
-
} = pluginCreators !== null && pluginCreators !== void 0 ? pluginCreators : require('@angular/localize/src/tools/src/translate/source_files/es5_translate_plugin');
|
|
78
71
|
plugins.push(makeEs5TranslatePlugin(diagnostics, translation, {
|
|
79
72
|
missingTranslation: missingTranslationBehavior,
|
|
80
73
|
}));
|
|
81
74
|
}
|
|
82
|
-
const { makeLocalePlugin,
|
|
83
|
-
// TODO_ESM: Remove all deep imports once `@angular/localize` is published with the `tools` entry point
|
|
84
|
-
} = pluginCreators !== null && pluginCreators !== void 0 ? pluginCreators : require('@angular/localize/src/tools/src/translate/source_files/locale_plugin');
|
|
85
75
|
plugins.push(makeLocalePlugin(locale));
|
|
86
76
|
return plugins;
|
|
87
77
|
}
|
|
@@ -101,7 +91,7 @@ function createNgtscLogger(reporter) {
|
|
|
101
91
|
};
|
|
102
92
|
}
|
|
103
93
|
function default_1(api, options) {
|
|
104
|
-
var _a;
|
|
94
|
+
var _a, _b;
|
|
105
95
|
const presets = [];
|
|
106
96
|
const plugins = [];
|
|
107
97
|
let needRuntimeTransform = false;
|
|
@@ -160,7 +150,10 @@ function default_1(api, options) {
|
|
|
160
150
|
if (options.instrumentCode) {
|
|
161
151
|
plugins.push([
|
|
162
152
|
require('babel-plugin-istanbul').default,
|
|
163
|
-
{
|
|
153
|
+
{
|
|
154
|
+
inputSourceMap: (_b = options.instrumentCode.inputSourceMap) !== null && _b !== void 0 ? _b : false,
|
|
155
|
+
cwd: options.instrumentCode.includedBasePath,
|
|
156
|
+
},
|
|
164
157
|
]);
|
|
165
158
|
}
|
|
166
159
|
if (needRuntimeTransform) {
|
|
@@ -41,6 +41,7 @@ async function requiresLinking(path, source) {
|
|
|
41
41
|
}
|
|
42
42
|
return needsLinking(path, source);
|
|
43
43
|
}
|
|
44
|
+
// eslint-disable-next-line max-lines-per-function
|
|
44
45
|
exports.default = (0, babel_loader_1.custom)(() => {
|
|
45
46
|
const baseOptions = Object.freeze({
|
|
46
47
|
babelrc: false,
|
|
@@ -51,7 +52,7 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
51
52
|
inputSourceMap: false,
|
|
52
53
|
});
|
|
53
54
|
return {
|
|
54
|
-
async customOptions(options, { source }) {
|
|
55
|
+
async customOptions(options, { source, map }) {
|
|
55
56
|
var _a, _b;
|
|
56
57
|
const { i18n, scriptTarget, aot, optimize, instrumentCode, ...rawOptions } = options;
|
|
57
58
|
// Must process file if plugins are added
|
|
@@ -65,13 +66,10 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
65
66
|
};
|
|
66
67
|
// Analyze file for linking
|
|
67
68
|
if (await requiresLinking(this.resourcePath, source)) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const linkerBabelModule = await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/linker/babel');
|
|
73
|
-
linkerPluginCreator = linkerBabelModule.createEs2015LinkerPlugin;
|
|
74
|
-
}
|
|
69
|
+
// Load ESM `@angular/compiler-cli/linker/babel` using the TypeScript dynamic import workaround.
|
|
70
|
+
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
71
|
+
// changed to a direct dynamic import.
|
|
72
|
+
linkerPluginCreator !== null && linkerPluginCreator !== void 0 ? linkerPluginCreator : (linkerPluginCreator = (await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/linker/babel')).createEs2015LinkerPlugin);
|
|
75
73
|
customOptions.angularLinker = {
|
|
76
74
|
shouldLink: true,
|
|
77
75
|
jitMode: aot !== true,
|
|
@@ -104,20 +102,24 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
104
102
|
// During the transition, this will always attempt to load the entry point for each file.
|
|
105
103
|
// This will only occur during prerelease and will be automatically corrected once the new
|
|
106
104
|
// entry point exists.
|
|
107
|
-
// TODO_ESM: Make import failure an error once the `tools` entry point exists.
|
|
108
105
|
if (i18nPluginCreators === undefined) {
|
|
109
106
|
// Load ESM `@angular/localize/tools` using the TypeScript dynamic import workaround.
|
|
110
107
|
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
111
108
|
// changed to a direct dynamic import.
|
|
112
|
-
|
|
113
|
-
i18nPluginCreators = await (0, load_esm_1.loadEsmModule)('@angular/localize/tools');
|
|
114
|
-
}
|
|
115
|
-
catch { }
|
|
109
|
+
i18nPluginCreators = await (0, load_esm_1.loadEsmModule)('@angular/localize/tools');
|
|
116
110
|
}
|
|
117
111
|
customOptions.i18n = {
|
|
118
112
|
...i18n,
|
|
119
113
|
pluginCreators: i18nPluginCreators,
|
|
120
114
|
};
|
|
115
|
+
// Add translation files as dependencies of the file to support rebuilds
|
|
116
|
+
// Except for `@angular/core` which needs locale injection but has no translations
|
|
117
|
+
if (customOptions.i18n.translationFiles &&
|
|
118
|
+
!/[\\/]@angular[\\/]core/.test(this.resourcePath)) {
|
|
119
|
+
for (const file of customOptions.i18n.translationFiles) {
|
|
120
|
+
this.addDependency(file);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
121
123
|
shouldProcess = true;
|
|
122
124
|
}
|
|
123
125
|
if (optimize) {
|
|
@@ -140,6 +142,7 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
140
142
|
// `babel-plugin-istanbul` has it's own includes but we do the below so that we avoid running the the loader.
|
|
141
143
|
customOptions.instrumentCode = {
|
|
142
144
|
includedBasePath: instrumentCode.includedBasePath,
|
|
145
|
+
inputSourceMap: map,
|
|
143
146
|
};
|
|
144
147
|
shouldProcess = true;
|
|
145
148
|
}
|
|
@@ -198,7 +201,13 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
198
201
|
// `@ampproject/remapping` source map objects but both are compatible with Webpack.
|
|
199
202
|
// This method for merging is used because it provides more accurate output
|
|
200
203
|
// and is faster while using less memory.
|
|
201
|
-
result.map =
|
|
204
|
+
result.map = {
|
|
205
|
+
// Convert the SourceMap back to simple plain object.
|
|
206
|
+
// This is needed because otherwise code-coverage will fail with `don't know how to turn this value into a node`
|
|
207
|
+
// Which is thrown by Babel if it is invoked again from `istanbul-lib-instrument`.
|
|
208
|
+
// https://github.com/babel/babel/blob/780aa48d2a34dc55f556843074b6aed45e7eabeb/packages/babel-types/src/converters/valueToNode.ts#L115-L130
|
|
209
|
+
...(0, remapping_1.default)([result.map, inputSourceMap], () => null),
|
|
210
|
+
};
|
|
202
211
|
}
|
|
203
212
|
return result;
|
|
204
213
|
},
|
|
@@ -46,6 +46,7 @@ const output_paths_1 = require("../../utils/output-paths");
|
|
|
46
46
|
const package_chunk_sort_1 = require("../../utils/package-chunk-sort");
|
|
47
47
|
const service_worker_1 = require("../../utils/service-worker");
|
|
48
48
|
const spinner_1 = require("../../utils/spinner");
|
|
49
|
+
const supported_browsers_1 = require("../../utils/supported-browsers");
|
|
49
50
|
const version_1 = require("../../utils/version");
|
|
50
51
|
const webpack_browser_config_1 = require("../../utils/webpack-browser-config");
|
|
51
52
|
const configs_1 = require("../../webpack/configs");
|
|
@@ -97,8 +98,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
97
98
|
return (0, rxjs_1.from)(context.getProjectMetadata(projectName)).pipe((0, operators_1.switchMap)(async (projectMetadata) => {
|
|
98
99
|
var _a;
|
|
99
100
|
const sysProjectRoot = (0, core_1.getSystemPath)((0, core_1.resolve)((0, core_1.normalize)(context.workspaceRoot), (0, core_1.normalize)((_a = projectMetadata.root) !== null && _a !== void 0 ? _a : '')));
|
|
100
|
-
|
|
101
|
-
checkInternetExplorerSupport(buildBrowserFeatures.supportedBrowsers, context.logger);
|
|
101
|
+
checkInternetExplorerSupport(sysProjectRoot, context.logger);
|
|
102
102
|
return {
|
|
103
103
|
...(await initialize(options, context, transforms.webpackConfiguration)),
|
|
104
104
|
cacheOptions: (0, normalize_cache_1.normalizeCacheOptions)(projectMetadata, context.workspaceRoot),
|
|
@@ -155,8 +155,9 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
155
155
|
}
|
|
156
156
|
// Check for budget errors and display them to the user.
|
|
157
157
|
const budgets = options.budgets;
|
|
158
|
+
let budgetFailures;
|
|
158
159
|
if (budgets === null || budgets === void 0 ? void 0 : budgets.length) {
|
|
159
|
-
|
|
160
|
+
budgetFailures = [...(0, bundle_calculator_1.checkBudgets)(budgets, webpackStats)];
|
|
160
161
|
for (const { severity, message } of budgetFailures) {
|
|
161
162
|
switch (severity) {
|
|
162
163
|
case bundle_calculator_1.ThresholdSeverity.Warning:
|
|
@@ -250,7 +251,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
250
251
|
spinner.succeed('Service worker generation complete.');
|
|
251
252
|
}
|
|
252
253
|
}
|
|
253
|
-
(0, stats_1.webpackStatsLogger)(context.logger, webpackStats, config);
|
|
254
|
+
(0, stats_1.webpackStatsLogger)(context.logger, webpackStats, config, budgetFailures);
|
|
254
255
|
return { success: buildSuccess };
|
|
255
256
|
}
|
|
256
257
|
}), (0, operators_1.map)((event) => ({
|
|
@@ -290,7 +291,8 @@ function mapEmittedFilesToFileInfo(files = []) {
|
|
|
290
291
|
}
|
|
291
292
|
return filteredFiles;
|
|
292
293
|
}
|
|
293
|
-
function checkInternetExplorerSupport(
|
|
294
|
+
function checkInternetExplorerSupport(projectRoot, logger) {
|
|
295
|
+
const supportedBrowsers = (0, supported_browsers_1.getSupportedBrowsers)(projectRoot);
|
|
294
296
|
if (supportedBrowsers.some((b) => b === 'ie 9' || b === 'ie 10' || b === 'ie 11')) {
|
|
295
297
|
logger.warn(`Warning: Support was requested for Internet Explorer in the project's browserslist configuration. ` +
|
|
296
298
|
'Internet Explorer is no longer officially supported.' +
|
|
@@ -37,10 +37,13 @@ const url = __importStar(require("url"));
|
|
|
37
37
|
const utils_1 = require("../../utils");
|
|
38
38
|
const check_port_1 = require("../../utils/check-port");
|
|
39
39
|
const color_1 = require("../../utils/color");
|
|
40
|
+
const i18n_options_1 = require("../../utils/i18n-options");
|
|
41
|
+
const load_translations_1 = require("../../utils/load-translations");
|
|
40
42
|
const normalize_cache_1 = require("../../utils/normalize-cache");
|
|
41
43
|
const package_chunk_sort_1 = require("../../utils/package-chunk-sort");
|
|
42
44
|
const version_1 = require("../../utils/version");
|
|
43
45
|
const webpack_browser_config_1 = require("../../utils/webpack-browser-config");
|
|
46
|
+
const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
|
|
44
47
|
const configs_1 = require("../../webpack/configs");
|
|
45
48
|
const index_html_webpack_plugin_1 = require("../../webpack/plugins/index-html-webpack-plugin");
|
|
46
49
|
const stats_1 = require("../../webpack/utils/stats");
|
|
@@ -145,7 +148,7 @@ function serveWebpackBrowser(options, context, transforms = {}) {
|
|
|
145
148
|
if (i18n.inlineLocales.size > 1) {
|
|
146
149
|
throw new Error('The development server only supports localizing a single locale per build.');
|
|
147
150
|
}
|
|
148
|
-
await setupLocalize(locale, i18n, browserOptions, webpackConfig, cacheOptions);
|
|
151
|
+
await setupLocalize(locale, i18n, browserOptions, webpackConfig, cacheOptions, context);
|
|
149
152
|
}
|
|
150
153
|
if (transforms.webpackConfiguration) {
|
|
151
154
|
webpackConfig = await transforms.webpackConfiguration(webpackConfig);
|
|
@@ -220,7 +223,7 @@ function serveWebpackBrowser(options, context, transforms = {}) {
|
|
|
220
223
|
}));
|
|
221
224
|
}
|
|
222
225
|
exports.serveWebpackBrowser = serveWebpackBrowser;
|
|
223
|
-
async function setupLocalize(locale, i18n, browserOptions, webpackConfig, cacheOptions) {
|
|
226
|
+
async function setupLocalize(locale, i18n, browserOptions, webpackConfig, cacheOptions, context) {
|
|
224
227
|
var _a;
|
|
225
228
|
const localeDescription = i18n.locales[locale];
|
|
226
229
|
// Modify main entrypoint to include locale data
|
|
@@ -248,6 +251,7 @@ async function setupLocalize(locale, i18n, browserOptions, webpackConfig, cacheO
|
|
|
248
251
|
locale,
|
|
249
252
|
missingTranslationBehavior,
|
|
250
253
|
translation: i18n.shouldInline ? translation : undefined,
|
|
254
|
+
translationFiles: localeDescription === null || localeDescription === void 0 ? void 0 : localeDescription.files.map((file) => path.resolve(context.workspaceRoot, file.path)),
|
|
251
255
|
};
|
|
252
256
|
const i18nRule = {
|
|
253
257
|
test: /\.[cm]?[tj]sx?$/,
|
|
@@ -276,5 +280,30 @@ async function setupLocalize(locale, i18n, browserOptions, webpackConfig, cacheO
|
|
|
276
280
|
webpackConfig.module.rules = rules;
|
|
277
281
|
}
|
|
278
282
|
rules.push(i18nRule);
|
|
283
|
+
// Add a plugin to reload translation files on rebuilds
|
|
284
|
+
const loader = await (0, load_translations_1.createTranslationLoader)();
|
|
285
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
286
|
+
webpackConfig.plugins.push({
|
|
287
|
+
apply: (compiler) => {
|
|
288
|
+
compiler.hooks.thisCompilation.tap('build-angular', (compilation) => {
|
|
289
|
+
if (i18n.shouldInline && i18nLoaderOptions.translation === undefined) {
|
|
290
|
+
// Reload translations
|
|
291
|
+
(0, i18n_options_1.loadTranslations)(locale, localeDescription, context.workspaceRoot, loader, {
|
|
292
|
+
warn(message) {
|
|
293
|
+
(0, webpack_diagnostics_1.addWarning)(compilation, message);
|
|
294
|
+
},
|
|
295
|
+
error(message) {
|
|
296
|
+
(0, webpack_diagnostics_1.addError)(compilation, message);
|
|
297
|
+
},
|
|
298
|
+
});
|
|
299
|
+
i18nLoaderOptions.translation = localeDescription.translation;
|
|
300
|
+
}
|
|
301
|
+
compilation.hooks.finishModules.tap('build-angular', () => {
|
|
302
|
+
// After loaders are finished, clear out the now unneeded translations
|
|
303
|
+
i18nLoaderOptions.translation = undefined;
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
},
|
|
307
|
+
});
|
|
279
308
|
}
|
|
280
309
|
exports.default = (0, architect_1.createBuilder)(serveWebpackBrowser);
|
|
@@ -29,6 +29,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
const nodePath = __importStar(require("path"));
|
|
30
30
|
const load_esm_1 = require("../../utils/load-esm");
|
|
31
31
|
function localizeExtractLoader(content, map) {
|
|
32
|
+
// This loader is not cacheable due to how message extraction works.
|
|
33
|
+
// Extracted messages are not part of webpack pipeline and hence they cannot be retrieved from cache.
|
|
34
|
+
// TODO: We should investigate in the future on making this deterministic and more cacheable.
|
|
35
|
+
this.cacheable(false);
|
|
32
36
|
const options = this.getOptions();
|
|
33
37
|
const callback = this.async();
|
|
34
38
|
extract(this, content, map, options).then(() => {
|
|
@@ -43,7 +47,6 @@ async function extract(loaderContext, content, map, options) {
|
|
|
43
47
|
// Try to load the `@angular/localize` message extractor.
|
|
44
48
|
// All the localize usages are setup to first try the ESM entry point then fallback to the deep imports.
|
|
45
49
|
// This provides interim compatibility while the framework is transitioned to bundled ESM packages.
|
|
46
|
-
// TODO_ESM: Remove all deep imports once `@angular/localize` is published with the `tools` entry point
|
|
47
50
|
let MessageExtractor;
|
|
48
51
|
try {
|
|
49
52
|
// Load ESM `@angular/localize/tools` using the TypeScript dynamic import workaround.
|
|
@@ -61,6 +61,7 @@ export interface BuildOptions {
|
|
|
61
61
|
cache: NormalizedCachedOptions;
|
|
62
62
|
codeCoverage?: boolean;
|
|
63
63
|
codeCoverageExclude?: string[];
|
|
64
|
+
supportedBrowsers: string[];
|
|
64
65
|
}
|
|
65
66
|
export interface WebpackDevServerOptions extends BuildOptions, Omit<DevServerSchema, 'optimization' | 'sourceMap' | 'browserTarget'> {
|
|
66
67
|
}
|
|
@@ -20,13 +20,12 @@ export declare enum ThresholdSeverity {
|
|
|
20
20
|
Warning = "warning",
|
|
21
21
|
Error = "error"
|
|
22
22
|
}
|
|
23
|
-
export
|
|
24
|
-
export declare function checkBudgets(budgets: Budget[], webpackStats: StatsCompilation): IterableIterator<{
|
|
25
|
-
severity: ThresholdSeverity;
|
|
26
|
-
message: string;
|
|
27
|
-
}>;
|
|
28
|
-
export declare function checkThresholds(thresholds: IterableIterator<Threshold>, size: number, label?: string): IterableIterator<{
|
|
23
|
+
export interface BudgetCalculatorResult {
|
|
29
24
|
severity: ThresholdSeverity;
|
|
30
25
|
message: string;
|
|
31
|
-
|
|
26
|
+
label?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function calculateThresholds(budget: Budget): IterableIterator<Threshold>;
|
|
29
|
+
export declare function checkBudgets(budgets: Budget[], webpackStats: StatsCompilation): IterableIterator<BudgetCalculatorResult>;
|
|
30
|
+
export declare function checkThresholds(thresholds: IterableIterator<Threshold>, size: number, label?: string): IterableIterator<BudgetCalculatorResult>;
|
|
32
31
|
export {};
|
|
@@ -143,7 +143,7 @@ class BundleCalculator extends Calculator {
|
|
|
143
143
|
.filter((chunk) => { var _a; return (_a = chunk === null || chunk === void 0 ? void 0 : chunk.names) === null || _a === void 0 ? void 0 : _a.includes(budgetName); })
|
|
144
144
|
.map((chunk) => this.calculateChunkSize(chunk))
|
|
145
145
|
.reduce((l, r) => l + r, 0);
|
|
146
|
-
return [{ size, label:
|
|
146
|
+
return [{ size, label: this.budget.name }];
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
@@ -262,6 +262,7 @@ function* checkThresholds(thresholds, size, label) {
|
|
|
262
262
|
const sizeDifference = (0, stats_1.formatSize)(size - threshold.limit);
|
|
263
263
|
yield {
|
|
264
264
|
severity: threshold.severity,
|
|
265
|
+
label,
|
|
265
266
|
message: `${label} exceeded maximum budget. Budget ${(0, stats_1.formatSize)(threshold.limit)} was not met by ${sizeDifference} with a total of ${(0, stats_1.formatSize)(size)}.`,
|
|
266
267
|
};
|
|
267
268
|
break;
|
|
@@ -273,6 +274,7 @@ function* checkThresholds(thresholds, size, label) {
|
|
|
273
274
|
const sizeDifference = (0, stats_1.formatSize)(threshold.limit - size);
|
|
274
275
|
yield {
|
|
275
276
|
severity: threshold.severity,
|
|
277
|
+
label,
|
|
276
278
|
message: `${label} failed to meet minimum budget. Budget ${(0, stats_1.formatSize)(threshold.limit)} was not met by ${sizeDifference} with a total of ${(0, stats_1.formatSize)(size)}.`,
|
|
277
279
|
};
|
|
278
280
|
break;
|
|
@@ -8,6 +8,5 @@
|
|
|
8
8
|
export declare const allowMangle: boolean;
|
|
9
9
|
export declare const shouldBeautify: boolean;
|
|
10
10
|
export declare const allowMinify: boolean;
|
|
11
|
-
export declare const profilingEnabled: boolean;
|
|
12
11
|
export declare const maxWorkers: number;
|
|
13
12
|
export declare const cachingDisabled: boolean | null;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.cachingDisabled = exports.maxWorkers = exports.
|
|
10
|
+
exports.cachingDisabled = exports.maxWorkers = exports.allowMinify = exports.shouldBeautify = exports.allowMangle = void 0;
|
|
11
11
|
const color_1 = require("./color");
|
|
12
12
|
function isDisabled(variable) {
|
|
13
13
|
return variable === '0' || variable.toLowerCase() === 'false';
|
|
@@ -57,9 +57,6 @@ exports.allowMangle = isPresent(mangleVariable)
|
|
|
57
57
|
: debugOptimize.mangle;
|
|
58
58
|
exports.shouldBeautify = debugOptimize.beautify;
|
|
59
59
|
exports.allowMinify = debugOptimize.minify;
|
|
60
|
-
// Build profiling
|
|
61
|
-
const profilingVariable = process.env['NG_BUILD_PROFILING'];
|
|
62
|
-
exports.profilingEnabled = isPresent(profilingVariable) && isEnabled(profilingVariable);
|
|
63
60
|
/**
|
|
64
61
|
* Some environments, like CircleCI which use Docker report a number of CPUs by the host and not the count of available.
|
|
65
62
|
* This cause `Error: Call retries were exceeded` errors when trying to use them.
|
|
@@ -9,19 +9,21 @@ import { BuilderContext } from '@angular-devkit/architect';
|
|
|
9
9
|
import { json } from '@angular-devkit/core';
|
|
10
10
|
import { Schema as BrowserBuilderSchema } from '../builders/browser/schema';
|
|
11
11
|
import { Schema as ServerBuilderSchema } from '../builders/server/schema';
|
|
12
|
+
import { TranslationLoader } from './load-translations';
|
|
13
|
+
export interface LocaleDescription {
|
|
14
|
+
files: {
|
|
15
|
+
path: string;
|
|
16
|
+
integrity?: string;
|
|
17
|
+
format?: string;
|
|
18
|
+
}[];
|
|
19
|
+
translation?: Record<string, unknown>;
|
|
20
|
+
dataPath?: string;
|
|
21
|
+
baseHref?: string;
|
|
22
|
+
}
|
|
12
23
|
export interface I18nOptions {
|
|
13
24
|
inlineLocales: Set<string>;
|
|
14
25
|
sourceLocale: string;
|
|
15
|
-
locales: Record<string,
|
|
16
|
-
files: {
|
|
17
|
-
path: string;
|
|
18
|
-
integrity?: string;
|
|
19
|
-
format?: string;
|
|
20
|
-
}[];
|
|
21
|
-
translation?: Record<string, unknown>;
|
|
22
|
-
dataPath?: string;
|
|
23
|
-
baseHref?: string;
|
|
24
|
-
}>;
|
|
26
|
+
locales: Record<string, LocaleDescription>;
|
|
25
27
|
flatOutput?: boolean;
|
|
26
28
|
readonly shouldInline: boolean;
|
|
27
29
|
hasDefinedSourceLocale?: boolean;
|
|
@@ -31,3 +33,7 @@ export declare function configureI18nBuild<T extends BrowserBuilderSchema | Serv
|
|
|
31
33
|
buildOptions: T;
|
|
32
34
|
i18n: I18nOptions;
|
|
33
35
|
}>;
|
|
36
|
+
export declare function loadTranslations(locale: string, desc: LocaleDescription, workspaceRoot: string, loader: TranslationLoader, logger: {
|
|
37
|
+
warn: (message: string) => void;
|
|
38
|
+
error: (message: string) => void;
|
|
39
|
+
}, usedFormats?: Set<string>): void;
|