@angular-devkit/build-angular 14.0.0-next.1 → 14.0.0-next.12

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 (95) hide show
  1. package/README.md +10 -10
  2. package/builders.json +5 -0
  3. package/package.json +33 -34
  4. package/src/babel/plugins/pure-toplevel-functions.js +5 -1
  5. package/src/babel/presets/application.js +5 -1
  6. package/src/babel/webpack-loader.d.ts +1 -0
  7. package/src/babel/webpack-loader.js +2 -0
  8. package/src/builders/app-shell/index.js +8 -4
  9. package/src/builders/app-shell/schema.d.ts +2 -2
  10. package/src/builders/app-shell/schema.json +2 -2
  11. package/src/builders/browser/index.d.ts +2 -3
  12. package/src/builders/browser/index.js +13 -10
  13. package/src/builders/browser/schema.d.ts +0 -1
  14. package/src/builders/browser/schema.json +2 -3
  15. package/src/builders/browser-esbuild/compiler-plugin.d.ts +14 -0
  16. package/src/builders/browser-esbuild/compiler-plugin.js +338 -0
  17. package/src/builders/browser-esbuild/esbuild.d.ts +34 -0
  18. package/src/builders/browser-esbuild/esbuild.js +59 -0
  19. package/src/builders/browser-esbuild/experimental-warnings.d.ts +10 -0
  20. package/src/builders/browser-esbuild/experimental-warnings.js +65 -0
  21. package/src/builders/browser-esbuild/index.d.ts +19 -0
  22. package/src/builders/browser-esbuild/index.js +258 -0
  23. package/src/builders/browser-esbuild/options.d.ts +34 -0
  24. package/src/builders/browser-esbuild/options.js +87 -0
  25. package/src/builders/browser-esbuild/stylesheets.d.ts +52 -0
  26. package/src/builders/browser-esbuild/stylesheets.js +118 -0
  27. package/src/builders/dev-server/index.d.ts +1 -1
  28. package/src/builders/dev-server/index.js +5 -1
  29. package/src/builders/dev-server/schema.d.ts +1 -1
  30. package/src/builders/dev-server/schema.json +1 -1
  31. package/src/builders/extract-i18n/index.d.ts +1 -1
  32. package/src/builders/extract-i18n/index.js +5 -1
  33. package/src/builders/extract-i18n/ivy-extract-loader.js +5 -1
  34. package/src/builders/karma/find-tests.js +5 -1
  35. package/src/builders/karma/index.d.ts +1 -1
  36. package/src/builders/karma/index.js +10 -6
  37. package/src/builders/ng-packagr/index.js +5 -1
  38. package/src/builders/protractor/index.d.ts +2 -1
  39. package/src/builders/protractor/index.js +5 -1
  40. package/src/builders/server/index.d.ts +2 -3
  41. package/src/builders/server/index.js +5 -1
  42. package/src/builders/server/schema.json +1 -2
  43. package/src/index.js +5 -1
  44. package/src/typings.d.ts +0 -4
  45. package/src/utils/check-port.js +8 -4
  46. package/src/utils/color.js +5 -1
  47. package/src/utils/copy-assets.js +5 -1
  48. package/src/utils/delete-output-dir.js +6 -9
  49. package/src/utils/environment-options.d.ts +0 -1
  50. package/src/utils/environment-options.js +1 -13
  51. package/src/utils/i18n-inlining.js +5 -1
  52. package/src/utils/i18n-options.js +1 -8
  53. package/src/utils/index-file/html-rewriting-stream.js +5 -1
  54. package/src/utils/index-file/index-html-generator.js +5 -1
  55. package/src/utils/index-file/inline-critical-css.js +5 -1
  56. package/src/utils/index-file/inline-fonts.js +5 -1
  57. package/src/utils/index.js +5 -1
  58. package/src/utils/load-translations.js +5 -1
  59. package/src/utils/normalize-asset-patterns.d.ts +2 -2
  60. package/src/utils/normalize-asset-patterns.js +34 -10
  61. package/src/utils/normalize-builder-schema.d.ts +2 -2
  62. package/src/utils/normalize-builder-schema.js +5 -6
  63. package/src/utils/normalize-cache.js +0 -4
  64. package/src/utils/normalize-file-replacements.d.ts +4 -4
  65. package/src/utils/normalize-file-replacements.js +38 -18
  66. package/src/utils/process-bundle.js +6 -2
  67. package/src/utils/purge-cache.js +3 -8
  68. package/src/utils/read-tsconfig.js +5 -1
  69. package/src/utils/service-worker.d.ts +1 -2
  70. package/src/utils/service-worker.js +14 -12
  71. package/src/utils/webpack-browser-config.js +14 -12
  72. package/src/webpack/configs/analytics.js +1 -4
  73. package/src/webpack/configs/common.js +10 -12
  74. package/src/webpack/configs/dev-server.js +6 -2
  75. package/src/webpack/configs/index.js +5 -1
  76. package/src/webpack/configs/styles.d.ts +6 -0
  77. package/src/webpack/configs/styles.js +16 -22
  78. package/src/webpack/plugins/analytics.d.ts +1 -2
  79. package/src/webpack/plugins/analytics.js +1 -3
  80. package/src/webpack/plugins/any-component-style-budget-checker.js +5 -1
  81. package/src/webpack/plugins/common-js-usage-warn-plugin.js +2 -2
  82. package/src/webpack/plugins/css-optimizer-plugin.js +7 -3
  83. package/src/webpack/plugins/esbuild-executor.d.ts +2 -2
  84. package/src/webpack/plugins/esbuild-executor.js +11 -17
  85. package/src/webpack/plugins/javascript-optimizer-plugin.js +8 -4
  86. package/src/webpack/plugins/json-stats-plugin.js +5 -1
  87. package/src/webpack/plugins/karma/karma.js +11 -27
  88. package/src/webpack/plugins/named-chunks-plugin.js +9 -0
  89. package/src/webpack/plugins/postcss-cli-resources.js +7 -3
  90. package/src/webpack/plugins/scripts-webpack-plugin.js +5 -1
  91. package/src/webpack/plugins/transfer-size-plugin.js +3 -2
  92. package/src/webpack/plugins/typescript.js +1 -2
  93. package/src/webpack/utils/helpers.js +5 -1
  94. package/src/webpack/utils/stats.js +5 -1
  95. package/esbuild-check.js +0 -16
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -27,8 +31,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
27
31
  };
28
32
  Object.defineProperty(exports, "__esModule", { value: true });
29
33
  exports.EsbuildExecutor = void 0;
30
- const child_process_1 = require("child_process");
31
- const path = __importStar(require("path"));
32
34
  /**
33
35
  * Provides the ability to execute esbuild regardless of the current platform's support
34
36
  * for using the native variant of esbuild. The native variant will be preferred (assuming
@@ -53,22 +55,14 @@ class EsbuildExecutor {
53
55
  /**
54
56
  * Determines whether the native variant of esbuild can be used on the current platform.
55
57
  *
56
- * @returns True, if the native variant of esbuild is support; False, if the WASM variant is required.
58
+ * @returns A promise which resolves to `true`, if the native variant of esbuild is support or `false`, if the WASM variant is required.
57
59
  */
58
- static hasNativeSupport() {
60
+ static async hasNativeSupport() {
59
61
  // Try to use native variant to ensure it is functional for the platform.
60
- // Spawning a separate esbuild check process is used to determine if the native
61
- // variant is viable. If check fails, the WASM variant is initialized instead.
62
- // Attempting to call one of the native esbuild functions is not a viable test
63
- // currently since esbuild spawn errors are currently not propagated through the
64
- // call stack for the esbuild function. If this limitation is removed in the future
65
- // then the separate process spawn check can be removed in favor of a direct function
66
- // call check.
67
62
  try {
68
- const { status, error } = (0, child_process_1.spawnSync)(process.execPath, [
69
- path.join(__dirname, '../../../esbuild-check.js'),
70
- ]);
71
- return status === 0 && error === undefined;
63
+ const { formatMessages } = await Promise.resolve().then(() => __importStar(require('esbuild')));
64
+ await formatMessages([], { kind: 'error' });
65
+ return true;
72
66
  }
73
67
  catch {
74
68
  return false;
@@ -84,7 +78,7 @@ class EsbuildExecutor {
84
78
  return;
85
79
  }
86
80
  // If the WASM variant was preferred at class construction or native is not supported, use WASM
87
- if (this.alwaysUseWasm || !EsbuildExecutor.hasNativeSupport()) {
81
+ if (this.alwaysUseWasm || !(await EsbuildExecutor.hasNativeSupport())) {
88
82
  await this.useWasm();
89
83
  this.initialized = true;
90
84
  return;
@@ -61,9 +61,10 @@ class JavaScriptOptimizerPlugin {
61
61
  cacheItem = cache.getItemCache(name, eTag);
62
62
  const cachedOutput = await cacheItem.getPromise();
63
63
  if (cachedOutput) {
64
- compilation.updateAsset(name, cachedOutput.source, {
64
+ compilation.updateAsset(name, cachedOutput.source, (assetInfo) => ({
65
+ ...assetInfo,
65
66
  minimized: true,
66
- });
67
+ }));
67
68
  continue;
68
69
  }
69
70
  }
@@ -110,7 +111,7 @@ class JavaScriptOptimizerPlugin {
110
111
  // Perform a single native esbuild support check.
111
112
  // This removes the need for each worker to perform the check which would
112
113
  // otherwise require spawning a separate process per worker.
113
- alwaysUseWasm: !esbuild_executor_1.EsbuildExecutor.hasNativeSupport(),
114
+ alwaysUseWasm: !(await esbuild_executor_1.EsbuildExecutor.hasNativeSupport()),
114
115
  };
115
116
  // Sort scripts so larger scripts start first - worker pool uses a FIFO queue
116
117
  scriptsToOptimize.sort((a, b) => a.code.length - b.code.length);
@@ -137,7 +138,10 @@ class JavaScriptOptimizerPlugin {
137
138
  const optimizedAsset = map
138
139
  ? new SourceMapSource(code, name, map)
139
140
  : new OriginalSource(code, name);
140
- compilation.updateAsset(name, optimizedAsset, { minimized: true });
141
+ compilation.updateAsset(name, optimizedAsset, (assetInfo) => ({
142
+ ...assetInfo,
143
+ minimized: true,
144
+ }));
141
145
  return cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.storePromise({
142
146
  source: optimizedAsset,
143
147
  });
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -30,7 +34,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
30
34
  };
31
35
  Object.defineProperty(exports, "__esModule", { value: true });
32
36
  const path = __importStar(require("path"));
33
- const glob = __importStar(require("glob"));
34
37
  const webpack_1 = __importDefault(require("webpack"));
35
38
  const webpack_dev_middleware_1 = __importDefault(require("webpack-dev-middleware"));
36
39
  const stats_1 = require("../../utils/stats");
@@ -42,27 +45,6 @@ let isBlocked = false;
42
45
  let webpackMiddleware;
43
46
  let successCb;
44
47
  let failureCb;
45
- // Add files to the Karma files array.
46
- function addKarmaFiles(files, newFiles, prepend = false) {
47
- const defaults = {
48
- included: true,
49
- served: true,
50
- watched: true,
51
- };
52
- const processedFiles = newFiles
53
- // Remove globs that do not match any files, otherwise Karma will show a warning for these.
54
- .filter((file) => glob.sync(file.pattern, { nodir: true }).length != 0)
55
- // Fill in pattern properties with defaults.
56
- .map((file) => ({ ...defaults, ...file }));
57
- // It's important to not replace the array, because
58
- // karma already has a reference to the existing array.
59
- if (prepend) {
60
- files.unshift(...processedFiles);
61
- }
62
- else {
63
- files.push(...processedFiles);
64
- }
65
- }
66
48
  const init = (config, emitter) => {
67
49
  if (!config.buildWebpack) {
68
50
  throw new Error(`The '@angular-devkit/build-angular/plugins/karma' karma plugin is meant to` +
@@ -80,10 +62,12 @@ const init = (config, emitter) => {
80
62
  // frameworks cannot be added dynamically.
81
63
  const smsPath = path.dirname(require.resolve('source-map-support'));
82
64
  const ksmsPath = path.dirname(require.resolve('karma-source-map-support'));
83
- addKarmaFiles(config.files, [
84
- { pattern: path.join(smsPath, 'browser-source-map-support.js'), watched: false },
85
- { pattern: path.join(ksmsPath, 'client.js'), watched: false },
86
- ], true);
65
+ config.files.unshift({
66
+ pattern: path.join(smsPath, 'browser-source-map-support.js'),
67
+ included: true,
68
+ served: true,
69
+ watched: false,
70
+ }, { pattern: path.join(ksmsPath, 'client.js'), included: true, served: true, watched: false });
87
71
  }
88
72
  config.reporters.unshift('@angular-devkit/build-angular--event-reporter');
89
73
  // When using code-coverage, auto-add karma-coverage.
@@ -24,6 +24,11 @@ class NamedChunksPlugin {
24
24
  if (chunk.name) {
25
25
  return;
26
26
  }
27
+ if ([...chunk.files.values()].every((f) => f.endsWith('.css'))) {
28
+ // If all chunk files are CSS files skip.
29
+ // This happens when using `import('./styles.css')` in a lazy loaded module.
30
+ return undefined;
31
+ }
27
32
  const name = this.generateName(chunk);
28
33
  if (name) {
29
34
  chunk.name = name;
@@ -37,6 +42,10 @@ class NamedChunksPlugin {
37
42
  if (!(block instanceof webpack_1.AsyncDependenciesBlock)) {
38
43
  continue;
39
44
  }
45
+ if (block.groupOptions.name) {
46
+ // Ignore groups which have been named already.
47
+ return undefined;
48
+ }
40
49
  for (const dependency of block.dependencies) {
41
50
  if (dependency instanceof ImportDependency) {
42
51
  return webpack_1.Template.toPath(dependency.request);
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -66,7 +70,7 @@ function default_1(options) {
66
70
  // If starts with a caret, remove and return remainder
67
71
  // this supports bypassing asset processing
68
72
  if (inputUrl.startsWith('^')) {
69
- return inputUrl.substr(1);
73
+ return inputUrl.slice(1);
70
74
  }
71
75
  const cacheKey = path.resolve(context, inputUrl);
72
76
  const cachedUrl = resourceCache.get(cacheKey);
@@ -74,7 +78,7 @@ function default_1(options) {
74
78
  return cachedUrl;
75
79
  }
76
80
  if (inputUrl.startsWith('~')) {
77
- inputUrl = inputUrl.substr(1);
81
+ inputUrl = inputUrl.slice(1);
78
82
  }
79
83
  const { pathname, hash, search } = url.parse(inputUrl.replace(/\\/g, '/'));
80
84
  const resolver = (file, base) => new Promise((resolve, reject) => {
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -31,9 +31,10 @@ class TransferSizePlugin {
31
31
  }
32
32
  actions.push(brotliCompressAsync(scriptAsset.source.source())
33
33
  .then((result) => {
34
- compilation.updateAsset(assetName, (s) => s, {
34
+ compilation.updateAsset(assetName, (s) => s, (assetInfo) => ({
35
+ ...assetInfo,
35
36
  estimatedTransferSize: result.length,
36
- });
37
+ }));
37
38
  })
38
39
  .catch((error) => {
39
40
  compilation.warnings.push(new compilation.compiler.webpack.WebpackError(`Unable to calculate estimated transfer size for '${assetName}'. Reason: ${error.message}`));
@@ -8,7 +8,6 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.createIvyPlugin = void 0;
11
- const core_1 = require("@angular-devkit/core");
12
11
  const webpack_1 = require("@ngtools/webpack");
13
12
  const typescript_1 = require("typescript");
14
13
  function ensureIvy(wco) {
@@ -44,7 +43,7 @@ function createIvyPlugin(wco, aot, tsconfig) {
44
43
  const fileReplacements = {};
45
44
  if (buildOptions.fileReplacements) {
46
45
  for (const replacement of buildOptions.fileReplacements) {
47
- fileReplacements[(0, core_1.getSystemPath)(replacement.replace)] = (0, core_1.getSystemPath)(replacement.with);
46
+ fileReplacements[replacement.replace] = replacement.with;
48
47
  }
49
48
  }
50
49
  let inlineStyleFileExtension;
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
package/esbuild-check.js DELETED
@@ -1,16 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
-
9
- // If the platform does not support the native variant of esbuild, this will crash.
10
- // This script can then be spawned by the CLI to determine if native usage is supported.
11
- require('esbuild')
12
- .formatMessages([], { kind: 'error ' })
13
- .then(
14
- () => {},
15
- () => {},
16
- );