@angular-devkit/build-angular 12.1.0-next.5 → 12.1.2

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.
Files changed (70) hide show
  1. package/package.json +24 -23
  2. package/src/app-shell/index.js +28 -8
  3. package/src/babel/plugins/adjust-static-class-members.js +4 -1
  4. package/src/babel/plugins/adjust-typescript-enums.js +4 -1
  5. package/src/babel/plugins/pure-toplevel-functions.js +24 -2
  6. package/src/babel/presets/application.js +25 -4
  7. package/src/browser/index.d.ts +1 -4
  8. package/src/browser/index.js +38 -36
  9. package/src/dev-server/index.d.ts +1 -1
  10. package/src/dev-server/index.js +31 -10
  11. package/src/dev-server/tests/execute-fetch.js +4 -1
  12. package/src/extract-i18n/index.d.ts +1 -1
  13. package/src/extract-i18n/index.js +34 -12
  14. package/src/extract-i18n/ivy-extract-loader.js +20 -1
  15. package/src/karma/find-tests.js +20 -1
  16. package/src/karma/index.js +21 -2
  17. package/src/ng-packagr/index.js +21 -2
  18. package/src/protractor/index.js +21 -2
  19. package/src/server/index.d.ts +1 -1
  20. package/src/server/index.js +21 -2
  21. package/src/server/tests/setup.d.ts +18 -0
  22. package/src/server/tests/setup.js +27 -0
  23. package/src/tslint/index.js +22 -3
  24. package/src/utils/action-cache.js +21 -2
  25. package/src/utils/action-executor.js +21 -2
  26. package/src/utils/build-browser-features.js +25 -3
  27. package/src/utils/cache-path.js +5 -2
  28. package/src/utils/check-port.js +20 -1
  29. package/src/utils/color.js +20 -1
  30. package/src/utils/copy-assets.js +26 -4
  31. package/src/utils/copy-file.js +20 -1
  32. package/src/utils/delete-output-dir.js +28 -2
  33. package/src/utils/environment-options.d.ts +1 -0
  34. package/src/utils/environment-options.js +26 -2
  35. package/src/utils/find-up.js +20 -1
  36. package/src/utils/i18n-inlining.js +21 -2
  37. package/src/utils/i18n-options.js +22 -3
  38. package/src/utils/index-file/html-rewriting-stream.js +20 -1
  39. package/src/utils/index-file/index-html-generator.js +20 -1
  40. package/src/utils/index-file/inline-critical-css.js +20 -1
  41. package/src/utils/index-file/inline-fonts.js +27 -5
  42. package/src/utils/is-directory.js +20 -1
  43. package/src/utils/load-translations.js +26 -7
  44. package/src/utils/process-bundle.js +34 -12
  45. package/src/utils/read-tsconfig.js +20 -1
  46. package/src/utils/service-worker.js +21 -2
  47. package/src/utils/spinner.js +5 -2
  48. package/src/utils/version.d.ts +1 -2
  49. package/src/utils/version.js +5 -4
  50. package/src/utils/webpack-browser-config.js +21 -2
  51. package/src/webpack/configs/analytics.d.ts +11 -0
  52. package/src/webpack/configs/analytics.js +29 -0
  53. package/src/webpack/configs/browser.js +0 -16
  54. package/src/webpack/configs/common.js +94 -16
  55. package/src/webpack/configs/dev-server.js +20 -1
  56. package/src/webpack/configs/index.d.ts +1 -0
  57. package/src/webpack/configs/index.js +1 -0
  58. package/src/webpack/configs/server.js +0 -1
  59. package/src/webpack/configs/styles.js +30 -2
  60. package/src/webpack/configs/test.js +32 -3
  61. package/src/webpack/configs/typescript.d.ts +2 -9
  62. package/src/webpack/configs/typescript.js +16 -14
  63. package/src/webpack/plugins/any-component-style-budget-checker.js +20 -1
  64. package/src/webpack/plugins/index.js +4 -1
  65. package/src/webpack/plugins/karma/karma.js +26 -4
  66. package/src/webpack/plugins/postcss-cli-resources.js +21 -2
  67. package/src/webpack/plugins/scripts-webpack-plugin.js +20 -1
  68. package/src/webpack/utils/helpers.js +20 -1
  69. package/src/webpack/utils/stats.d.ts +0 -1
  70. package/src/webpack/utils/stats.js +35 -12
@@ -6,6 +6,9 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
9
12
  Object.defineProperty(exports, "__esModule", { value: true });
10
13
  exports.PostcssCliResources = exports.CommonJsUsageWarnPlugin = exports.DedupeModuleResolvePlugin = exports.RemoveHashPlugin = exports.SuppressExtractedTextChunksWebpackPlugin = exports.ScriptsWebpackPlugin = exports.AnyComponentStyleBudgetChecker = void 0;
11
14
  // Exports the webpack plugins we use internally.
@@ -22,4 +25,4 @@ Object.defineProperty(exports, "DedupeModuleResolvePlugin", { enumerable: true,
22
25
  var common_js_usage_warn_plugin_1 = require("./common-js-usage-warn-plugin");
23
26
  Object.defineProperty(exports, "CommonJsUsageWarnPlugin", { enumerable: true, get: function () { return common_js_usage_warn_plugin_1.CommonJsUsageWarnPlugin; } });
24
27
  var postcss_cli_resources_1 = require("./postcss-cli-resources");
25
- Object.defineProperty(exports, "PostcssCliResources", { enumerable: true, get: function () { return postcss_cli_resources_1.default; } });
28
+ Object.defineProperty(exports, "PostcssCliResources", { enumerable: true, get: function () { return __importDefault(postcss_cli_resources_1).default; } });
@@ -6,10 +6,32 @@
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
- const path = require("path");
11
- const glob = require("glob");
12
- const webpack = require("webpack");
32
+ const path = __importStar(require("path"));
33
+ const glob = __importStar(require("glob"));
34
+ const webpack_1 = __importDefault(require("webpack"));
13
35
  const webpackDevMiddleware = require('webpack-dev-middleware');
14
36
  const stats_1 = require("../../utils/stats");
15
37
  const node_1 = require("@angular-devkit/core/node");
@@ -122,7 +144,7 @@ const init = (config, emitter) => {
122
144
  // Files need to be served from a custom path for Karma.
123
145
  webpackConfig.output.path = `/${KARMA_APPLICATION_PATH}/`;
124
146
  webpackConfig.output.publicPath = `/${KARMA_APPLICATION_PATH}/`;
125
- const compiler = webpack(webpackConfig, (error, stats) => {
147
+ const compiler = webpack_1.default(webpackConfig, (error, stats) => {
126
148
  var _a;
127
149
  if (error) {
128
150
  throw error;
@@ -6,11 +6,30 @@
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.postcss = void 0;
11
30
  const loader_utils_1 = require("loader-utils");
12
- const path = require("path");
13
- const url = require("url");
31
+ const path = __importStar(require("path"));
32
+ const url = __importStar(require("url"));
14
33
  function wrapUrl(url) {
15
34
  let wrappedUrl;
16
35
  const hasSingleQuotes = url.indexOf("'") >= 0;
@@ -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.ScriptsWebpackPlugin = void 0;
11
30
  const loader_utils_1 = require("loader-utils");
12
- const path = require("path");
31
+ const path = __importStar(require("path"));
13
32
  const webpack_1 = require("webpack");
14
33
  const Entrypoint = require('webpack/lib/Entrypoint');
15
34
  function addDependencies(compilation, scripts) {
@@ -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.assetNameTemplateFactory = exports.getWatchOptions = exports.isPolyfillsEntry = exports.getEsVersionForFileName = exports.getSourceMapDevTool = exports.normalizeExtraEntryPoints = exports.getOutputHashFormat = 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 typescript_1 = require("typescript");
14
33
  const webpack_1 = require("webpack");
15
34
  function getOutputHashFormat(option, length = 20) {
@@ -25,7 +25,6 @@ export declare function generateBundleStats(info: {
25
25
  rendered?: boolean;
26
26
  chunkType?: ChunkType;
27
27
  }): BundleStats;
28
- export declare const IGNORE_WARNINGS: RegExp[];
29
28
  export declare function statsWarningsToString(json: StatsCompilation, statsConfig: any): string;
30
29
  export declare function statsErrorsToString(json: StatsCompilation, statsConfig: any): string;
31
30
  export declare function statsHasErrors(json: StatsCompilation): boolean;
@@ -6,11 +6,33 @@
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
- exports.webpackStatsLogger = exports.createWebpackLoggingCallback = exports.statsHasWarnings = exports.statsHasErrors = exports.statsErrorsToString = exports.statsWarningsToString = exports.IGNORE_WARNINGS = exports.generateBundleStats = exports.formatSize = void 0;
32
+ exports.webpackStatsLogger = exports.createWebpackLoggingCallback = exports.statsHasWarnings = exports.statsHasErrors = exports.statsErrorsToString = exports.statsWarningsToString = exports.generateBundleStats = exports.formatSize = void 0;
11
33
  const core_1 = require("@angular-devkit/core");
12
- const path = require("path");
13
- const textTable = require("text-table");
34
+ const path = __importStar(require("path"));
35
+ const text_table_1 = __importDefault(require("text-table"));
14
36
  const color_1 = require("../../utils/color");
15
37
  const stats_1 = require("../configs/stats");
16
38
  const async_chunks_1 = require("./async-chunks");
@@ -105,7 +127,7 @@ function generateBuildStatsTable(data, colors, showTotalSize) {
105
127
  if (changedLazyChunksStats.length) {
106
128
  bundleInfo.push(['Lazy Chunk Files', 'Names', 'Size'].map(bold), ...changedLazyChunksStats);
107
129
  }
108
- return textTable(bundleInfo, {
130
+ return text_table_1.default(bundleInfo, {
109
131
  hsep: dim(' | '),
110
132
  stringLength: (s) => color_1.removeColor(s).length,
111
133
  align: ['l', 'l', 'r'],
@@ -115,6 +137,10 @@ function generateBuildStats(hash, time, colors) {
115
137
  const w = (x) => (colors ? color_1.colors.bold.white(x) : x);
116
138
  return `Build at: ${w(new Date().toISOString())} - Hash: ${w(hash)} - Time: ${w('' + time)}ms`;
117
139
  }
140
+ // We use this cache because we can have multiple builders running in the same process,
141
+ // where each builder has different output path.
142
+ // Ideally, we should create the logging callback as a factory, but that would need a refactoring.
143
+ const runsCache = new Set();
118
144
  function statsToString(json,
119
145
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
120
146
  statsConfig, bundleState) {
@@ -127,8 +153,11 @@ statsConfig, bundleState) {
127
153
  const changedChunksStats = bundleState !== null && bundleState !== void 0 ? bundleState : [];
128
154
  let unchangedChunkNumber = 0;
129
155
  if (!(bundleState === null || bundleState === void 0 ? void 0 : bundleState.length)) {
156
+ const isFirstRun = !runsCache.has(json.outputPath || '');
130
157
  for (const chunk of json.chunks) {
131
- if (!chunk.rendered) {
158
+ // During first build we want to display unchanged chunks
159
+ // but unchanged cached chunks are always marked as not rendered.
160
+ if (!isFirstRun && !chunk.rendered) {
132
161
  continue;
133
162
  }
134
163
  const assets = (_b = json.assets) === null || _b === void 0 ? void 0 : _b.filter((asset) => { var _a; return (_a = chunk.files) === null || _a === void 0 ? void 0 : _a.includes(asset.name); });
@@ -136,6 +165,7 @@ statsConfig, bundleState) {
136
165
  changedChunksStats.push(generateBundleStats({ ...chunk, size: summedSize }));
137
166
  }
138
167
  unchangedChunkNumber = json.chunks.length - changedChunksStats.length;
168
+ runsCache.add(json.outputPath || '');
139
169
  }
140
170
  // Sort chunks by size in descending order
141
171
  changedChunksStats.sort((a, b) => {
@@ -174,13 +204,6 @@ statsConfig, bundleState) {
174
204
  `));
175
205
  }
176
206
  }
177
- exports.IGNORE_WARNINGS = [
178
- // Webpack 5+ has no facility to disable this warning.
179
- // System.import is used in @angular/core for deprecated string-form lazy routes
180
- /System.import\(\) is deprecated and will be removed soon/i,
181
- // https://github.com/webpack-contrib/source-map-loader/blob/b2de4249c7431dd8432da607e08f0f65e9d64219/src/index.js#L83
182
- /Failed to parse source map from/,
183
- ];
184
207
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
185
208
  function statsWarningsToString(json, statsConfig) {
186
209
  const colors = statsConfig.colors;